[R] Meaning of error message when exporting to MS Excel

dthomas dyfed.thomas at midlandshn.health.nz
Tue Mar 5 22:13:17 CET 2013


Hi,

I’m attempting to export data (split into multiple files from one large
dataset) from R to excel using the excel.link package. The code for export
is as follows:

for(i in practicesNN){
  #Create relevant data for input
  #Separate out all parts of data – PracticeName is removed from example
data for privacy reasons
 detailedH<-dataExport2[dataExport1$PracticeName == i &
dataExport1$RISK_LEVEL == 'High',]
  detailedM<-dataExport2[dataExport1$PracticeName == i &
dataExport1$RISK_LEVEL == 'Medium',]
  detailedL<-dataExport2[dataExport1$PracticeName == i &
dataExport1$RISK_LEVEL == 'Low',]
  print(paste(i,"2"))
   x<-paste(i,".xls",sep="")
   #Open excel template
  xl.workbook.open("Template.xls")
   #Create practice specific file
  xl.workbook.save(x)
 #Activate detailed High risk sheet
  xl.sheet.activate("High Risk detailed")
  #Update detailed High risk spreadsheet
  xlrc[a1]<-detailedH
  #Activate detailed Medium risk sheet
  xl.sheet.activate("Medium Risk detailed")
  #Update detailed Medium risk spreadsheet
  xlrc[a1]<-detailedM
  #Activate detailed Low risk sheet
  xl.sheet.activate("Low Risk detailed")
  #Update detailed Low risk spreadsheet
  xlrc[a1]<-detailedL
  #Save spreadsheet
  xl.workbook.save(x)
  #Close spreadsheet
  xl.workbook.close(x)   
    } 

I attached an example file of data of the first 8 rows of the first xls. The
columns of the spreadsheet are filled until it gets to column ‘HbA1c_mmol’
which produces the following error:

Error in apply(r.obj[, iter], 1, paste, collapse = "\t") : 
  dim(X) must have a positive length

I removed the offending column and the same occurs when column ‘BMI’ is
encountered. Having searched for similar error message I have been unable to
deduce the meaning of the error, particularly the ‘apply(r.obj[, iter], 1,
paste, collapse = "\t")’ part. Can anyone explain what the error message
means and how to resolve it?

Many thanks,
Dove ExampleData.csv
<http://r.789695.n4.nabble.com/file/n4660378/ExampleData.csv>  




--
View this message in context: http://r.789695.n4.nabble.com/Meaning-of-error-message-when-exporting-to-MS-Excel-tp4660378.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list