Skip to content
Prev 298811 / 398503 Next

list to dataframe conversion-testing for identical

Yes it does have something to do with the representation of floating point
numbers. Using cbind() forces the list to become a matrix and that forces
all of the data to become character strings since one of the list elements
is character:
chr [1:10, 1:3] "21.3709584471467" "19.4353018286039" ...
Then you convert that to a data.frame. The default in data.frame() is to
convert characters to factors so you get
'data.frame':   10 obs. of  3 variables:
 $ X1: Factor w/ 10 levels "19.4353018286039",..: 8 1 5 7 6 2 9 3 10 4
 $ X2: Factor w/ 2 levels "A","B": 1 2 1 2 1 2 1 2 1 2
 $ X3: Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5

With dat2 you used data.frame() so the numeric fields were not converted to
strings and then factors. Then you converted the dat1 factors back to
numeric. You would be fine with just
Or you can name the list elements and then convert
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352