对比R中的错误

时间:2015-09-20 15:25:41

标签: r function dataframe

嗨我在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)

任何帮助将不胜感激。

0 个答案:

没有答案