R is for read_

April 21, 2020
By

[This article was first published on Deeply Trivial, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The tidyverse is full of functions for reading data, beginning with “read_”. The read_csv I’ve used to access my reads2019 data is one example, falling under the read_delim functions. read_tsv allows you to quickly read in tab-delimited files. And you can also read in files with other delimiters, using read_delim and specifying the delimiter used. You can also tell R if the file contains column names and whether those should be read in too, using col_names = TRUE.

But there are many more read_ functions you can use:

  • read_clip: Data from the clipboard
  • read_+ dta, sas, or spss: Data from other statistical programs
  • read_json: JSON data
  • read_fwf: Fixed-width files
  • read_lines: Line from a file
  • read_excel: Excel files – you’ll also need to include the worksheet name or number

All of these functions are included as part of the tidyverse packages, though for some, you may need to load the single package if it doesn’t automatically load with library(tidyverse) – this includes haven (for dta, sas, and spss) and readxl (for read_excel).

You can find out more about a particular function by typing ?[functionname] into the R console. Or use ?? before to search all of R help for a particular string, such as ??read_.

Tomorrow, let’s talk about summarizing data!

To leave a comment for the author, please follow the link and comment on their blog: Deeply Trivial.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)