Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在dataframe中重新缩放列?_R_Plyr_Rescale - Fatal编程技术网

在dataframe中重新缩放列?

在dataframe中重新缩放列?,r,plyr,rescale,R,Plyr,Rescale,我有一个名为data的dataframe,我想将第四个字段中的值重新缩放到0-1000的范围,并将缩放值四舍五入到最接近的整数。我尝试使用ddply、圆形和重缩放: 有没有人能指出问题所在,或者找到一个更好的方法来完成我想做的事情?我觉得你把事情弄得太复杂了——我根本不明白你为什么需要ddply 我觉得你把事情弄得太复杂了——我完全不明白你为什么需要ddply scaled_data <- ddply(data, round(rescale(data[,4], to=c(0,1000),

我有一个名为data的dataframe,我想将第四个字段中的值重新缩放到0-1000的范围,并将缩放值四舍五入到最接近的整数。我尝试使用ddply、圆形和重缩放:


有没有人能指出问题所在,或者找到一个更好的方法来完成我想做的事情?

我觉得你把事情弄得太复杂了——我根本不明白你为什么需要ddply


我觉得你把事情弄得太复杂了——我完全不明白你为什么需要ddply

scaled_data <- ddply(data, round(rescale(data[,4], to=c(0,1000), from=range(data[,4], na.rm=TRUE)), 0)
Error in `[.data.frame`(envir, exprs) : undefined columns selected
dd[,4] <- round(ggplot2::rescale(dd[,4],to=c(0,1000))
dd <- transform(dd,fourth=rescale(fourth,to=c(0,1000)))