You can use the XLConnect
package to read .xls or .xlsx files into R. Suppose you have a file named example.xls in your working directory. You can read the data on sheet1 into R using the following commands.
Alternatively, you can read in the data by sheet name. For example, the following code will read the data on the sheet named “raw_data” into R.
After reading an excel file into R, you often want to tidy up the data. Here’re some functions I use frequently for that purpose:
- lapply
- vapply
- strsplit
- paste
- tolower
- gsub