Upload
muhammad-nabi-ahmad
View
574
Download
0
Embed Size (px)
Citation preview
Summary Introduction Data Import (csv, txt ...) Data
Types Data-frames Question (sapply(tree,class) --ref(1) )
Basic Operations Help Summery Subset and Filter Duplicates and NA
Basic analysis/stats Graphs
Default package ggplot
How many have installed ggplot2 package Ref.1) http://www.statmethods.net/input/datatypes.html
Tree <- read.table("datavis.csv",sep=",",header=T)
?separator ?Yes file has a Header
library(ggplot2)
RStudioFile → New File → R Script
ggplot(data=tree, aes(x=PosTopoSeq)) + geom_bar(stat="bin")
? ? ?Geometry = bar
statistical transformation = binbin = number of cases in group
Data frame Field on x
Some colours please
ggplot(data=tree, aes(x=VegStructure,colour=Site)) + geom_bar(stat="bin")
?Different colours for each site
ggplot(data=tree, aes(x=VegStructure,fill=Site)) + geom_bar(stat="bin")
Fill geometry
Veg. Structure = Shrubland is in all sites
&
Site 1 is richest in terms of
Veg. Structure
Question: Confirm that Shrubland is present in every site
ggplot(data=tree) + geom_boxplot(aes(Site,avTreeDen,col=Site))+ coord_flip() + facet_wrap(~VegStructure,ncol=1)
Yes Veg. Structure = Shrubland
is in all sites
ggplot(data=tree,aes(x=Carbon,y=Clay)) + geom_line(colour="red", linetype="dashed", size=0.5) +
geom_point(colour="red", size=2, shape=22, fill="red")
? linetype
0 = blank, 1 = solid, 2 = dashed, 3 = dotted, 4 = dotdash, 5 = longdash, 6 = twodash
gg <- ggplot() + geom_point(data=tree,aes(x=Carbon,y=Clay,col=Site)) + geom_line(data=tree,aes(x=Carbon,y=Clay,col=Site))
plot(gg)
ggplot(data=tree) + geom_boxplot(aes(Site, pH))
ggplot(data=tree) + geom_boxplot(aes(Site, Clay))
ggplot(data=tree) + geom_boxplot(aes(Site, Carbon))