Re: [R] subset function within a function

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Thu, 03 Jul 2008 18:27:59 -0300

I think that you can use split fot this,

see ?split

On Thu, Jul 3, 2008 at 6:25 PM, Lana Schaffer <schaffer_at_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_at_scripps.edu
>
> ______________________________________________
> 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.
>

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

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

Received on Thu 03 Jul 2008 - 21:33:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Jul 2008 - 22:31:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive