Splitting a dataframe based on rows in R -


i have table in pdf file. converted csv , here csv content.

a   23  45  53  34     62  87  94  75  b   120 61  113 41     109 48  90  95     123 113 112 101 

i loaded csv r, dataframe not expected.

a   23  45  53  34  62  87  94  75  b   120 61  113 41  109 48  90  95  123 113 112 101  

how can split rows in dataframe. appreciated.

at end, trying acheive like:

a1  23  45  53  34 a2  62  87  94  75  b1  120 61  113 41 b2  109 48  90  95 b3  123 113 112 101 

thanks lot

would work?

x <-read.csv("your-file.csv", header=f)  h=vector("character",nrow(x))  n=1; p=na  (i in 1:nrow(x)) {    if (""==x$v1[i]) { n=n+1; z = p} else { n = 1; z = p = x$v1[i] }   h[i] = paste0(z,n)   }  x$v1 <- h 

probably there better solutions, without for-loop, quickest devise...


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -