data visualization with r.ggplot2 and its extensions examples
TRANSCRIPT
![Page 1: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/1.jpg)
prepared by VOLKAN OBAN
DATA VİSUALIZATION with Rggplot2 and Its Extension Examples:
![Page 2: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/2.jpg)
![Page 3: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/3.jpg)
![Page 4: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/4.jpg)
![Page 5: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/5.jpg)
![Page 6: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/6.jpg)
![Page 7: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/7.jpg)
![Page 8: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/8.jpg)
theme(panel.background = element_rect(fill = 'paleturquoise'), panel.grid.major = element_line(colour = "purple2", size=3), panel.grid.minor = element_line(colour = "red4", size=1))
![Page 9: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/9.jpg)
![Page 10: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/10.jpg)
![Page 11: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/11.jpg)
![Page 12: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/12.jpg)
corr <- round(cor(mtcars), 2)
df <- reshape2::melt(corr)
gg <- ggplot(df, aes(x=Var1, y=Var2, fill=value, label=value)) + geom_tile() + theme_bw() + geom_text(aes(label=value, size=value), color="white") + labs(title="mtcars - Correlation plot") + theme(text=element_text(size=20), legend.position="none")
library(RColorBrewer)
p2 <- gg + scale_fill_distiller(palette="Reds")
p3 <- gg + scale_fill_gradient2()
gridExtra::grid.arrange(gg, p2, p3, ncol=3)
lattice example:
![Page 13: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/13.jpg)
![Page 14: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/14.jpg)
Code:
library(semPlot)library(lavaan)library(clusterGeneration) #this is to generate a positive definite covariance matrix#simulate some dataset.seed(1222)sig<-genPositiveDefMat("onion",dim=5,eta=4)$Sigma #the covariance matrixmus<-c(10,5,120,35,6) #the vector of the meansdata<-as.data.frame(mvrnorm(100,mu=mus,Sigma=sig)) #the datasetnames(data)<-c("CO2","Temp","Nitro","Biom","Rich") #giving it some names#building an SEM with a latent variablem<-'Abiot =~ CO2 + Temp + NitroBiom ~ AbiotRich ~ Abiot + Biom'm.fit<-sem(m,data)#the plot#basic version, the what arguments specify what should be plotted, here we choose to look at the standardized path coefficientssemPaths(m.fit,what="std",layout="circle")
Reference: http://r-statistics.co/
![Page 15: Data Visualization with R.ggplot2 and its extensions examples](https://reader036.vdocuments.us/reader036/viewer/2022070513/588727651a28abfb0b8b6c9d/html5/thumbnails/15.jpg)
http://r-statistics.co/ggplot2-cheatsheet.html#Annotationhttp://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf