Re: [R] Splitting a vector into data frame

2016-03-24 Thread Ivan Calandra
Hi! As Boris explained, if you do not always have the same number of values per country, you need to provide more details, e.g. should the empty cells be filled with NA? But if you do always have 20 values per country (unlike in your sample data), then this could work for you: mydf <- data.

Re: [R] Splitting a vector into data frame

2016-03-24 Thread Jim Lemon
Hi Burhan, As all of your values seem to be character, perhaps: country.df<-as.data.frame(matrix(temp.data,ncol=22,byrow=TRUE)[,2:21]) if there really are 2 country names and 20 values for each country. As Boris has pointed out, there are different numbers of values following the country names in

Re: [R] Splitting a vector into data frame

2016-03-24 Thread Boris Steipe
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 wrote: > Hi, > > 1. I have scraped some data from the web, subset shown below > >> dput(temp.data) > c("Armenia", "Armenia", "43827", "39200", "357

[R] Splitting a vector into data frame

2016-03-24 Thread Burhan ul haq
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"