Hi David

Please keep the r-help list on when you reply, I’m not your personal 
consultant and David Winsemius would also like see how this progress since he 
is also trying to help you.

I’m still guessing, so is this what you want

For (i in c(1,5,8)){

} ????

Please, if you hope to get some qualified help, then provide a small example 
using part of your data.


Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
fr...@vestas.com<mailto:fr...@vestas.com>
http://www.vestas.com<http://www.vestas.com/>

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice<http://www.vestas.com/legal/notice>
If you have received this e-mail in error please contact the sender.

From: David Gwenzi [mailto:dgwe...@gmail.com]
Sent: 15. maj 2014 07:43
To: Frede Aakmann Tøgersen
Subject: Re: [R] for loop using index values

Hi Frede,

Thanks for your reple. I guess I am not making my question very clear. Sorry 
about that. Let me re-phrase it this way

Suppose I have subSets 1,2,3,4,5,6,7,8,9 and I want to process them all I would 
use
for (i in 1:9){
..................
}
No problem!!

Now I want to process only subSets 1,5,8

How should I set up the for loop?

btw I am using capital S for set in subset so I avoid the problem of the 
inbuilt function

Thanks,

David Gwenzi
Graduate Degree Program in Ecology
Natural Resources Ecology Lab
Colorado State University

On Wed, May 14, 2014 at 11:27 PM, Frede Aakmann Tøgersen 
<fr...@vestas.com<mailto:fr...@vestas.com>> wrote:
As David says it will be good to see how the structure of the list subset is. 
Now I'm going to guess that the i'th element of subset is a dataframe since you 
are using nrow(subset[[i]]).

Now you're doing

select<-which(nrow(subset[[i]])>=100) ## added a missing closing )

so now select holds the number of rows of subset[[i]] only.

Perhaps it should be something like

select <- which(lapply(subset, nrow) >= 100).

Using some dummy data:

> tmp <- 
> list(matrix(0,2,3),matrix(0,9,3),matrix(0,8,3),matrix(0,3,3),matrix(0,6,3))
> which((lapply(tmp, nrow) > 6))
[1] 2 3


By the way there is a function called subset so you could run into trouble 
later on when calling your list for subset.

Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
fr...@vestas.com<mailto:fr...@vestas.com>
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice<http://www.vestas.com/legal/notice>
If you have received this e-mail in error please contact the sender.


> -----Original Message-----
> From: r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org> 
> [mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>]
> On Behalf Of David Winsemius
> Sent: 15. maj 2014 06:49
> To: David Gwenzi
> Cc: r-help@r-project.org<mailto:r-help@r-project.org>
> Subject: Re: [R] for loop using index values
>
>
> 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
>
> ______________________________________________
> R-help@r-project.org<mailto: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.


        [[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.

Reply via email to