I think that you can use split fot this,

see ?split

On Thu, Jul 3, 2008 at 6:25 PM, Lana Schaffer <schaffer@scripps.edu> wrote:

> Hi,
> I am using this subset statement and it works
> outside a function.
> LIS[[i]]<- lapply(LI, subset, select=cov[[i]])
> However, wrapped inside a function this statement
> produces the same values for every LIS[[1]] which
> is only the first subset of LI.
> Does anyone know why is not working correctly inside
> a function?
>
> ff = factor(covariate)
> nLev <- nlevels(ff)
> cov <- vector(mode="list",length=nLev)
> for (gp in 1:nLev) {
> cov[[gp]] <- covariate == levels(ff)[gp]  }
>
> LIS <- vector(mode="list",length=nLev)
> #if (SINGLE == T ) LIS[[1]] <- LI else {}
> for (i in 1:nLev)
> LIS[[i]]<- lapply(LI, subset, select=cov[[i]])
>
>
> Lana Schaffer
> Biostatistics/Informatics
> The Scripps Research Institute
> DNA Array Core Facility
> La Jolla, CA 92037
> (858) 784-2263
> (858) 784-2994
> schaffer@scripps.edu
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

