, results) wont keep rownames

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 <-, 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):

results <- lapply(1:5, function(i){
  expr<-as.vector(predicted_gene[,i] )
  resi <- multinom(tgroup2 ~ sex + age + Site_Category+ expr, data = pheno)
allResults <-, results)

The result is only this:

I would like it to have the gene name instead of 1-5 in the first column.

Thank you for any hint!

Could you make a reprex ? its hard to follow.

#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

# 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)]
# just has the column names of the first iteration,results)

# transpose and dataframe our results
(results <-lapply(1:4, function(i){
  coeff <- c(1,i)
  names(coeff) <- letters[c(1,i+1)]

#instead of rbind,results)
1 Like

Does the res1 object contain the gene names?

Thank you I figured it out.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.