top of page
Search

Example: Beeswarm plot in R

library(foreign)

data <- read.dta("C:/Users/hellmund/Documents/MyStataDataFile.dta")

names(data)

install.packages(‘beeswarm’)

library(beeswarm)

levels(data$group)

png(file=”C:/Users/hellmund/Documents/il6.png”, bg=”transparent”)

beeswarm(data$il6~data$group,data=data, method=c(“swarm”),pch=16,pwcol=data$Gender,xlab=”,ylab=’il6′,ylim=c(0,20))

legend(‘topright’,legend=levels(data$Gender),title=’Gender’,pch=16,col=2:1)

boxplot(data$il6~data$group, data=data, add = T, names = c(“”,””,””), col=”#0000ff22″)

dev.off()


1 view0 comments

Recent Posts

See All

dplyr or base R

dplyr and tidyverse are convenient frameworks for data management and technical analytic programming. With more than 25 years of R experience, I have a tendency to analyze programmatic problems before

©2020 by Danish Institute for Data Science. Proudly created with Wix.com

bottom of page