我有一个data.frame,我正在按列对其进行归一化(将每个列除以给定的归一化因子),当我取消此操作(将每列乘以其归一化因子)时,有时我得到的值与原始(十进制差异)。
这应该不一样吗?有什么办法解决这个问题而无需四舍五入小数?
代码:
# Divide each column by its normalization factor
# Dim data.skcm 60483, 470. Length norm.factor 470
data.skcm.norm <- sweep(data.skcm, 2, norm.factor, "/")
i <- 3 # Select a random column to test if values are the same
# Multiply a column by its normalization factor
data.skcm.unormlized <- data.skcm.norm[,i] * dds.estimation$sizeFactor[i]
# Values that won't match after undoing the operation
fal <- which((data.skcm.unormlized == data.skcm[,i]) == FALSE)
# 6451 are FALSE out of 60483 for column 3
length(fal)
head(fal)
[1] 2 5 13 15 19 20
#Test differences
#Testing top 3 rows whose values are not identical
data.skcm.unormlized[2] - data.skcm[2,i]
[1] -1.776357e-15
data.skcm.unormlized[5] - data.skcm[5,i]
[1] -2.842171e-14
data.skcm.unormlized[13] - data.skcm[13,i]
[1] 2.273737e-13
#Testing type
# -- Just for first element
str(data.skcm.unormlized[2])
num 13
str(data.skcm[2,i])
num 13