CoCalc Public Filestmp / r.ipynb
Views : 89
Compute Environment: Ubuntu 18.04 (Deprecated)
In [1]:
require(ggplot2)
p1 <- ggplot(mpg, aes(x=class, y=hwy)) +
geom_boxplot(color="blue", fill="blue", alpha=0.2, notch=TRUE, notchwidth = 0.8,
outlier.colour="red", outlier.fill="red", outlier.size=3
)

p1

Loading required package: ggplot2 notch went outside hinges. Try setting notch=FALSE. notch went outside hinges. Try setting notch=FALSE.

â€¦ saving plot to PDF

In [2]:
pdf("r-cars-plot.pdf")
p1
dev.off()

notch went outside hinges. Try setting notch=FALSE. notch went outside hinges. Try setting notch=FALSE.
png: 2
In [3]:
require("fishmethods")

In [4]:
data(rig)
fit <- grotagplus(rig,dataID="Sex",alpha=70,beta=100,
model=list(mean="Francis",var="linear",seas="none"),
design=list(galpha=list("F","M"),gbeta=list("F","M"),
s=1,nu=1,m=0,p=0),
stvalue=list(galpha=c(5,4),gbeta=c(3,2),s=2,nu=0.5),
upper=list(galpha=c(8,6),gbeta=c(5,4),s=4,nu=1),
lower=list(galpha=c(3,2),gbeta=c(1.5,1),s=0.5,nu=0.2))
mnlenatage <- list(F=90.7*(1-exp(-0.42*(seq(1.5,6.5)-0.77))),
M= 118.7*(1-exp(-0.16*(seq(4,11)-2.02))),
PGM=161.1*(1-exp(-0.11*(seq(3.5,10.5)-1.91))))
plot(fit,age.based.growth=mnlenatage)
## Residual plots
fit <- grotagplus(rig,dataID="Sex",alpha=70,beta=100,
model=list(mean="Francis",var="linear",seas="none"),
design=list(galpha=list("F","M"),gbeta=list("F","M"),
s=1,nu=1,m=0,p=0),
stvalue=list(galpha=c(5,4),gbeta=c(3,2),s=2,nu=0.5),
upper=list(galpha=c(8,6),gbeta=c(5,4),s=4,nu=1),
lower=list(galpha=c(3,2),gbeta=c(1.5,1),s=0.5,nu=0.2))
plot(fit,"resid")
plot(fit,"resid",resid.spec=list(Pearson=FALSE,x="L1"))
## Trajectory plot as in Fig. 2 of Francis (1988)
data(bonito)
fit <- grotagplus(bonito,alpha=35,beta=55,
design=list(galpha=1,gbeta=1,s=1,nu=1,m=1,p=1,u=1,w=1),
stvalue=list(s=0.81,nu=0.3,m=0,p=0.01,u=0.5,w=0.5),
upper=list(s=3,nu=1,m=2,p=0.1,u=1,w=1),
lower=list(s=0.1,nu=0.1,m=-2,p=0,u=0,w=0))
plot(fit,"traj",Linitial=35)


3D plot package

In [7]:
library("plot3D")
with(USArrests, text3D(Murder, Assault, Rape,
labels = rownames(USArrests), colvar = UrbanPop,
col = gg.col(100), theta = 60, phi = 20,
xlab = "Murder", ylab = "Assault", zlab = "Rape",
main = "USA arrests", cex = 0.5,
bty = "g", ticktype = "detailed", d = 3,
clab = c("Urban","Pop"), adj = 0.5, font = 2))