嗨我在R.传递参数时,我传递了字符串值,我收到了以下错误。
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
In addition: Warning message:
In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'addresstest.txt'
这是我的代码
input <- function(CITY,ADDRESS)
{
delhi <- read.delim("addresstest.txt", na.strings = "")
delhi$lnprice <- log(delhi$PRIMARY_PRICE) # creating log price variable
uidel = lm (lnprice ~ CITY+AREA_SQFT+BEDS+BATHS+ADDRESS,data = delhi)
model <- predict (uidel,data.frame(CITY=CITY,ADDRESS=ADDRESS), na.rm = TRUE)
model
}
通过
传递值input(CITY=NCR,ADDRESS=Sector78)
任何帮助将不胜感激。