我使用3个参数创建了用户定义的函数。当调用函数,如果我碰巧硬编码值,其中被注释掉一切正常,但如果我试图利用我收到以下错误参数行表示:将参数传递给用户定义的函数
Warning message:
In `[<-.data.frame`(`*tmp*`, data$X == "Key1", , value = list(X = integer(0), :
provided 17 variables to replace 16 variables
数据帧的数据包含16列!!!使用
代码:
Change <- function('Arc', Value, 'Key1'){
data<-read.csv("matrix.csv")
#This statement works but the below does not ......
#data[data$'X'=='C1',]$'OGB_OGB' <-(data[data$'X'=='C1',]$'OGB_OGB'/Value)
data[data$'X'=="Key1",]$"Arc" <-data[data$'X'=="Key1",]$"Arc"/Value
return(data)
}
tes<-Change("OGB_OGB",.3,"C1")
我猜我的地方我搞乱了的弦parameters..please帮助
我很su珍惜你的函数定义没有返回一个错误沿变化< - 函数中的意外字符串常量('Arc'' – mnel