我在数据框中有一些列需要进行对数转换。
我使用以下代码执行此操作:
$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))
由于