Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Replacing multiple random observations in one line

    How to do this in one line?

    replace Country = "Bahamas, The" if Country == "Bahamas"
    replace Country = "Bolivia (Plurinational State of)" if Country == "Bolivia"
    replace Country = "Brunei Darussalam" if Country == "Brunei"
    replace Country = "D.R. of the Congo" if Country == "Congo, Democratic Republic of"
    replace Country = "Congo" if Country == "Congo, Republic of"
    replace Country = "CuraƧao" if Country == "Curacao"

  • #2
    It could be done in one line with cond() but even if fluent with that function, you'd be writing code that was hard to write, hard to read and hard to debug,

    Just possibly there is neater alternative that depends on your having in a dataset two variables only, the names you have and the names you want. Then it is a merge problem.

    Comment

    Working...
    X