列上的log变换会在r中生成警告

时间:2017-02-26 15:00:53

标签: r dataframe data.table transformation

我在数据框中有一些列需要进行对数转换。

我使用以下代码执行此操作:

$sql = "SELECT * FROM news ORDER BY n_date DESC LIMIT 1";

我收到了很多警告:

cols = c("LotArea", "MasVnrArea", "LotFrontage", "BsmtFinSF2", "LowQualFinSF", 
         "BsmtHalfBath", "KitchenAbvGr", "OpenPorchSF",
         "EnclosedPorch", "MiscVal", "PoolArea", "3SsnPorch", "ScreenPorch")
train[, which(names(train) %in% cols)] <- log(train[, which(names(train) %in% cols)] + 1, 2)

还有:

Supplied 13 items to be assigned to 1455 items of column 'LotFrontage' (recycled leaving remainder of 12 items)

我对指定的每个列都有相同的警告,所有列都是Coerced 'double' RHS to 'integer' to match the column's type; may have truncated precision. Either change the target column to 'double' first (by creating a new 'double' vector length 1455 (nrows of entire table) and assign that; i.e. 'replace' column), or coerce RHS to 'integer' (e.g. 1L, NA_[real|integer]_, as.*, etc) to make your intent clear and for speed. Or, set the column type correctly up front when you create the table and stick to it, please

我做错了吗?

为了帮助重现,以下是int

的输出
dput(head(train))

由于

0 个答案:

没有答案