Skip to content

data frame component replacement: feature or bug? (PR#266)

1 message · Peter Dalgaard

#
Matthew Wiener <mcw@ln.nimh.nih.gov> writes:
Well, it is prototype-compatible. Splus 5.3 does likewise. A way out
is

t1<-data.frame(unclass(t1))

However, we do seem to have a bug in the area:
Error: dim<- length of dims do not match the length of object
X1 X2         X3         X4
1  1  2  0.6020524  1.1595935
2  1  2 -1.8212204 -0.2118746
3  1  2  1.5506706  0.0680275
4  1  2 -0.8872958  0.4709870

This boils down to the construction

dfr[1]<-list(X1=1)

which doesn't extend dfr$X1, whereas

dfr[c(1,2)]<-list(X1=3,X2=4)

does. Splus handles both cases.