如何将单个属性转换为列名?

时间:2017-03-13 04:34:11

标签: r

我需要将指标的属性转换为列名。我使用了tidyr库,但似乎有一个限制,你可以转换。 下面提到的代码不是实际的表,因为该表有大约800个属性。

Country<- c("India", "India","India", "Russia", "Russia","Russia","USA","USA","India","India","India","Russia","Russia","USA","USA")
Indicator <- c("Mortality", "Education", "Poverty", "Mortality", "Education", "Poverty","Mortality","Education","Mortality","Education","Poverty","Education","Poverty","Education","Poverty")
Value<-c(40,54,68,28,70,30,11,80,30,60,40,20,60,7,95)
Year<-c(1965,1965,1965,1965,1965,1965,1965,1965,2003,2003,2003,2003,2003,2003,2003)
dat <- data.frame(Country,Indicator,Year,Value) 
Indicators<-spread(dat,Indicator,Value)

0 个答案:

没有答案