Hi all
I have point data along a transect and I want to divide the transect into
small blocks of 10m length each. I have named the blocks as a list i.e
subset[[i]]. Now the issue is I want to process only those blocks that have
at least 100 data points and keep the original index values of those
subsets. How do I set the for loop. I have tried the following but it is
still processing everything
select<-which(nrow(subset[[i]])>=100
for (i in c(select)){
..............
}
Thank you in advance,
David Gwenzi
Graduate Degree Program in Ecology
Natural Resources Ecology Lab
Colorado State University
[[alternative HTML version deleted]]
On May 14, 2014, at 9:23 PM, David Gwenzi wrote:> Hi all > > I have point data along a transect and I want to divide the transect > into > small blocks of 10m length each. I have named the blocks as a list i.e > subset[[i]]. Now the issue is I want to process only those blocks > that have > at least 100 data points and keep the original index values of those > subsets. How do I set the for loop. I have tried the following but > it is > still processing everything > > select<-which(nrow(subset[[i]])>=100 > for (i in c(select)){ > .............. > } > Thank you in advance,So can you provide str( subset[[1]] )?> > David Gwenzi > Graduate Degree Program in Ecology > Natural Resources Ecology Lab > Colorado State University > > [[alternative HTML version deleted]]And this is a plain text mailing list as described in the Posting Guide. -- David Winsemius, MD Alameda, CA, USA
Hi,
Not sure I understand correctly.? May be this helps:
##If the blocks are created as a list
set.seed(475)
?lst1 <- setNames(lapply(1:10, function(i) {rowN <- sample(20,1)*15;
matrix(sample(40,10*rowN, replace=TRUE), nrow=rowN)}),1:10)
sapply(lst1,nrow)>100
?#?? 1???? 2???? 3???? 4???? 5???? 6???? 7???? 8???? 9??? 10
?#TRUE? TRUE? TRUE? TRUE? TRUE FALSE? TRUE FALSE? TRUE? TRUE
sapply(lst1[sapply(lst1,nrow)>100],mean)
##
lapply(lst1[sapply(lst1,nrow)>100],summary)
A.K.
On Thursday, May 15, 2014 12:26 AM, David Gwenzi <dgwenzi at gmail.com>
wrote:
Hi all
I have point data along a transect and I want to divide the transect into
small blocks of 10m length each. I have named the blocks as a list i.e
subset[[i]]. Now the issue is I want to process only those blocks that have
at least 100 data points and keep the original index values of those
subsets. How do I set the for loop. I have tried the following but it is
still processing everything
select<-which(nrow(subset[[i]])>=100
for (i in c(select)){
..............
}
Thank you in advance,
David Gwenzi
Graduate Degree Program in Ecology
Natural Resources Ecology Lab
Colorado State University
??? [[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.