I would like to subset data from a larger dataset and generate a smaller dataset. However, I don't want to use sample() because it does it randomly. I would like to take non-random subsamples, for example, every 2nd number, or every 3rd number. Is there a procedure that does this? Thanks, Nate -- View this message in context: http://r.789695.n4.nabble.com/Subsetting-data-systematically-tp3618516p3618516.html Sent from the R help mailing list archive at Nabble.com.
Subsetting data systematically
3 messages · Peter Alspach, gibberish
Tena koe Nate You can use the fact that R recycles. If yourData is a dataframe, then (as examples): yourData[c(TRUE,FALSE),] will give you every second row, starting with the first. Similarly, yourData[c(FALSE,TRUE,FALSE),] will give every third row, starting with the second; and yourData[c(TRUE, rep(FALSE,19)),] will give every twentieth row, starting with the first. There's also seq(). HTH .... Peter Alspach.
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of gibberish Sent: Thursday, 23 June 2011 11:05 a.m. To: r-help at r-project.org Subject: [R] Subsetting data systematically I would like to subset data from a larger dataset and generate a smaller dataset. However, I don't want to use sample() because it does it randomly. I would like to take non-random subsamples, for example, every 2nd number, or every 3rd number. Is there a procedure that does this? Thanks, Nate -- View this message in context: http://r.789695.n4.nabble.com/Subsetting- data-systematically-tp3618516p3618516.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.
The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited.
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110624/01950e6a/attachment.pl>