Skip to content
Prev 395334 / 398502 Next

Bug in print for 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:
A B C
1 1 2 3
A B C
1 1 1 3
A B A
1 1 1 1
'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? I did mess up the data frame (and this was a mistake on my part), but finding the bug was harder because print(x) didn't show the C any longer.

Thanks. With best wishes -

. . . Christian