1

One similar question did have a similar type of issue but it looks like there were some typos involved and it wasn't using the right functions, it was unknown that it wasn't a data frame. Mine is being read in as a list from a table structured .csv file. I've also attempted the rbind option in do.call suggested in this question but that didn't work so it's commented out, it still showed up as a list under typeof().

Here's a public Google spreadsheet of the dataset and here's my reproduceable code:

# Read study file
getwd()
bank <- read.csv("attemptCSV.csv")
bank
typeof(bank)
bank <- data.frame(bank)
typeof(bank)
colnames(bank)
#do.call(rbind.data.frame, bank)
#typeof(bank)

#> typeof(bank)
#[1] "list"
#> bank <- data.frame(bank)
#> typeof(bank)
#[1] "list"
#> colnames(bank)
# [1] "age"       "job"       "marital"   "education" "default"   "balance"   "housing"   "loan"     
# [9] "contact"   "day"       "month"     "duration"  "campaign"  "pdays"     "previous"  #"poutcome" 
#[17] "y"         

1 Answers1

2

It should be class and not typeof because according to ?typeof

typeof determines the (R internal) type or storage mode of any object

class(bank)

-checking

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

The reason is also that data.frame is a list with elements (columns) of equal length

akrun
  • 874,273
  • 37
  • 540
  • 662
  • 2
    Oh oops haha, sorry about that, I guess since it's all in quotations for some reason the values are being read non-numerically so that threw me off. Thanks! –  Oct 20 '21 at 16:55