user2879978
user2879978

Reputation: 1

col() in R gives warning message

on 6-month-old iMac with OSX v. 10.8.5 using R v 2.15.2 (2012-10-26) with either RStudio or Terminal this simple code:

m <- matrix(c(1,2,3,4),2)

yields the expected 2x2 matrix and row(m) yields the expected 2x2 matrix with row 1s in the first row and 2s in the second.

But col(m) gave the following error:
Warning message: In seq. int(0, 1, length.out = n): first element used of 'length.out' argument.

Curiously, the same code on a 5-year-old MacBook Air, OSX 10.6.8, but the same version of R gave the expected result for col(m) of 1's in the first col and 2s in the second.

Any suggestions?

Upvotes: 0

Views: 3234

Answers (1)

Rob Hall
Rob Hall

Reputation: 1418

As stated by other posters, this works on a current version of R. Some suggestions to figure out why it produces a warning for you:

  • Check that you do not have a custom function called "col" in your workspace. Try rm(col) to remove.
  • Check if the following works

        .Internal(col(c(2L, 2L)))
    

    If this does not work, I would suspect that you have a strange R build and would suggest re-downloading from CRAN.

  • If the internal command works, use debug() to find out what is happening.

Upvotes: 2

Related Questions