Mark Heckmann
2010-Jan-06 14:07 UTC
[R] plyr: issue with column names when converting one element list to dataframe
Hi, I have an issue concerning plyr. I have a list l as output from dlply. > l $`1` (0.5,1.5] (1.5,2.5] (2.5,3.5] (3.5,4.5] f5_9 0.2342569 0.465995 0.2518892 0.04785894 attr(,"split_type") [1] "data.frame" attr(,"split_labels") f15 1 1 When I convert it into a dataframe I get. > list_to_dataframe(l) .id X.0.5.1.5. X.1.5.2.5. X.2.5.3.5. X.3.5.4.5. 1 1 0.2342569 0.465995 0.2518892 0.04785894 The column labels have names I do not want. When I do the same using two list elements everything is fine, that is column names are as desired. > l2 <- c(l,l) > list_to_dataframe(l2) .id (0.5,1.5] (1.5,2.5] (2.5,3.5] (3.5,4.5] 1 1 0.2342569 0.465995 0.2518892 0.04785894 2 1 0.2342569 0.465995 0.2518892 0.04785894 Does someone know a remedy? TIA, Mark> Mark Heckmann > Dipl. Wirt.-Ing. cand. Psych. > Vorstra?e 93 B01 > 28359 Bremen > Blog: www.markheckmann.de > R-Blog: http://ryouready.wordpress.com
hadley wickham
2010-Jan-06 14:48 UTC
[R] plyr: issue with column names when converting one element list to dataframe
Hi Mark, Could you send a the results of dput(l)? It will make exploration easier. Hadley On Wed, Jan 6, 2010 at 8:07 AM, Mark Heckmann <mark.heckmann at gmx.de> wrote:> > Hi, > > I have an issue concerning plyr. > I have a list l as output from dlply. > >> l > $`1` > ? ? (0.5,1.5] (1.5,2.5] (2.5,3.5] ?(3.5,4.5] > f5_9 0.2342569 ?0.465995 0.2518892 0.04785894 > > attr(,"split_type") > [1] "data.frame" > attr(,"split_labels") > ?f15 > 1 ? 1 > > When I convert it into a dataframe I get. > >> list_to_dataframe(l) > ?.id X.0.5.1.5. X.1.5.2.5. X.2.5.3.5. X.3.5.4.5. > 1 ? 1 ?0.2342569 ? 0.465995 ?0.2518892 0.04785894 > > The column labels have names I do not want. > When I do the same using two list elements everything is fine, that is > column names are as desired. > >> l2 <- c(l,l) >> list_to_dataframe(l2) > ?.id (0.5,1.5] (1.5,2.5] (2.5,3.5] ?(3.5,4.5] > 1 ? 1 0.2342569 ?0.465995 0.2518892 0.04785894 > 2 ? 1 0.2342569 ?0.465995 0.2518892 0.04785894 > > Does someone know a remedy? > > TIA, > Mark > > >> Mark Heckmann >> Dipl. Wirt.-Ing. cand. Psych. >> Vorstra?e 93 B01 >> 28359 Bremen >> Blog: www.markheckmann.de >> R-Blog: http://ryouready.wordpress.com > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- http://had.co.nz/
Mark Heckmann
2010-Jan-06 14:53 UTC
[R] plyr: issue with column names when converting one element list to dataframe
Hadley, thanks for the quick reply: > dput(l) list(structure(c(0.182198327359618, 0.473715651135006, 0.29689366786141, 0.0471923536439665), .Dim = c(1L, 4L), .Dimnames = list("f5_9", c("(0.5,1.5]", "(1.5,2.5]", "(2.5,3.5]", "(3.5,4.5]")))) Mark Am 06.01.2010 um 15:48 schrieb hadley wickham:> Hi Mark, > > Could you send a the results of dput(l)? It will make exploration > easier. > > Hadley > > On Wed, Jan 6, 2010 at 8:07 AM, Mark Heckmann <mark.heckmann at gmx.de> > wrote: >> >> Hi, >> >> I have an issue concerning plyr. >> I have a list l as output from dlply. >> >>> l >> $`1` >> (0.5,1.5] (1.5,2.5] (2.5,3.5] (3.5,4.5] >> f5_9 0.2342569 0.465995 0.2518892 0.04785894 >> >> attr(,"split_type") >> [1] "data.frame" >> attr(,"split_labels") >> f15 >> 1 1 >> >> When I convert it into a dataframe I get. >> >>> list_to_dataframe(l) >> .id X.0.5.1.5. X.1.5.2.5. X.2.5.3.5. X.3.5.4.5. >> 1 1 0.2342569 0.465995 0.2518892 0.04785894 >> >> The column labels have names I do not want. >> When I do the same using two list elements everything is fine, that >> is >> column names are as desired. >> >>> l2 <- c(l,l) >>> list_to_dataframe(l2) >> .id (0.5,1.5] (1.5,2.5] (2.5,3.5] (3.5,4.5] >> 1 1 0.2342569 0.465995 0.2518892 0.04785894 >> 2 1 0.2342569 0.465995 0.2518892 0.04785894 >> >> Does someone know a remedy? >> >> TIA, >> Mark >> >> >>> Mark Heckmann >>> Dipl. Wirt.-Ing. cand. Psych. >>> Vorstra?e 93 B01 >>> 28359 Bremen >>> Blog: www.markheckmann.de >>> R-Blog: http://ryouready.wordpress.com >> >> ______________________________________________ >> R-help at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > > -- > http://had.co.nz/