仅将log2转换应用于data.frame的数字列 [英] Apply log2 transformation only to numeric columns of a data.frame
本文介绍了仅将log2转换应用于data.frame的数字列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在我的数据集上运行 log2
转换,但我不断收到一条错误消息,提示数据框中的非数字变量。我的数据具有 row.names = 1
和 header = TRUE
,属于数据类。 frame()
I am trying to run a log2
transformation on my data set but I keep getting an error that says "non-numeric variable(s) in data frame". My data has row.names = 1
and header = TRUE
and is of class data.frame()
我尝试添加 lappy(na.strings)
,但这确实无法解决问题
I tried adding lappy(na.strings)
but this does not fix the problem
Shared_DEGs <- cbind(UT.Degs_heatmap[2:11], MT.Degs_heatmap[2:11], HT.Degs_heatmap[2:11])
Shared_DEGs1 <- `row.names<-`(Shared_DEGs, (UT.Degs_heatmap[,1]))
MyData.INF.log2 <- log2(Shared_DEGs1)
数据应该被log2转换为输出
The data should be log2 transformed as an output
推荐答案
使用 base R
的 rapply $ c的另一种方法$ c>,请使用@ r2evans提供的数据。
Yet another way using base R
's rapply
, kindly using the data provided by @r2evans.
rapply(mydf, f = log2, classes = c("numeric", "integer"), how = "replace")
# num int chr lgl
#1 1.651496 2.321928 A TRUE
这篇关于仅将log2转换应用于data.frame的数字列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文