How to read data from an Excel .xlsx file in R

To read directly from a .xlsx in the same directory as your R script:

> data <- read.xlsx(“yourdata.xlsx”)

… or …

To read from a workspace directory containing a .xlsx file:

> wdir = “C:/workspace/yourdirectory”
> data <- read.xlsx(paste(wdir, “yoursubdirectory”, “yourdata.xlsx”, sep=“/”))

… or …

To read from the second sheet of a .xlsx workbook:

> wdir = “C:/workspace/yourdirectory”
> data <- read.xlsx(paste(wdir, “yoursubdirectory”, “yourdata.xlsx”, sep=“/”), sheet = 2)

 
0
Kudos
 
0
Kudos

Now read this

How to convert a Unix timestamp to POSIXct in R (i.e. 1532289300 = 2018-07-22 19:55:00)

If you are converting a column of Unix timestamps in a dataframe: > df$Your.Times <- as.POSIXct(df$Your.Times, origin = “1970-1-1”) [1] [POSIXct datetimes] … or … If you are converting a single Unix timestamp: > yourtime =... Continue →