Changing Character data in csv file to factors__stringsasFactors !!!NOt Worky!

here is the code that works:
BankCustomer <- read.csv("Demo 1_ Identifying Data Structures.csv")

View(BankCustomer)
str(BankCustomer)
'data.frame': 4521 obs. of 15 variables:
ï..age : int 30 33 35 30 59 35 36 39 41 43 ... job : chr "unemployed" "services" "management" "management" ...
marital : chr "married" "married" "single" "married" ... education: chr "primary" "secondary" "tertiary" "tertiary" ...
default : chr "no" "no" "no" "no" ... housing : chr "no" "yes" "yes" "yes" ...
loan : chr "no" "yes" "no" "yes" ... contact : chr "cellular" "cellular" "cellular" "unknown" ...
month : chr "oct" "may" "apr" "jun" ... day : int 19 11 16 3 5 23 14 6 14 17 ...
duration : int 79 220 185 199 226 141 341 151 57 313 ... campaign : int 1 1 1 4 1 2 1 2 2 1 ...
pdays : int -1 339 330 -1 -1 176 330 -1 -1 147 ... previous : int 0 4 1 0 0 3 2 0 0 2 ...
$ poutcome : chr "unknown" "failure" "failure" "unknown" ...

Here is what doesn't work for some unknown reason:

BankCustomer <- read.csv("Demo 1_ Identifying Data Structures.csv", stringsasFactors = TRUE)
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
unused argument (stringsasFactors = TRUE)

Please ask a reprex when asking a question in this community.
Now we have to guess which version of read.csv you are using.

If it is utils::read.csvthen you can check the documentation by typing:

? read.csv

There you see that the ... arguments (i.e. all that are not explicitly mentioned under read.csv) are passed to the read.table function. Looking there, we see that there is no argument stringsasFactors .
However the argument stringsAsFactorsexists. In R variable names are case sensitive.

Roger! Reprex installed!

Objective achieved by stringsAsFacvtors=TRUE

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.