Simple lookup to insert values in an R data frame

后端 未结 4 639
没有蜡笔的小新
没有蜡笔的小新 2021-02-07 16:38

This is a seemingly simple R question, but I don\'t see an exact answer here. I have a data frame (alldata) that looks like this:

Case     zip     market
1              


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-07 16:47

    Here's the dplyr way of doing it:

    library(tidyverse)
    alldata %>%
      select(-market) %>%
      left_join(zipcodes, by="zip")
    

    which, on my machine, is roughly the same performance as lookup.

提交回复
热议问题