Re: [R] Advice on data format

2015-08-05 Thread Michael Dewey
Dear Trent If you want them side-by-side in one data frame then you could use merge making sure it only merges by date. I would use sub to change all the anitbiotic names by adding "h1" "h2" and so on. Then you can sum antibiotic over hospital by using grep to select all the columns containin

Re: [R] Advice on data format

2015-08-05 Thread Jim Lemon
Hi Trent, I may be missing something, but I think that if you simply add your column with the hospital code to each of the five data frames: hospital1.df$hospital<-"hospital1" hospital2.df$hospital<-"hospital2" ... and then concatenate (rbind) them you can get what you want without going to a 3D

[R] Advice on data format

2015-08-05 Thread Trent Yarwood
Hi all, I'm responsible for collating data on antibiotic use at my local group of hospitals. I have data for five different hospitals, about 40 different antibiotics and monthly data going back to 2006. At the moment, I have this stored in 5 datafiles, one for each hospital, formatted as follows