Dear all,
I am running a function "results", which is basically al loop over 10000 genes and it fetches the results of two parameter (coefficient and z value) for each gene.
I then combine all results for all genes with allResults <- do.call(rbind, results).
Now my issue is that I would like to keep the gene name as well (not only the coefficient and zvalue).
I am not quite sure how to fix this.
This is the complete code (currently set to 5 genes):
#suprised that your code whose lappy ends with a names statement
# doesnt give you just the names in its output
(results <-lapply(1:4, function(i){
coeff <- c(1,i)
names(coeff) <- letters[c(1,i+1)]
# coeff
}))
do.call(rbind,results)
# has a different problem because the names differ between
# iteration to iteration
(results <-lapply(1:4, function(i){
coeff <- c(1,i)
names(coeff) <- letters[c(1,i+1)]
coeff
}))
# just has the column names of the first iteration
do.call(rbind,results)
# transpose and dataframe our results
(results <-lapply(1:4, function(i){
coeff <- c(1,i)
names(coeff) <- letters[c(1,i+1)]
as.data.frame(t(coeff))
}))
#instead of rbind
do.call(dplyr::bind_rows,results)