[R] cannot coerce class '"rle"' into a data.frame

Sam Steingold sds at gnu.org
Tue Oct 16 19:54:29 CEST 2012


why?

> rle
Run Length Encoding
  lengths: int [1:1650061] 2 2 8 2 4 5 6 3 26 46 ...
  values : chr [1:1650061] "4bbf9e94cbceb70c BG bg" "4fbbf2c67e0fb867 SK sk" ...
> as.data.frame(rle)
Error in as.data.frame.default(vertices.rle) : 
  cannot coerce class '"rle"' into a data.frame

it seems that

rle.df <- data.frame(values=rle$values,length=rle$length)

works and DTRT.

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://iris.org.il http://memri.org
http://www.PetitionOnline.com/tap12009/ http://camera.org
char*a="char*a=%c%s%c;main(){printf(a,34,a,34);}";main(){printf(a,34,a,34);}



More information about the R-help mailing list