10

I am new to R and trying to read a csv. The documentation shows a function read.csv(). However, when I read the file and check the type of the variable it shows a list. Documentation shows it as a data.frame. Can someone explain why it happens that way?

My code so far:

mytable<-read.csv(InputFile,header=TRUE,stringsAsFactors=FALSE)
dim(mytable)
typeof(mytable)

Output:

dim(mytable)
[1] 500  20

typeof(mytable)
[1] "list"
MLavoie
  • 9,671
  • 41
  • 36
  • 56
AMisra
  • 1,869
  • 2
  • 25
  • 45

1 Answers1

2

As it is explained in the answer https://stackoverflow.com/a/6258536/8900683. In R every "object" has a mode and a class. The former represents how an object is stored in memory (numeric, character, list and function) while the later represents its abstract type.

For example:

d <- data.frame(V1=c(1,2))
class(d)
# [1] "data.frame"
mode(d)
# [1] "list"
typeof(d)
# list
Rene B.
  • 6,557
  • 7
  • 46
  • 72