Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-Forge #5016] [fread] 'stringsAsFactors = TRUE' has no effect #501

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@arunsrinivasan
Copy link
Member

Submitted by: Artem Klevtsov; Assigned to: Nobody; R-Forge link

fread's argument stringsAsFactors has no effect when set to TRUE.

file <- tempfile()
DF <- data.frame(A = 1:10, B = LETTERS[1:10])
sapply(DF, class)
#         A         B 
# "integer"  "factor" 
write.table(DF, file, sep = ";", row.names = FALSE)

# fread's stringsAsFactors has no effect
DT <- fread(file, sep = ";", stringsAsFactors = TRUE)
sapply(DT, class)
#           A           B 
#   "integer" "character" 

Here's the same file read using read.csv():

DF2 <- read.csv(file, sep = ";", stringsAsFactors = TRUE)
sapply(DF2, class)
#         A         B 
# "integer"  "factor" 

DF3 <- read.csv(file, sep = ";", stringsAsFactors = FALSE)
sapply(DF3, class)
#           A           B 
#  "integer" "character" 
unlink(file)

Here's the sessionInfo() output:

sessionInfo()
# R version 3.0.2 (2013-09-25)
# Platform: x86_64-unknown-linux-gnu (64-bit)
# 
# locale:
#  [1] LC_CTYPE=ru_RU.UTF-8       LC_NUMERIC=C               LC_TIME=ru_RU.UTF-8       
#  [4] LC_COLLATE=C               LC_MONETARY=ru_RU.UTF-8    LC_MESSAGES=ru_RU.UTF-8   
#  [7] LC_PAPER=ru_RU.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
# [10] LC_TELEPHONE=C             LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=C       

# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
# [1] data.table_1.8.11
# 
# loaded via a namespace (and not attached):
# [1] plyr_1.8       reshape2_1.2.2 stringr_0.6.2  tools_3.0.2 
@nr0cinu
Copy link

nr0cinu commented Feb 10, 2015

same here :(

@TheVinhLuong102
Copy link

Hi all, I have the same problem

@mplatzer
Copy link

same here

@DavidArenburg
Copy link
Member

Guys you can stop commenting- it is the same for everyone without exceptions.

@arunsrinivasan arunsrinivasan added this to the v1.9.6 milestone Jul 11, 2015
@arunsrinivasan arunsrinivasan self-assigned this Jul 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants