wrong replacement of values in function unfactor()

Create issue
Issue #2 resolved
Former user created an issue

R 3.4.2, varhandle 2.0.2

example:

df <- data.frame(postcode=c(rep("01234", 5), rep("09876", 5)), inhabitant=c(rep(30000, 5), rep(100000, 5)), stringsAsFactors=TRUE)
str(df)

'data.frame': 10 obs. of 2 variables: $ postcode : Factor w/ 2 levels "01234","09876": 1 1 1 1 1 2 2 2 2 2 $ inhabitant: num 30000 30000 30000 30000 30000 100000 100000 100000 100000 100000

unfactor(df)

Warning in [<-.data.frame(*tmp*, , factor_columns_indecies, value = list( : provided 10 variables to replace 1 variables

  • .. postcode inhabitant
  • 1 1234 30000
  • 2 1234 30000
  • 3 1234 30000
  • 4 1234 30000
  • 5 1234 30000
  • 6 1234 100000
  • 7 1234 100000
  • 8 1234 100000
  • 9 1234 100000
  • 10 1234 100000

All values in column postcode are replaced by only one value.

Comments (2)

  1. Log in to comment