我正在尝试使用年份、品牌和型号将来自 NHTSA 的解码 VIN 数据与来自fueleconomy.gov 的车辆数据连接起来。以下是我尝试加入的数据示例:
# This is the first dataframe
make <- c("PORSCHE", "TESLA", "MITSUBISHI")
model <- c("Cayenne", "Model S", "Outlander - PHEV")
year <- c(2017, 2013, 2018)
electrification_level <- (PHEV, BEV, PHEV)
vin_data <- data.frame(make, model, year, electrification_level)
# This is the second dataframe
make <- c("Porsche", "Tesla", "Mitsubishi")
# There are multiple versions of the models (an average of these would be ideal - e.g. avg. mpg)
model <- c("Cayenne S e-Hybrid", "Model S AWD - P85D", "Outlander 2WD")
year <- c(2017, 2013, 2018)
# These mpg are made up for the example
mpg <- c(75, 120, 80)
fueleconomy_data <- data.frame(make, model, year, mpg)
我在尝试完成此加入时遇到了多个问题。
- 我需要使用 make 和 year 加入数据,但 make 需要不区分大小写。
- 我需要对模型执行不精确匹配,并且可能对模型的 mpg 值进行平均,因为每个模型的fueleconomy.gov 数据中有多个条目(例如2WD、4WD、不同的发动机尺寸、混合动力等)。
我参考了以下问题来尝试解决这个谜语:
我还联系了fueleconomy.gov 和NHTSA,看看他们是否有能力加入基于车辆ID 的数据,但我想问问社区是否也有一个简单的解决方案。