Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.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_R_Regression - Fatal编程技术网

R

R,r,regression,R,Regression,在R的逻辑回归过程中,我在拆分和子集数据时收到以下错误消息。我被困在“子集”步骤 库(caTools) 拆分您正在对列进行拆分。如果您阅读了帮助页面: 用法: sample.split( Y, SplitRatio = 2/3, group = NULL ) Arguments: Y: Vector of data labels. If there are only a few labels (as is expected) than relative ratio o

在R的逻辑回归过程中,我在拆分和子集数据时收到以下错误消息。我被困在“子集”步骤

库(caTools)

拆分您正在对列进行拆分。如果您阅读了帮助页面:

用法:

  sample.split( Y, SplitRatio = 2/3, group = NULL )
  Arguments:

   Y: Vector of data labels. If there are only a few labels (as is
      expected) than relative ratio of data in both subsets will be
      the same.
您提供的是整个数据帧,它以列表的形式读取。因此,如果您有一个因变量,例如
y
,它将是:

split <-sample.split(df1$y, SplitRatio = 0.5)
training <- df1[split,]
testing <- df1[!split,]

split永远不要把
的“TRUE”
和“FALSE”`放在引号里——这会使它们成为字符串,而不是逻辑值。这不一定是您的问题,但这是最佳实践。我会尝试
training=df1[split,]
testing=df1[!split,]
但可能会签出
head(split)
以确保它是真/假值,并将
length(split)
nrow(df1)进行比较
以确保尺寸正确。在这种情况下,删除引号并不能解决问题。split有9个值,TRUE或FALSE。我认为这是造成问题的原因。我在df1中有333030行,如错误消息所示。同时,我应该使用什么分割比率?谢谢它起作用了!谢谢!
split <-sample.split(df1$y, SplitRatio = 0.5)
training <- df1[split,]
testing <- df1[!split,]
split <-sample.split(1:nrow(df1), SplitRatio = 0.5)
training <- df1[split,]
testing <- df1[!split,]