Deloitte Interview Questions | What is the use of stringAsFactors set as False?
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 2 )
StringAsFactors is a argument in the read.csv(), read.table() etc functions.
It indicates whether strings in a data frame should be treated as factor variables or as just plain strings.
So, when it is set to False, the strings in a DataFrame will be set as strings and not factors.
The default argument is set to TRUE which is necessary when using linear models like
lm() and glm() as categorical variables need to be represented as features.
The argument ‘stringsAsFactors’ is an argument to the ‘data.frame()’ function in R. It is a logical that indicates whether strings in a data frame should be treated as factor variables or as just plain strings. The argument also appears in ‘read.table()’ and related functions because of the role these functions play in reading in table data and converting them to data frames. By default, ‘stringsAsFactors’ is set to TRUE.