Assuming I have dataframe ³test² with dim = (2,10) say; And that I can choose some of the data; Test[1,2:6] How do I turn this data into a list [which I would like to run a function across]. Tried as.list but doesn¹t look or feel right. Thanks in advance, it is simple I am sure so apologies for not being a interesting problem ! Glenn [[alternative HTML version deleted]]
On Tue, Dec 30, 2008 at 11:57 AM, glenn <g1enn.roberts at btinternet.com> wrote:> Assuming I have dataframe ?test? with dim = (2,10) say; > > And that I can choose some of the data; > > Test[1,2:6] > > How do I turn this data into a list [which I would like to run a function > across]. > Tried as.list but doesn?t look or feel right.Well, what DO you want it to look and feel like? A data frame is already a list.> test <- rbind.data.frame(1:10, 101:110) > is.data.frame(test)[1] TRUE> is.list(test)[1] TRUE> is.list(test[1,2:6])[1] TRUE How about some more information? Sarah -- Sarah Goslee http://www.functionaldiversity.org
not sure what you want either but reshape package may help, melt function. Sarah Goslee wrote:> On Tue, Dec 30, 2008 at 11:57 AM, glenn <g1enn.roberts at btinternet.com> wrote: >> Assuming I have dataframe ?test? with dim = (2,10) say; >> >> And that I can choose some of the data; >> >> Test[1,2:6] >> >> How do I turn this data into a list [which I would like to run a function >> across]. >> Tried as.list but doesn?t look or feel right. > Well, what DO you want it to look and feel like? A data frame is already a > list. >> test <- rbind.data.frame(1:10, 101:110) >> is.data.frame(test) > [1] TRUE >> is.list(test) > [1] TRUE >> is.list(test[1,2:6]) > [1] TRUE > How about some more information? > Sarah > -- > Sarah Goslee > http://www.functionaldiversity.org > ______________________________________________ > 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.Veja quais s?o os assuntos do momento no Yahoo! +Buscados http://br.maisbuscados.yahoo.com
I believe you are looking for: Test[1, 2:6, drop=TRUE] Patrick Burns patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") glenn wrote:> Assuming I have dataframe ?test? with dim = (2,10) say; > > And that I can choose some of the data; > > Test[1,2:6] > > How do I turn this data into a list [which I would like to run a function > across]. > Tried as.list but doesn?t look or feel right. > > Thanks in advance, it is simple I am sure so apologies for not being a > interesting problem ! > > Glenn > > [[alternative HTML version deleted]] > > > ------------------------------------------------------------------------ > > ______________________________________________ > 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. >