r - Panel Data from Long to wide reshape or cast -


hi have panel data , reshape or cast indicator name column long wide format. columns in long format, year(1960-2011), country name (all countries in world), indicator name (varying different indicators) , value(individual values corresponding year, indicator name , country name). how can can please. various indicators in wide format corresponding value below , on other columns year , country name. please help

indicator.name  year    country gdp             1960    usa gdp             1960    uk     country name    year    gdp    ppp    hhh usa             1960    7       9      10 uk              1960    9       10     na world           1960    7       5      3 africa          1960    3       7      na 

try using dcast reshape2 below:

library(reshape2) indicator <- c('ppp','ppp','gdp','gdp') country.name <- c('usa','uk','usa','uk') year <- c(1960,1961,1960,1961) value <- c(5,7,8,9) d <- data.frame(indicator, country.name, year, value) d1 <- dcast(d, country.name + year ~ indicator) 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -