[R] Different results when converting a matrix to a data.frame

G.Maubach at weinwolf.de G.Maubach at weinwolf.de
Wed Nov 16 16:20:38 CET 2016


Hi All,

I build an empty dataframe to fill it will values later. I did the 
following:

-- cut --
matrix(NA, 2, 2)
     [,1] [,2]
[1,]   NA   NA
[2,]   NA   NA
> data.frame(matrix(NA, 2, 2))
  X1 X2
1 NA NA
2 NA NA
> as.data.frame(matrix(NA, 2, 2))
  V1 V2
1 NA NA
2 NA NA
-- cut --

Why does data.frame deliver different results than as.data.frame with 
regard to the variable names (V instead of X)?

Kind regards

Georg

	[[alternative HTML version deleted]]



More information about the R-help mailing list