[R] Splitting a vector into data frame
Burhan ul haq
ulhaqz at gmail.com
Thu Mar 24 11:30:11 CET 2016
Hi,
1. I have scraped some data from the web, subset shown below
> dput(temp.data)
c("Armenia", "Armenia", "43827", "39200", "35700", "36700", "39341",
"30571", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", " 0",
"0", "0", "0", "0", "Austria", "Austria", "135417", "166200",
"144500", "147300", "163211", "162536", "155412", "133667", "134962",
"146440", "131188", "100001", "100000", "80000", "35000")
2. The corresponding list of countries, is as follows
> dput(raw.country)
c("Armenia", "Austria", "Belarus", "Belgium", "Brazil", "Bulgaria",
"Canada", "Castile-Leon (Hiszania)", "Catalonia", "Chile", "Colombia",
"Costarica", "Croatia", "Cyprus", "Czech Republic", "Ecuador",
"Estonia", "Finland", "France", "Georgia", "Germany", "Ghana",
"Greece", "Hungary", "Indonesia", "Iran", "Ireland", "Israel",
"Italy", "Kazakhstan", "Kyrgyzstan", "Latvia", "Lithuania", "Macedonia",
"Malaysia", "Mexico", "Moldova", "Mongolia", "Netherland", "Norway",
"Pakistan", "Panama", "Paraguay", "Peru", "Poland", "Portugal",
"Puertorico", "Romania", "Russia", "Serbia", "Slovakia", "Slovenia",
"Spain", "Sweden", "Switzerland", "Tunisia", "Ukraine", "United Kingdom",
"USA", "Venezuela", "Vltava", "World Total")
3. I want to organize the data into a data frame, where each row will
contain the 20 values for the corresponding country.
It needs to ignore the country name which appears twice.Something like:
Armenia "43827", "39200", "35700", "36700", "39341",
"30571", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", " 0",
"0", "0", "0", "0",
"Austria", "135417", "166200",
"144500", "147300", "163211", "162536", "155412", "133667", "134962",
"146440", "131188", "100001", "100000", "80000", "35000"
and so on
Thanks /
[[alternative HTML version deleted]]
More information about the R-help
mailing list