user13696679
user13696679

Reputation: 75

Hot to draw ggplot of the data in table?

I have gathered the data consisting of powers of 7 tests, in 3 cases (I,II,III). I would like to draw ggplot (points connected with lines), where

I started like this, but I don't know how to put the cases od I,II,III on x axsis.

Data frame looks like this: enter image description here

Many thanks for help!

power1 = c(0.109, 0.045, 0.703, 0.073,  0.066, 0.043, 0.05)
power2 = c(1,1,1, 1,1, 0.829,  1)
power3 = rep(1,7)
m = matrix(c(power1, power2, power3),nrow = 7)
TEST = c("HC", "HCmod", "Bonf" ,"ChiSq", "Fisher", "KS", "AD")
#MU1,MU2,MU3 ARE THREE CASES (I,II,III)
DF = data.frame(HC = m[1,],HCmod=m[2,],BONF = m[3,],CHI_SQ = m[4,],FISHER = m[5,],KS=m[6,], AD=m[7,],MU = c("MU1","MU2","MU3"))

ggplot(DF,aes(MU,DF)) +geom_point(aes(DF[]))

enter image description here

Upvotes: 1

Views: 58

Answers (1)

Duck
Duck

Reputation: 39613

Try this reshaping your data to long and then sketching the plot:

library(dplyr)
library(tidyr)
library(ggplot2)
#Code
DF %>% pivot_longer(-MU)%>%
  ggplot(aes(x=MU,y=value,group=name,color=name)) +
  geom_point()+
  geom_line()

Output:

enter image description here

Upvotes: 2

Related Questions