[R] Splitting a vector into data frame

Boris Steipe boris.steipe at utoronto.ca
Thu Mar 24 11:40:24 CET 2016


Your data rows have different numbers of columns. Thus your problem is not sufficiently specified.

B. 
On Mar 24, 2016, at 6:30 AM, Burhan ul haq <ulhaqz at gmail.com> wrote:

> 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]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list