[Rd] write.csv problems

Spencer Graves @pencer@gr@ve@ @end|ng |rom prod@y@e@com
Fri Jun 28 18:02:12 CEST 2024


Hello, All:


	  I'm getting strange errors with write.csv with some objects of class 
c('findFn', 'data.frame'). Consider the following:


df1 <- data.frame(x=1)
class(df1) <- c('findFn', 'data.frame')
write.csv(df1, 'df1.csv')
# Error in x$Package : $ operator is invalid for atomic vectors

df2 <- data.frame(a=letters[1:2],
       b=as.POSIXct('2024-06-28'))
class(df2) <- c('findFn', 'data.frame')
write.csv(df2, 'df1.csv')
# Error in tapply(rep(1, nrow(x)), xP, length) :
#  arguments must have same length


	  "write.csv" works with some objects of class c('findFn', 
'data.frame') but not others. I have 'findFn' object with 5264 rows that 
fails with the following error:


Error in `[<-.data.frame`(`*tmp*`, needconv, value = list(Count = 
c("83",  :
   replacement element 1 has 526 rows, need 5264


	  I have NOT yet been able to reproduce this error with a smaller 
example. However, starting 'write.csv' with something like the following 
should fix all these problems:


if(is.data.frame(x)) class(x) <- 'data.frame'


	  Comments?
	  Thanks for all your work to help improve the quality of statistical 
software available to the world.


	  Spencer Graves



More information about the R-devel mailing list