It's still kind of weird; embedded 2-column data frames print differently than
1-column ones:
> d <- data.frame(a=1, b=I(data.frame(d=1,e=2)))
> d
a b.d b.e
1 1 1 2
> str(d)
'data.frame': 1 obs. of 2 variables:
$ a: num 1
$ b:Classes 'AsIs' and 'data.frame': 1 obs. of 2 variables:
В Wed, 25 Oct 2023 09:18:26 +0300
"Christian Asseburg" пишет:
> > str(x)
> 'data.frame': 1 obs. of 3 variables:
> $ A: num 1
> $ B: num 1
> $ C:'data.frame': 1 obs. of 1 variable:
> ..$ A: num 1
>
> Why does the print(x) not show "C" as the name of the third element?
Dear R users! Thank you for your excellent replies. I didn't know that the
print.data.frame expands matrix-like values in this way. Why doesn't it call
the column in my example C.A? I understand that something like that happens
when the data.frame in position three has multiple columns. But
tober 26, 2023 6:43 AM
To: Christian Asseburg ; r-help@r-project.org
Subject: Re: [R] Bug in print for data frames?
[External Email]
Às 07:18 de 25/10/2023, Christian Asseburg escreveu:
Hi! I came across this unexpected behaviour in R. First I thought it was a bug in
the assignment operator <- b
ect.org
Subject: Re: [R] Bug in print for data frames?
[External Email]
Às 07:18 de 25/10/2023, Christian Asseburg escreveu:
> Hi! I came across this unexpected behaviour in R. First I thought it was a
> bug in the assignment operator <- but now I think it's maybe a bug in the way
>
Às 07:18 de 25/10/2023, Christian Asseburg escreveu:
Hi! I came across this unexpected behaviour in R. First I thought it was a bug in
the assignment operator <- but now I think it's maybe a bug in the way data
frames are being printed. What do you think?
Using R 4.3.1:
x <- data.frame(A =
On 25/10/2023 2:18 a.m., Christian Asseburg wrote:
Hi! I came across this unexpected behaviour in R. First I thought it was a bug in
the assignment operator <- but now I think it's maybe a bug in the way data
frames are being printed. What do you think?
Using R 4.3.1:
x <- data.frame(A = 1,
I would say this is not an error, but I think what you wrote isn't
what you intended to do anyway.
y[1] is a data.frame which contains only the first column of y, which
you assign to x$C, so now x$C is a data.frame.
R allows data.frame to be plain vectors as well as matrices and
data.frames,
Hi! I came across this unexpected behaviour in R. First I thought it was a bug
in the assignment operator <- but now I think it's maybe a bug in the way data
frames are being printed. What do you think?
Using R 4.3.1:
> x <- data.frame(A = 1, B = 2, C = 3)
> y <- data.frame(A = 1)
> x
A B C
9 matches
Mail list logo