[R] data.frame() creates list?
> d <- data.frame(name=c("李明", "张聪", "王建"), age=c(30, 35, 28), height=c(180, 162, 175))
> typeof(d)
[1] "list"
> n = c(2, 3, 5)
> s = c("aa", "bb", "cc")
> b = c(TRUE, FALSE, TRUE)
> df = data.frame(n, s, b)
> typeof(df)
[1] "list"
df <- data.frame(a=1:2, b=letters[1:2]);
> str(df)
'data.frame': 2 obs. of 2 variables:
$ a: int 1 2
$ b: Factor w/ 2 levels "a","b": 1 2
> class(df);
[1] "data.frame"
> mode(df);
[1] "list"
> typeof(df);
[1] "list"
PS:其实,data.frame是一个把class属性设置成"data.frame"的list