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 identify the length of time between two dates in R

If you are finding the length of time (in hours) between two columns of dates in a dataframe: > df$yourLength <- round(int_length(interval( df$yourStartTime, df$yourEndTIme)) / 60 / 60, digits = 2) [1] [interval lengths] … or … If... Continue →