0
datac$rank <- mapvalues(data$rank, from = c(1,2,3,4),
                      to= c(4,3,2,1), warn_missing = TRUE)

Error in data$rank : object of type 'closure' is not subsettable

akrun
  • 874,273
  • 37
  • 540
  • 662
Anu
  • 11
  • 2
  • (FYI: "closure" in this context is just a "function with an enclosing environment/namespace". So if it had said `object of type 'function' is not subsettable`, would it make any more sense?) – r2evans Jun 04 '20 at 22:16
  • I want to replace the values of one column of my dataset because it's a Rank column and Ranks are 1-highest .....4-lowest. – Anu Jun 04 '20 at 22:33
  • I want to make it as: 4-highest....1-lowest – Anu Jun 04 '20 at 22:34
  • @akrun, are you able to reproduce the error above with data and/or the `plyr::mapvalues` function? The error suggests it has nothing to do with the function/call itself. (We won't now for sure until Anu decides to give more information.) – r2evans Jun 04 '20 at 22:38
  • TYPO: you mentioned `datac` but your call above has `data$rank` (should be `datac$rank`). – r2evans Jun 04 '20 at 22:50
  • Perhaps it could be more appropriate to close as *"could not reproduce or is a typo"*, since the error (dupe) is caused by the typo. If you'd like to vote to reopen so that you can vote to close as a typo, I might be convinced. But closing the question is appropriate in either case. – r2evans Jun 04 '20 at 23:36
  • @r2evans I don't want to reopen. I was just saying that the error is a bit more general and it can happen in multiple cases. – akrun Jun 04 '20 at 23:39
  • The problem had nothing to do with `mapvalues`, and change from that function to any other code (base or otherwise) would fix nothing unless/until the OP fixes the typo of `data` to `datac` (case in point, `datac` from your answer and the OP code with typo fixed works fine). I'm not saying your answer was without value, quite the opposite, and often that's how (new) programmers learn: different approaches to data problems. I also think undeleting your answer holds value, too, it is certainly not irrelevant and I never intended to suggest that. – r2evans Jun 05 '20 at 02:20

0 Answers0