Hi everyone I need to make a work for school in R and one of my questions is to create 225 datasets of 100 observations and they need to be t_225 distributed. So, I know how to make one dataset (rt(100,df=225)), but how can I store those 225 in one vector, array,.. ? -- View this message in context: http://r.789695.n4.nabble.com/Storing-datasets-tp4632874.html Sent from the R help mailing list archive at Nabble.com.
R. Michael Weylandt <michael.weylandt@gmail.com>
2012-Jun-09 11:36 UTC
[R] Storing datasets
Take a look at ?replicate. Michael On Jun 9, 2012, at 5:16 AM, Rody <rodric_seutin at hotmail.com> wrote:> Hi everyone > > I need to make a work for school in R and one of my questions is to create > 225 datasets of 100 observations and they need to be t_225 distributed. So, > I know how to make one dataset (rt(100,df=225)), but how can I store those > 225 in one vector, array,.. ? > > -- > View this message in context: http://r.789695.n4.nabble.com/Storing-datasets-tp4632874.html > Sent from the R help mailing list archive at Nabble.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.
This does tend to look like homework, but... If you want them in one vector, then that vector will have length 225*100, of course. So rt(225*100,225) would do it. Or you could use the matrix() function to convert this to a matrix. See ?matrix. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/9/12 3:16 AM, "Rody" <rodric_seutin at hotmail.com> wrote:>Hi everyone > >I need to make a work for school in R and one of my questions is to create >225 datasets of 100 observations and they need to be t_225 distributed. >So, >I know how to make one dataset (rt(100,df=225)), but how can I store those >225 in one vector, array,.. ? > >-- >View this message in context: >http://r.789695.n4.nabble.com/Storing-datasets-tp4632874.html >Sent from the R help mailing list archive at Nabble.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.
I found a solution myself, but thanks for the answers. I solved it like this: D <- matrix(1:225*100,nrow=100,ncol=225) for(i in 1:225) D[,i] <- rt(100,df=225) end -- View this message in context: http://r.789695.n4.nabble.com/Storing-datasets-tp4632874p4633071.html Sent from the R help mailing list archive at Nabble.com.
On Tue, Jun 12, 2012 at 12:24 AM, Rody <rodric_seutin at hotmail.com> wrote:> I found a solution myself, but thanks for the answers. I solved it like this: > D <- matrix(1:225*100,nrow=100,ncol=225) > for(i in 1:225) > ? ? D[,i] <- rt(100,df=225) > endbut as Don said, you can do this in one step (and it is both faster and more elegant). D <- matrix(rt(100 * 225, df = 225), ncol = 225) Cheers, Josh> > > -- > View this message in context: http://r.789695.n4.nabble.com/Storing-datasets-tp4632874p4633071.html > Sent from the R help mailing list archive at Nabble.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.-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/