-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPer_cover_loop.R
More file actions
60 lines (50 loc) · 2.38 KB
/
Per_cover_loop.R
File metadata and controls
60 lines (50 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#USING GGPLOT
######################################
attach(algaetest<-read.table(file.choose(), header=TRUE))
attach(algaetest<-cbind(algaetest, AreaP=ifelse((3.14*(Diameter/2)^2) %% 2 >= 0.1, (3.14*(Diameter/2)^2), 0.1)))
attach(algaetest<-cbind(algaetest, AreaQ=(Xmax-Xmin)*(Ymax-Ymin)))
attach(algaetest<-cbind(algaetest, Count=round((PerCov*(AreaQ/AreaP)), 0)))
head(algaetest)
pts<-data.frame(X=0, Y=0, Spec=0, Diam=0)
for (row in 1:nrow(algaetest)) {
X=runif(Count[row],Xmin[row],Xmax[row])
Y=runif(Count[row], Ymin[row],Ymax[row])
Spec=rep.int(Species[row], Count[row])
Diam=rep.int(area[row], Count[row])
ptstemp<-data.frame(cbind(X, Y))
ptstemp<-cbind(ptstemp, Spec)
ptstemp<-cbind(ptstemp, Diam)
pts<-rbind(ptstemp, pts)
}
library(ggplot2)
ggplot(pts, aes(X,Y, col=Spec, group=factor(Spec)))+
geom_jitter(height=1, width=1, alpha=0.6, aes(size=Diam),
shape=ifelse(Diam>0.1, 19, 20))+
scale_size_area(max_size = 10) +
for (row in 1:nrow(shore)){
geom_segment(aes(x = xi[row], y = yi[row], xend = xf[row], yend = yf[row]))
}
#BASIC R CODE
#############################################
attach(algaetest<-read.table(file.choose(), header=TRUE))
attach(algaetest<-cbind(algaetest, AreaP=ifelse((3.14*(Diameter/2)^2) %% 2 >= 0.1, (3.14*(Diameter/2)^2), 0.1)))
attach(algaetest<-cbind(algaetest, AreaQ=(Xmax-Xmin)*(Ymax-Ymin)))
attach(algaetest<-cbind(algaetest, Count=round((PerCov*(AreaQ/AreaP)), 0)))
attach(algaetest<-cbind(algaetest, ColText=c("coral2", 'darkblue', 'blueviolet','forestgreen','firebrick')))
par(xaxs="i", yaxs="i")
plot(c(min(Xmin),max(Xmax)),c(min(Ymin),max(Ymax)), type='n', xlab='distance along shore (m)',ylab='distance from shore (m)',las=1)
for (row in 1:nrow(algaetest)) {
points(runif(Count[row], Xmin[row], Xmax[row]),runif(Count[row], Ymin[row],Ymax[row]), pch=20,
cex=2.5*AreaP[row], col=color[row])
}
for (row in 1:nrow(algaetest)) {
ggplot(algaetest, aes((runif(Count[row], Xmin[row], Xmax[row]),(runif(Count[row], Ymin[row],Ymax[row]))+geom_point()
}
ggplot(algaetest, aes((runif(Count, Xmin, Xmax)),(runif(Count, Ymin,Ymax)))+geom_point()
pts<-0
for (row in 1:nrow(algaetest)) {
points(runif(Count[row], Xmin[row], Xmax[row]),runif(Count[row], Ymin[row],Ymax[row]), pch=pch[row],
cex=Diameter[row], col=color[row])
}
pts<-data.frame(cbind(X=runif(10,0,10), Y=runif(10,0,10)))
test<-ggplot(pts, aes(X,Y))+geom_point()