Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning R Programming

You're reading from  Learning R Programming

Product type Book
Published in Oct 2016
Publisher Packt
ISBN-13 9781785889776
Pages 582 pages
Edition 1st Edition
Languages
Author (1):
Kun Ren Kun Ren
Profile icon Kun Ren

Table of Contents (21) Chapters

Learning R Programming
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Quick Start 2. Basic Objects 3. Managing Your Workspace 4. Basic Expressions 5. Working with Basic Objects 6. Working with Strings 7. Working with Data 8. Inside R 9. Metaprogramming 10. Object-Oriented Programming 11. Working with Databases 12. Data Manipulation 13. High-Performance Computing 14. Web Scraping 15. Boosting Productivity

Reading and writing data


The first step in any kind of data analysis in R is to load data, that is, to import a dataset into the environment. Before that, we have to figure out the type of data file and choose appropriate tools to read the data.

Reading and writing text-format data in a file

Among all the file types used to store data, perhaps the most widely used one is CSV. In a typical CSV file, the first line is the header of columns, and each subsequent line represents a data record with columns separated by commas. Here is an example of student records written in this format:

Name,Gender,Age,Major
Ken,Male,24,Finance
Ashley,Female,25,Statistics
Jennifer,Female,23,Computer Science

Importing data via RStudio IDE

RStudio provides an interactive way to import data. You can navigate to Tools | Import Dataset | From Local File and choose a local file in a text format, such as .csv and .txt. Then, you can adjust the parameters and preview the resulting data frame:

Note that you should check Strings...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}