Packages

install.packages("CGPfunctions")

or

install.packages("devtools")
devtools::install_github("ibecav/CGPfunctions")
library(CGPfunctions)

Data

data(newcancer)
library(DT)
datatable(newcancer)

Slopegraphs on newcancer data

newggslopegraph(dataframe = newcancer, 
                Times = Year, 
                Measurement = Survival, 
                Grouping = Type, 
                Title = "Estimates of Percent Survival Rates",
                SubTitle ="",
                Caption = NULL)

Another Example: PISA data

Data

library(readr)
dx <- read_csv("dx.csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
##   X1 = col_integer(),
##   Country2 = col_character(),
##   variable = col_character(),
##   value = col_double()
## )
dx=as.data.frame(dx[,-1])
datatable(dx,extensions = 'Buttons', options = list(
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
  )
  )

Slopegraph on PISA data

print(newggslopegraph(dataframe = dx,Times = variable,Measurement = value,Grouping = Country2,Title = "PISA scores",SubTitle = "",Caption = NULL,XTextSize = 10,YTextSize = 2))