1

I am following this tutorial. From which you can downloaded this data file (452 bytes only).

I explored the data structure of the data:

a busy cat

And then I tried to create the same type of data:

a busy cat

I have tried feeding in my own list but it didn't work the same way as the titanic.raw dataset. I Googled list and all of them look like my list but not like titanic.raw. They are both lists, I used is.list() to check.

Community
  • 1
  • 1
  • I'm not entirely sure what it is you're asking. Are you trying to create a data frame (which also shows typeof() as "list") – Matthew G. Jan 23 '14 at 04:13
  • oh, sorry, i am trying to produce the same kind of data like titanic.raw. titanic.raw is a list, so i tried creating my own list using list() but the end result is not the same as titanic.raw. – FailedMathematician Jan 23 '14 at 04:17

1 Answers1

1

This is a confusion that is centered around the distinction between typeof() and class() in R. What you have is a data.frame, but typeof() will show "list". Consider:

> tr <- data.frame(a=1:5, b=letters[1:5])
> typeof(tr)
[1] "list"
> is.list(tr)
[1] TRUE
> class(tr)
[1] "data.frame"
> is.data.frame(tr)
[1] TRUE
> head(tr)
  a b
1 1 a
2 2 b
3 3 c
4 4 d
5 5 e
> tl <- list(a=1:5, b=letters[1:5])
> tl
$a
[1] 1 2 3 4 5

$b
[1] "a" "b" "c" "d" "e"

> typeof(tl)
[1] "list"
> is.list(tl)
[1] TRUE
> class(tl)
[1] "list"
> is.data.frame(tl)
[1] FALSE

For more information about class, typeof, and mode (another related function), see this excellent SO thread: A comprehensive survey of the types of things in R. 'mode' and 'class' and 'typeof' are insufficient

Community
  • 1
  • 1
gung - Reinstate Monica
  • 11,583
  • 7
  • 60
  • 79