I iterate over a vector, for each element I look through something in the table named rowname and copy the return to another vector. For this
The following code is used:
gs1 = function(p) { output <- character()
All he spits out is a vector with numbers .... while all the other variables seem to contain the correct information (as checked by the print function) I feel like I'm doing something terribly wrong in filling out the output vector ... I could also use
output <- c(output,toappend)
But it gives me exactly the same, wrong and strange conclusion.
All help is much appreciated!
Output example
> gs1 = function(p) + { + output <- character() #empty vector to which results will be pasted + + for (i in 1:length(p)) { + test <- p[i] + index <- which(rownames(conditions) == test) + toappend <- conditions[index,3] #working + + output <- c(output,toappend) + output[i] <- toappend + print(paste(p[i],index,toappend,output[i],sep=",")) + } + return(output) + } > ########################### > test <- colnames(tri.data.1) > gs1(test) [1] "Row.names,,,NA" [1] "GSM235482,1,Glc A,5" [1] "GSM235484,2,Glc A,5" [1] "GSM235485,3,Glc A,5" [1] "GSM235487,4,Xyl A,21" [1] "GSM235489,5,Xyl A,21" [1] "GSM235491,6,Xyl A,21" [1] "GSM297399,7,pH 2.5,12" [1] "GSM297400,8,pH 2.5,12" [1] "GSM297401,9,pH 2.5,12" [1] "GSM297402,10,pH 4.5,13" [1] "GSM297403,11,pH 4.5,13" [1] "GSM297404,12,pH 4.5,13" [1] "GSM297563,13,pH 6.0,14" [1] "GSM297564,14,pH 6.0,14" [1] "GSM297565,15,pH 6.0,14" [1] "5" "5" "5" "5" "21" "21" "21" "12" "12" "12" "13" "13" "13" "14" "14" "14"