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?

5

1 Answer

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.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest