Skip to content

ingmarboeschen/graphing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The 'graphing' package

This package contains some convenient graphic functions for the statistical software R.

Built With

Depends on

The function igraph2() depends on the R packages

The function worldmap2() depends on the R packages

The function orcid2name() depends on the R package

Getting Started

To install graphing run the following steps:

Installation

  1. Install and load the devtools package
# Install the devtools package
install.packages("devtools")
# Load the devtools package
library(devtools)
  1. Install graphing from https://github.com/ingmarboeschen/graphing
# Install graphing from github
install_github("ingmarboeschen/graphing")

Examples

The examples listed below are minimal working examples. For a full documentation of each function, check the manual.

prettybarplot(), an adjustable labeled bar plot with background color option

x<-sample(letters[1:4],100,T)
y<-sample(1:3,100,T)
# one dimensional absolute frequencies
prettybarplot(table(x)) 
# two dimensional relative frequencies
prettybarplot(prop.table(table(x,y))) 

profileline(), course of descriptive parameters over several items

matrix<-data.frame(matrix(sample(-3:3,1000,T),ncol=10))
names(matrix)<-paste("Item",1:10); g<-paste("Group",rep(1:3,length=100))
for(i in 1:dim(matrix)[2]){matrix[,i]<-factor(matrix[,i],-3:3,c("fully disagree","2","3","4","5","6","fully agree"))}
profileline(matrix,g,main="profileline()",N_legend=T,type="Median",ex=T,xlab="agreement")
profileline(matrix,g,main="",N_legend=T,pch="",type="Mean",ex=T,low="low",high="high",xlab="agreement")

itemplot(), frequency distribution of categorical variable with descriptives

x<-factor(sample(letters[1:6],100,T))
itemplot(x,main="itemplot()",labels=c("I fully\n disagree","I fully\n agree"),legend=F)
itemplot(x,main="itemplot()",labels=c("I fully\n disagree","I fully\n agree"))

CIV(), confidence interval violin plot

x<-sample(paste("group",1:4),100,T)
y<-10+as.numeric(factor(x))*2+rnorm(length(x))
CIV(x,y,main="Confidence Intervall Violin Plot")

bp3d(), barplot for 3 dimensional contingency tables

x <- sample(paste("time",1:4),240,T)
z <- rep(c("A","B"),each=120)
y <- paste("answer",sample(1:7,240,T))
bp3d(x,z,y,main="bp3d()",xlab="treatment group")

stacked.area.chart(), stacked area chart for two dimensional contingency tables

x<-sample(2010:2020,1000,T,.2+(1:11)*.5)
y<-sample(paste("category",LETTERS[1:10]),1000,T)
par(mar=c(4,4,2,5))
stacked.area.chart(table(x,y),main="stacked.area.chart()",ylab="h(x)",xlab="year",reorder=T)
stacked.area.chart(prop.table(table(x,y),m=1),main="stacked.area.chart()",ylab="f(x)",xlab="year")

catplot(), conditioned/unconditioned frequency plot for two high dimensional categorial variables

x<-sample(2010:2020,1000,T,.2+(1:11)*.5)
y<-sample(paste("group",LETTERS[1:10]),1000,T)
catplot(x,y,main="catplot()",xlab="year")

multi.line(), multi group comparison of regression/lowess lines

data(ChickWeight)
attach(ChickWeight)
Diet<-paste("Diet",ChickWeight$Diet)
multi.line(x=jitter(Time,2),y=weight,group=Diet,points=T,main="multi.line()",xlab="time",ylab="weight")
multi.line(x=jitter(Time,2),y=weight,group=Diet,points=F,main="multi.line() without points with lowess line",xlab="time",ylab="weight",type="lowess")

igraph2(), simple network graph

x<-list(
     c("Laura","Ingmar"),
     c("Peter","Renate","Ingmar","Andrea"),
     c("Nassim","Ingmar","Sergej"),
     c("Laura","Rike","Andra"),
     c("Marlene","Nassim","Christina","Sabine"),
     c("Bela","Ingmar","Mariola","Nassim"),
     c("Gloria","Kim","Olek","Bolek"))
igraph2(x)

worlmap2(), world map of country and country connection frequency

 x<-list(c("Germany","Austria","S. Korea"),
 c("Germany","Austria","S. Korea"),c("Germany","Austria","S. Korea"),
 c("Germany","Spain"),c("Germany","Spain"),c("United States","Germany"),
 c("Germany","Cuba","Bolivia","South Africa"))
worldmap2(x)
# Note: arguments legend1 and legend2 need adjustments that dependend on the resolution of the resulting graph. 

orcid2name, ORCID author identification code to 'surname, name' conversion

# Note: You need an ORCID account to authenticate to the ORCID api
name<-c("https://orcid.org/0000-0003-1159-3991","Einstein, Albert")
orcid2name(name)