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

set triggers a strange warning when adding a NA to a factor column by reference #1234

Closed
DavidArenburg opened this issue Jul 20, 2015 · 0 comments
Assignees
Labels
Milestone

Comments

@DavidArenburg
Copy link
Member

library(data.table) ## v1.9.5+
data = data.frame(cats = rep(c('', ' ',  'meow'), 5))
set(data, i = grep("^$|^ $", data[[1]]), j = 1L, value = NA_integer_)
# Warning message:
#   In set(data, i = grep("^$|^ $", data[[j]]), j = 1L, value = NA_integer_) :
#   RHS contains -2147483648 which is outside the levels range ([1,3]) of column 1, NAs generated

While base R handles it correctly

data = data.frame(cats = rep(c('', ' ',  'meow'), 5))
indx <- grep("^$|^ $", data$cats)
data$cats[indx] <- NA_integer_

Related to this SO answer

@arunsrinivasan arunsrinivasan self-assigned this Aug 25, 2015
@arunsrinivasan arunsrinivasan added this to the v1.9.6 milestone Aug 25, 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

2 participants