我正在尝试创建一个组织我的数据的函数。我需要创建新列,将样本(即每行)分类为“重叠”,“非覆盖”或“更低”。但是,当它读取列创建代码时,我收到以下内容:
"Error in `$<-.data.frame`(`*tmp*`, "overlap", value = logical(0)) :
replacement has 0 rows, data has 1"
按照我的代码:
org <-function(bpoint){
bp <- data.frame(bpoint)
colnames(bp)<-gsub(x=colnames(bp)," ","_")
colnames(bp)<-gsub(x=colnames(bp),"(","",fixed=T)
colnames(bp)<-gsub(x=colnames(bp),")","",fixed=T)
bp$overlap <- (bp$"Low_Freq_Hz"<=2000&bp$"High_Freq_Hz">2000)
bp$non_over <- (bp$"Low_Freq_Hz">2000)
bp$lower <- (bp$"High_Freq_Hz"<=2000)
bp$time <- 'before'
}
我认为这一定是个傻瓜错误,但我在其他相关问题中找不到任何有用的解决方案......为什么我不能创建这个列,我该如何解决呢?
谢谢,