problem with as.table (PR#8652)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

problem with as.table (PR#8652)

I.J.Wilson
# Your mailer is set to "none" (default on Windows),
# hence we cannot send the bug report directly from R.
# Please copy the bug report (after finishing it) to
# your favorite email program and send it to
#
#       [hidden email]
#
######################################################


There is a problem with as.table converting from a matrix with
more than 26 rows (or columns) .

rows past 26 are set to <NA>.  This makes operations such as
turning the data back into a data.frame difficult.

example causing problems:

b <-  as.table(matrix(1:60,ncol=2))
as.integer(as.data.frame(b)[,1])

Ian Wilson


--please do not edit the information below--

Version:
 platform = i686-redhat-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status =
 major = 2
 minor = 2.1
 year = 2005
 month = 12
 day = 20
 svn rev = 36812
 language = R

Locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C

Search Path:
 .GlobalEnv, package:onelocus, package:methods, package:stats,
package:graphics, package:grDevices, package:utils, package:datasets,
Autoloads, package:base

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem with as.table (PR#8652)

Peter Dalgaard
[hidden email] writes:

> # Your mailer is set to "none" (default on Windows),
> # hence we cannot send the bug report directly from R.
> # Please copy the bug report (after finishing it) to
> # your favorite email program and send it to
> #
> #       [hidden email]
> #
> ######################################################
>
>
> There is a problem with as.table converting from a matrix with
> more than 26 rows (or columns) .
>
> rows past 26 are set to <NA>.  This makes operations such as
> turning the data back into a data.frame difficult.
>
> example causing problems:
>
> b <-  as.table(matrix(1:60,ncol=2))
> as.integer(as.data.frame(b)[,1])

You can add dimnames to b or the original matrix for a workaround.

Probably the easiest fix is (in as.table.default) to replace

 LETTERS[seq(length = dim(x)[i])]

with

 make.unique(LETTERS[seq(from=0, length = dim(x)[i]) %% 26 + 1], sep="")

The effect would be like

> make.unique(LETTERS[(0:59)%%26+1], sep="")
 [1] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"  "K"  "L"  "M"  "N"  "O"
[16] "P"  "Q"  "R"  "S"  "T"  "U"  "V"  "W"  "X"  "Y"  "Z"  "A1" "B1" "C1" "D1"
[31] "E1" "F1" "G1" "H1" "I1" "J1" "K1" "L1" "M1" "N1" "O1" "P1" "Q1" "R1" "S1"
[46] "T1" "U1" "V1" "W1" "X1" "Y1" "Z1" "A2" "B2" "C2" "D2" "E2" "F2" "G2" "H2"

Users might prefer a different scheme, but wouldn't really deserve
it... (If they want otherwise, they can just set it themselves).



--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Loading...