Thank you very much, the code worked the trick. Thank you, i appreciate. Alternative email: addtar...@icloud.com/tchir...@rbz.co.zw Skype: admirechirume Call: +263773369884 whatsapp: +818099861504
On Thu, Aug 5, 2021 at 11:53 AM Jim Lemon <drjimle...@gmail.com> wrote: > Hi Admire, > I think rep_n_stack in the prettyR package may do what you want: > > # download and install the prettyR package > install.packages("prettyR") > # load the prettyR package > library(prettyR) > # read in your data > ATCdf<-read.csv("BOP_All_Countries.csv",stringsAsFactors=TRUE) > # convert the values you want to long format > ATClong<-rep_n_stack(ATCdf,to.stack=3:17,stack.names=c("year","value")) > # as your column names in Excel will be coerced to character values by > prepending "X", > # coerce them back to numeric > ATClong$year<-as.numeric(substr(ATClong$year,2,5)) > # check the first row > ATClong[1,] > > As the "Variables" column is messy, you may want to substitute the > numeric value in the long output and print a table of the numeric and > character values of the factor: > > unique(ATClong$Variables) > ATClong$Variables<-as.numeric(ATClong$Variables) > > Jim > > On Tue, Aug 3, 2021 at 9:53 PM Admire Tarisirayi Chirume > <atchir...@gmail.com> wrote: > > > > > > > > Hello Jim, i hope you are well. I think my msg was rejected beacuse of > the size of my files. I was kindly help me to structure data in the folder > attached herewith in file BOP_All_Countries.csv. I am doing panel data > analysis. I need it to be structured as it is on the file R_help.csv. > > > > Please kindly see the r-script below (r_help.R) that i ran which did not > yield what i wanted. > > > > Thank you in advance for your help. > > > > > > Alternative email: addtar...@icloud.com/tchir...@rbz.co.zw > > Skype: admirechirume > > Call: +263773369884 > > whatsapp: +818099861504 > [[alternative HTML version deleted]] ______________________________________________ R-help@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.