Re: [R] Subsetting data systematically

2011-06-24 Thread gibberish
Thanks!




From: Peter Alspach-2 [via R]
[mailto:ml-node+3618799-1094957657-247...@n4.nabble.com] 
Sent: Wednesday, June 22, 2011 9:27 PM
To: Bendik, Nathan
Subject: Re: Subsetting data systematically


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: [hidden email] [mailto:r-help-bounces@r- 
 project.org] On Behalf Of gibberish 
 Sent: Thursday, 23 June 2011 11:05 a.m. 
 To: [hidden email] 
 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. 
 
 __ 
 [hidden email] 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. 

__ 
[hidden email] 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. 





If you reply to this email, your message will be added to the
discussion below:

http://r.789695.n4.nabble.com/Subsetting-data-systematically-tp3618516p3
618799.html 
To unsubscribe from Subsetting data systematically, click here
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib
e_by_codenode=3618516code=bmF0aGFuLmJlbmRpa0BjaS5hdXN0aW4udHgudXN8MzYx
ODUxNnwyMDc3MzAzODgz . 



--
View this message in context: 
http://r.789695.n4.nabble.com/Subsetting-data-systematically-tp3618516p3623467.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@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.


[R] Subsetting data systematically

2011-06-22 Thread gibberish
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@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.


Re: [R] Subsetting data systematically

2011-06-22 Thread Peter Alspach
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-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of gibberish
 Sent: Thursday, 23 June 2011 11:05 a.m.
 To: r-help@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@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.

__
R-help@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.