On Wed, 27 Feb 2002, christian schulz wrote:
Hi,
i get only one value, but expect ncol values - what's wrong ?
You only compute one value for y and then return it. The assignment to y
is outside the loop, but in any case it would overwrite the previous value
test <- function(){
for (i in 1:ncol(configData))
x <- subset(configData, Q71 == 1 & configData[,i] ==1 , select =
configData[,i])
y <- (dim(x)[1]/dim(configData)[1])*100
return(y) }
My guess is that you mean something like
test <- function(){
y<-numeric(ncol(configData))
for (i in 1:ncol(configData)){
x <- subset(configData, Q71 == 1 & configData[,i] ==1 , select = configData[,i])
y[i] <- (dim(x)[1]/dim(configData)[1])*100
}
return(y) }
-thomas
Thomas Lumley Asst. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle