For sure this is not a Mac OS X related problem. If the data frame is named BSE then your lm() calls need to say data = BSE, not data = bse.
How many factpr levels does company have? Besides all that, I would suggest you start with simpler uses of lm, and find out if they work. For example, try lm( CP ~ company, data=BSE) If that works, then start adding variables on the right hand side until you get one that causes errors. The message about a 'closure' suggests that you are somehow asking lm() to perform analyses on an R function instead of data in a data frame. That would be very strange, and I have trouble imagining how that could be. Are you sure all your data is numeric? Try lapply( BSE, class) str(BSE) -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 5/14/15, 5:07 AM, "samarvir singh" <samarvir1...@gmail.com> wrote: >I Have a data frame named BSE and CP is my independent variable >and here;s the error I get if I try to run an lm function >any idea whats wrong > >P.S - all my data is in numeric except company which is a factor. I have >2700 row and 450 variable > >P.P.S - I have no missing data, I have 0 in Empty field. > >> BSE_Reg <- lm(CP ~.-company, data = bse) >Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels > >> BSE_Reg <- lm(CP ~., data = bse) >Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : > contrasts can be applied only to factors with 2 or more levels >Error in as.character(tools:::httpdPort) : > cannot coerce type 'closure' to vector of type 'character' >Error in as.character(tools:::httpdPort) : > cannot coerce type 'closure' to vector of type 'character' >Error in as.character(tools:::httpdPort) : > cannot coerce type 'closure' to vector of type 'character' >Error in as.character(tools:::httpdPort) : > cannot coerce type 'closure' to vector of type 'character' > > > > > >> R.Version() >$platform >[1] "x86_64-apple-darwin13.4.0" > >$arch >[1] "x86_64" > >$os >[1] "darwin13.4.0" > >$system >[1] "x86_64, darwin13.4.0" > >$status >[1] "" > >$major >[1] "3" > >$minor >[1] "2.0" > >$year >[1] "2015" > >$month >[1] "04" > >$day >[1] "16" > >$`svn rev` >[1] "68180" > >$language >[1] "R" > >$version.string >[1] "R version 3.2.0 (2015-04-16)" > >$nickname >[1] "Full of Ingredients" > > [[alternative HTML version deleted]] > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.