Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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
R中的Bucketing数据给出错误_R - Fatal编程技术网

R中的Bucketing数据给出错误

R中的Bucketing数据给出错误,r,R,我正试图将我的数据分为不同的类别,并在这样做的同时面临一个问题。我不知道哪里出了问题。请帮忙 new_df<-original_df new_df$bucket_column<-cut( as.numeric( new_df$value_for_bucket_column), breaks=c(0,1,2,3,4,5,6,7,14,21,28,60,90,180,365,Inf),

我正试图将我的数据分为不同的类别,并在这样做的同时面临一个问题。我不知道哪里出了问题。请帮忙

new_df<-original_df
new_df$bucket_column<-cut(
                as.numeric(
                  new_df$value_for_bucket_column),
                breaks=c(0,1,2,3,4,5,6,7,14,21,28,60,90,180,365,Inf),
                labels = c("1 Day","1-2 Days","2-3 Days","3- Days",
                "4-5 Days","5-6 Days", "1 Week",
                "1-2 Weeks","2-3 Weeks","3-4 Weeks",
                "1-2 Months","2-3 Months","3-6 Months",
                "6-12 Months","More than a Year"))

new\u df您需要提供更多信息,但是您的
cut(…)
可能返回零长度向量。
as.numeric(新的\u-df$value\u用于\u-bucket\u列)
确实是有效的24783长度数字向量吗?如果我删除as.numeric函数,而只为\u-bucket\u列提供新的\u-df$value\u,那么它将成功完成。但是,当我尝试使用table(new_df$bucket_column)将输出列转换为列,然后尝试查看值时,它会显示区段0>的table。您能否显示
str(new_df$value_for_bucket_column)
的输出或重现问题的示例数据?请提供一个可重复的示例。
Error in `$<-.data.frame`(`*tmp*`, "bucket_column", value = integer(0)) : 
  replacement has 0 rows, data has 24783