1)我想在 Gnu R 中使用此处的数据集进行子集操作,以生成仅包含巴西、时间和有关收入份额的所有系列名称的结果数据框(例如“最低 10% 持有的收入份额”、“ “Income share by minimum 20%”等)。总共会有7个关于Income Share的系列名称。
我尝试了以下命令,但不能子集多个“Series.Name”:
test <- melt(subset(WDI, subset = Series.Name == "Income share held by lowest 10%", select = -c(Time.Code, Series.Code, Argentina, Canada, Chile, Colombia, Mexico, USA, Venezuela)), id.vars = c("Series.Name", "Time"))
2)在第二步中,我想删除所有具有 NA 值的行。
我使用的完整代码如下:
WDI <- read.csv(https://dl.dropboxusercontent.com/u/109495328/WDI_Data_final.csv, na.strings = "..")
library(reshape)
library(reshape2)
WDI <- rename(WDI, (c(Argentina..ARG.="Argentina", Brazil..BRA.="Brazil", Canada..CAN.="Canada", Chile..CHL.="Chile", Colombia..COL.="Colombia", Mexico..MEX.="Mexico", United.States..USA.="USA", Venezuela..RB..VEN.="Venezuela")))
income_brazil_long <- melt(subset(WDI, subset = Series.Name == "Income share held by lowest 10%", select = -c(Time.Code, Series.Code, Argentina, Canada, Chile, Colombia, Mexico, USA, Venezuela)), id.vars = c("Series.Name", "Time"))