|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Sample on dataframeHi
I'm looking for solution or function which I can use to sample data frame, to obtain new (smaller) data frame similar to sample() function Jarek Jasiewicz ______________________________________________ R-help@... 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. |
|
|
Re: Sample on dataframeI hope this helps
my.df<-read.table(stdin(), head=T, sep=" ") V5 V5.1 V5.2 V5.3 V5.4 V5.5 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 number.of.records<-5 my.df.subset<-my.df[sample(1:dim(my.df)[1], size=number.of.records, replace=F),] my.df.subset You can change "replace" by T if you allow repeat rows. Cheers, miltinho astronauta brazil On 7/23/08, Jarekj <jarekj@...> wrote: > > Hi > I'm looking for solution or function which I can use to sample data frame, > to obtain new (smaller) data frame similar to sample() function > Jarek Jasiewicz > > ______________________________________________ > R-help@... mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@... 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. |
|
|
Re: Sample on dataframeAll that is needed is
my.df[sample(nrow(my.df), size=<whatever>), ] On Wed, 23 Jul 2008, milton ruser wrote: > I hope this helps > > > > > my.df<-read.table(stdin(), head=T, sep=" ") > V5 V5.1 V5.2 V5.3 V5.4 V5.5 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > > number.of.records<-5 > my.df.subset<-my.df[sample(1:dim(my.df)[1], size=number.of.records, > replace=F),] > my.df.subset > You can change "replace" by T if you allow repeat rows. > > Cheers, > > miltinho astronauta > brazil > > > > > > On 7/23/08, Jarekj <jarekj@...> wrote: >> >> Hi >> I'm looking for solution or function which I can use to sample data frame, >> to obtain new (smaller) data frame similar to sample() function >> Jarek Jasiewicz >> >> ______________________________________________ >> R-help@... mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@... 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. > -- Brian D. Ripley, ripley@... Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@... 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. |
|
|
Re: Sample on dataframeyes, that is
thanks milton ruser pisze: > I hope this helps > > > > > my.df<-read.table(stdin(), head=T, sep=" ") > V5 V5.1 V5.2 V5.3 V5.4 V5.5 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > > number.of.records<-5 > my.df.subset<-my.df[sample(1:dim(my.df)[1], size=number.of.records, > replace=F),] > my.df.subset > > You can change "replace" by T if you allow repeat rows. > > Cheers, > > miltinho astronauta > brazil > > > > > > > On 7/23/08, *Jarekj* <jarekj@... <mailto:jarekj@...>> > wrote: > > Hi > I'm looking for solution or function which I can use to sample > data frame, to obtain new (smaller) data frame similar to sample() > function > Jarek Jasiewicz > > ______________________________________________ > R-help@... <mailto:R-help@...> mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > <http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ R-help@... 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. |
| Free Forum Powered by Nabble | Forum Help |