## Upload a data
=read.csv("C:/Users/L/OneDrive/Bureau/STAA 566/ggplot slide/prostate.csv",header = TRUE)
Prostat
## make a plot
<- ggplot(data = Prostat,
pro mapping = aes(x = lcavol,
y = lpsa,
color=lweight))+
geom_point(aes(size=age),
alpha=.5,
shape=16)
= pro + geom_smooth(method = "loess", aes(color=lweight))+
Pro theme_minimal()+ ylab("log(prostate specific antigen)") +
xlab("log(cancer volume)")+
theme_tufte(base_size=12,
base_family = "sans")+
guides(size=guide_legend(title="Age (Years)"),
color="none")+
theme(legend.position = c(0.87, 0.25))
= Pro + scale_color_viridis(discrete = FALSE) + ggtitle("level of prostate-specific antigen by Cancer volume") Pro
ggplot Assignment
Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
Running Code
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
Description
Data to examine the correlation between the level of prostate-specific antigen and a number of clinical measures in men who were about to receive a radical prostatectomy. A data frame with 97 observations on the following 10 variables
Data visualization (make a Figure)
Save figure as PDF
pdf("ggplot_assignmnent.pdf", height=4, width=6)
print(Pro)
`geom_smooth()` using formula 'y ~ x'
dev.off()
png
2
Display Figure in HTLM
Pro
`geom_smooth()` using formula 'y ~ x'