[BioC] the function subset inside a function

Lana Schaffer schaffer at scripps.edu
Fri Jul 4 01:02:19 CEST 2008

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 (which is
always 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]]) 

-----Original Message-----
From: Lana Schaffer 
Sent: Thursday, July 03, 2008 3:44 PM
To: 'bioconductor at stat.math.ethz.ch'
Subject: the function subset inside a function

I have successfully applied the subset function on a list.  However,
inside a function the subset did not work.  Has anyone else run into
this problem?

Lana Schaffer
The Scripps Research Institute
DNA Array Core Facility
La Jolla, CA 92037
(858) 784-2263
(858) 784-2994
schaffer at scripps.edu 

More information about the Bioconductor mailing list