Dear all,
I would like to transpose my data like the picture below.
I used this code
tdf <- data.frame(t(df)
My problem is that I can not fix the column name and row name.
I would like to ask for help. Thank you so much.
df<-data.frame(wgi = as.factor(c("voice","stability", "government","regulatory","rule")),
X2016 = c(-1.37, 0.23, 0.02, -0.45, 0.08),
X2017 = c(-1.4, 0.29, 0.01, -0.4, 0.07),
X2018 = c(-1.44, 0.11, 0, -0.35, 0),
X2019 = c(-1.38, 0.13, 0.04, -0.26, -0.02))