[Rd] xtabs to dataframe fails (PR#3754)
daniel.frey at switzerland.org
daniel.frey at switzerland.org
Sat Aug 16 01:40:45 MEST 2003
Full_Name: Daniel Frey
Version: 1.7.1
OS: Windows 2000
Submission from: (NULL) (80.254.164.242)
Generating a data frame out of a xtabs result acts unusual. Take the following
sample to reproduce it:
> a.a <- c("a","a","a","b","b")
> a.b <- c("c","c","d","e","f")
> a.df <- data.frame(list("A"=a.a,"B"=a.b))
> a.x <- xtabs(~A+B,a.df)
> a.x
B
A c d e f
a 2 1 0 0
b 0 0 1 1
> data.frame(a.x)
A B Freq
1 a c 2
2 b c 0
3 a d 1
4 b d 0
5 a e 0
6 b e 1
7 a f 0
8 b f 1
I would expect something like a.x itself. Instead I have to give the exact
bounds, otherwise it doesn't convert properly:
> data.frame(a.x[1:2,1:4])
c d e f
a 2 1 0 0
b 0 0 1 1
I consider this a bug, as consistency of the handling breaks here.
Daniel Frey
More information about the R-devel
mailing list