[R] Error with write.table

Peter Ehlers ehlers at ucalgary.ca
Wed Feb 3 06:53:47 CET 2010


jlwoodard wrote:
> I was trying to save a data frame to an excel file using the following
> command:
> 
> write.table(myData, file="myData.csv",sep=",", row.names=F)
> 
> The command works for some data frames, but for other data frames, I get the
> following error:
> 
> Error in if (inherits(X[[j]], "data.frame") && ncol(xj) > 1L) X[[j]] <-
> as.matrix(X[[j]]) : 
>   missing value where TRUE/FALSE needed
> 
> 
> Is there something I'm doing wrong in trying to save the data frame to a
> .csv file?  

Probably.
What packages are attached?
Are you sure myData is always a dataframe? Use class(myData)
before the write.* call.
Use write.csv() (this won't fix the 'problem').

  -Peter Ehlers

> Many thanks in advance! 
> 
> John Woodard
> 

-- 
Peter Ehlers
University of Calgary



More information about the R-help mailing list