Reputation: 13
I've tried to research the answer and I've found something close to my error but not similar enough to help me. My code is as follows:
setwd("Directory")
require(XLConnect)
wb <- loadWorkbook("workbook.xlsx")
st = readWorksheet(wb, sheet = getSheets(wb))
summary(lm(X36~Temp.C., data=st))
Where X36 is a column within the Excel file.
The error I'm getting is:
"Error in summary(lm(X36 ~ Temp.C., data = st)) :
error in evaluating the argument 'object' in selecting a method for
function 'summary': Error in data.frame(Info = list(Trial.. = c("Purpose: ",
"Cure: ", "Cond: ", :
arguments imply differing number of rows: 12, 0, 7, 5, 10, 17, 3, 500, 25, 31, 8"
What I'm trying to do is create a data frame so I can run a lm
on different columns. I believe the problem might be there being different sheets of differing amounts of rows within them but I'm not sure.
Upvotes: 0
Views: 2715
Reputation: 872
Input the data into R as a csv file type and then you should be able to do what you want so much easier
data<-read.csv("workbook.csv")
this way you can treat your data like a matrix :)
Upvotes: 0
Reputation: 3158
Try one sheet at a time:
st <- readWorksheet(wb, sheet = "mtcars")
where mtcars is the name of a sheet in "wb" workbook.
or try:
st <- readTable(wb, sheet = "mtcars_sheet", table = "MtcarsTable")
if you know the sheet name and table name.
Upvotes: 2