Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Data In and Out of R Introduction to R, Part II

Similar presentations


Presentation on theme: "Getting Data In and Out of R Introduction to R, Part II"— Presentation transcript:

1 Getting Data In and Out of R Introduction to R, Part II
Anna Blackstock Statistician, Biostatistics and Information Management Office (BIMO) NCEZID/DFWED

2 Getting Data Into R You can create vectors and other data structures in R (which you already know)

3 Getting Data Into R In your work, though, you may not use simple vectors much! You probably have data saved that you will need to read into R. Luckily, R can read in (and save) data of many types.

4 Getting Data into R Type Read In (Extension) R Package Function
General table Base R read.table() CSV (.csv) read.csv() readr read_csv()* Excel (.xlsx or .xls) readxl read_excel()* SAS (.sas7bdat) haven read_sas()* *Creates a data frame with bonus features called a “tibble.”

5 Getting Data into R: Tips
Remember to look at the help for the functions you are using. What are the default parameter values? What parameters need to be changed? Always check your data before running analyses. Are data types appropriate? Are missing values being handled correctly?

6 Saving Datasets Many functions for reading data have counterparts for saving data. Type Saved (Extension) R Package Function General table Base R write.table() CSV (.csv) write.csv() readr write_csv() SAS (.sas7bdat) haven write_sas()

7 Saving R Objects You can also save and import R objects directly.
Examples: saveRDS() and readRDS in base R write_rds() and read_rds() in “readr” package

8 Where to next? Check out the data import chapter of “R for Data Science”:


Download ppt "Getting Data In and Out of R Introduction to R, Part II"

Similar presentations


Ads by Google