-
Notifications
You must be signed in to change notification settings - Fork 4
/
example-script.R
49 lines (39 loc) · 1.65 KB
/
example-script.R
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
#==============================================================================
# ggplot2
#
# Example from https://www.statmethods.net/advgraphs/ggplot2.html
#==============================================================================
library(ggplot2)
# Create factors with value labels
mtcars$gear <- factor(mtcars$gear,levels=c(3,4,5), labels=c("3gears","4gears","5gears"))
mtcars$am <- factor(mtcars$am,levels=c(0,1), labels=c("Automatic","Manual"))
mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8), labels=c("4cyl","6cyl","8cyl"))
# Kernel density plots for mpg
# grouped by number of gears (indicated by color)
qplot(mpg, data=mtcars, geom="density", fill=gear, alpha=I(.5),
main="Distribution of Gas Milage", xlab="Miles Per Gallon",
ylab="Density"
)
# Save figure
ggsave("distribution.png", dpi=200)
#==============================================================================
# Biostrings
#
# https://bioconductor.org/packages/release/bioc/html/Biostrings.html
#==============================================================================
library(Biostrings)
# Create random DNA sequence of 10 nucléotides
seq = sample(DNA_ALPHABET[1:4], size=10, replace=TRUE)
seq = paste(seq, collapse="")
seq
#==============================================================================
# Diagram
#
# https://cran.r-project.org/web/packages/diagram/index.html
#==============================================================================
library(diagram)
example(plotweb)
#==============================================================================
# Session info
#==============================================================================
sessionInfo()