Skip to content

Need help with lm function on MAC OS X. R version - 3.2.0

3 messages · MacQueen, Don, samarvir singh

#
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.
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
  contrasts can be applied only to factors with 2 or more levels
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'
$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"
1 day later
#
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)
#
Thanks a lot Don, I did the above mentioned. And yes one of my variable
field had some non numeric data. Because of large set of variables , when I
used str(BSE) , some result was omitted, so that's why it went un noticed.
Thank you
On Fri 15 May, 2015 11:21 pm MacQueen, Don <macqueen1 at llnl.gov> wrote: