I'm quite new to R studio, so I apologise in advance. I need help to create a grouped barplot. I have three variables: "Time": converted to a continuous variable "Treatment": "Con", "Hya" "Trial": "T1", "T2", "T3" I want to produce something like this:
There should be three groups of three columns stacked beside each other. Time on the Y-axis; Trial (1,2 & 3)on the X-axis; Treatment corresponding to coloured columns (Hya=grey, Con=white) with a legend explaining Treatment colour.
Here is the structure of my data:
'data.frame': 102 obs. of 3 variables:
$ Trial : int 1 1 1 1 1 1 1 1 1 1 ...
$ Treatment: $ Trial : int 1 1 1 1 1 1 1 1 1 1 ...
$ Treatment: Factor w/ 2 levels "Control","Hyaluronan": 1 1 1 1 1 1 1 1 1 1 ...
$ Time : num 11 7 7.68 7.7 7 3 5 5.48 4 6 ...
I get this error message:
> barplot(table(Biopsy$Time, Biopsy$Treatment, Biopsy$Trial))
Error in barplot.default(table(Biopsy$Time, Biopsy$Treatment, Biopsy$Trial)) :
'height' must be a vector or a matrix
Please if anyone is able to help I would so appreciate it, I've been trying for so long :(