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"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With