Hi,
How can I plot small variables i.e. kurto and skew in secondary y-axis in facet?
The code below showed a plot of all 4 variables for each group a-d.
library(dplyr, warn.conflicts = FALSE)
library(tidyr)
library(e1071)
library(ggplot2)
set.seed(100)
df=data.frame(
a=sample(100,96),
b=sample(100,96),
c=sample(100,96),
d=sample(100,96)
)
dat=df %>%
pivot_longer(a:d,names_to = "model", values_to = "value") %>%
mutate(month=month.abb[rep(rep((1:12),each=4),8)])
pfinal=dat %>%
group_by(month,model) %>%
summarise(sdev=sd(value,na.rm=TRUE),
cV=sd(value) / mean(value) * 100,
sKew=skewness(value),
kUrto=kurtosis(value)
)
d_long=pfinal %>%
pivot_longer(sdev:kUrto,names_to = "Type_of_measure", values_to = "value")
ggplot(d_long, aes(x = month, y= value, fill = Type_of_measure), xlab="") +
geom_bar(stat="identity", width=.5, position = "dodge") +
facet_wrap(~model)
Thank you.!