简体   繁体   English

log2转换ff对象

[英]log2 transform ff objects

I would like to log2 transform all numeric values in a ff object from ff package. 我想log2转换ff包中的ff对象中的所有数值。

Using my df : 使用我的df

library(ff)
    df <- 'probeset_id sample1 sample2 sample3
            probe_1 1834.2 1743.4 1384
            probe_2 4711 4922 4650
            probe_3 4555 1387 4650.8
            probe_4 2588 1325 3258'
    df <- read.table(text=df, header=T)
    write.table(df, "del.txt", col.names=T, row.names=F, quote=F, sep="\t")
    df <- read.table.ffdf(file="del.txt", header=T)

I tried the below code but I got an error: 我尝试了以下代码,但出现错误:

df[, 2:length(df)] <- log(df[2:length(df)], 2)
Error in log(df[2:length(df)], 2) :
  non-numeric argument to mathematical function

There exist a way to apply this funtion to ff objects? 有一种方法可以将此功能应用于ff对象?

log(df[,2:length(df)],2)可以工作,但是sapply(df[,2:length(df)],log2)如果数据帧较大sapply(df[,2:length(df)],log2)可能会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM