Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .RData
Binary file not shown.
351 changes: 351 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,351 @@
ls
pwd
ls
x <- 3
print x <- 3
setwd
install.packages("swirl")
library(swirl)
1
swirl (1)
library("swirl")
swirl()
1
swirl()
numeric(0.5, 55, -10, 6)
numeric("0.5, 55, -10, 6")
numeric("0.5", "55", "-10", "6")
num_vect <- numeric("0.5", "55", "-10", "6")
num_vect <- numeric("0.5","55","-10","6")
num_vect <- numeric(0.5, 55, -10, 6)
num_vect <- c(0.5, 55, -10, 6)
swirl()
swirl()
0
tf <- num_vect < 1
print(tf)
tf
num_vect >= 6
my_char <- c("my", "name", "is")
my_char <- c("My", "name", "is")
my_char
paste(my_char, collapse = " ")
my_name <- c(my_char, "Lan")
my_name
paste(my_name, collapse = " ")
paste("Hello", "world!", sep = " ")
paste(num_vect(1:3), c("X", "Y", "Z"), sep = "")
paste(num_vect(1L:3L), c("X", "Y", "Z"), sep = "")
paste(num_vect(1L:3L), c("X", "Y", "Z"), sep = "")
paste(num_vect(1L, 2L, 3L), c("X", "Y", "Z"), sep = "")
paste(c(1L, 2L, 3L), c("X", "Y", "Z"), sep = "")
paste(1:3, c("X", "Y", "Z"), sep = "")
paste(LETTERS, 1:4, sep = "-")
5+7
x <- 5+7
x
y <- x-3
y
0
exit
exit()
c(1.1, 9, 3.14)
z <- c(1.1, 9, 3.14)
?c()
?c
z
c(z, 555)
c(z, 555, z)
z*2+100
my_sqrt <- sqrt
my_sqrt <- sqrt(z-1)
my_sqrt
my_div <- my_sqrt/z
my_div <- z / my_sqrt
my_div
c(1,2,3,4 + 0, 10)
(1, 2, 3, 4) + c(0, 10)
c(1, 2, 3, 4) + c(0, 10)
c(1, 2, 3, 4) + c(0, 10, 100)
c(1, 2, 3, 4) + c(0, 10, 100)
c(1, 2, 3, 4) + c(0, 10, 1000)
z*2+1000
my_char
my_div
sqirl
sqwirl
swirl()
swirl
swirl::main()
swirl::main()
swirl
swirl::swirl()
getwd()
ls()
x <- 9
ls
ls()
dir()
?list.files
args(list.files)
getwd
old.dir <- getwd()
testdir <- dir.create()
testdir <- dir.create(getwd)
testdir <- dir.create(getwd())
dir.create("testdir")
setwd
setwd("testdir")
file.create("mytest.R")
dir()
file.exists()
file.exists("mytest.R")
file.info("mytest.R")
args(file.rename)
file.rename("mytest.R", "mytest2.R")
file.copy("mytest2.R", "mytest3.R")
file.path("mytest3.R")
file.path("mytest3.R", 'folder1', 'folder2')
file.path("folder1", "folder2")
?dir.create
dir.create(file.path ("testdir2", "testdir3"), recursive = recursive = TRUE)
dir.create(file.path ("testdir2", "testdir3"), recursive = TRUE)
setwd
setwd()
setwd(old.dir)
1:20
pi:10
15:1
?`:`
seq(1:20)
seq(1,20)
seq(1,20, by=0.5)
seq(1,10, by=0.5)
seq(0,10, by=0.5)
my_seq <- seq(5, 10, length=30)
length(my_seq)
seq(1:length(my_seq))
1:length(my_seq)
seq(along.with = my_seq)
seq_along(my_seq)
rep(0, times = 40)
rep(c(0, 1, 2), times = 10)
rep(c(0, 1, 2), each = 10)
#a scatter plot of those two variables (time and the amount of cumulative drug release)
setwd("Desktop/Biocomp_tutorial12/")
a = read.table("drug_release.txt", header = T, stringsAsFactors = F, sep = " ")
a = read.table("drug_release.txt", header = T, stringsAsFactors = F, sep = "")
a = read.table("drug_release.txt", header = T, sep = "")
a <- read.table("drug_release.txt", header = T)
a <- read.table("drug_release.txt", header = T, sep = "")
a <- read.table("drug_release.txt", header = T, sep = "", fill = T)
a
a
a
library(ggplot2)
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "", fill = T)
a
library(ggplot2)
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "", fill = T)
a
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "")
a
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
a
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)")
library(ggplot2)
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)")
library(ggplot2)
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_bw()
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_bw()+
theme(axis.text.x = element_text(angle=0, vjust=0.6))
setwd("Desktop/Biocomp_tutorial12/")
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic()
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
setwd("Desktop/Biocomp_tutorial12/")
library(ggplot2)
rm(list = ls())
#1. a scatter plot of those two variables (time and the amount of cumulative drug release)
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
# 2-1 a barplot of the means of the four populations
b <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
b
# 2-1 a barplot of the means of the four populations
b <- read.table("data.txt", header = T, sep = "", stringsAsFactors = F)
b
head(b)
b <- read.table("data.txt", header = T, sep = ",", stringsAsFactors = F)
head(b)
b <- read.table("data.txt", header = T, sep = ",", stringsAsFactors = F)
head(b)
ggplot(b, aes(x = region, y = observations)) +
stat_summary(fun = mean, geom = "bar") +
xlab("region") +
ylab("population") +
theme_classic()
?geom_scatterplot
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm") +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(method="lm",se=FALSE) +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point() +
stat_smooth(se=FALSE) +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point(size = 2) +
stat_smooth(se=FALSE) +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point(size = 3) +
stat_smooth(se=FALSE) +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point(size = 3) +
stat_smooth(se=FALSE) +
xlab("Time (hour)", font = 4) +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point(size = 3) +
stat_smooth(se=FALSE) +
xlab("Time (hour)", font = 10) +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release), font = 12) +
geom_point(size = 3) +
stat_smooth(se=FALSE) +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release, font = 12)) +
geom_point(size = 3) +
stat_smooth(se=FALSE) +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())
ggplot(b, aes(x = region, y = observations)) +
geom_scatterplot()
ggplot(b, aes(x = region, y = observations)) +
geom_jitter()
#2-2 a scatter plot of all of the observations
ggplot(b, aes(x = region, y = observations)) +
geom_jitter(size = 1)
ggplot(b, aes(x = region, y = observations)) +
geom_jitter(size = 1)+
theme_classic()
b <- read.table("data.txt", header = T, sep = ",", stringsAsFactors = F)
head(b)
ggplot(b, aes(x = region, y = observations)) +
stat_summary(fun = mean, geom = "bar") +
xlab("region") +
ylab("population") +
theme_classic()
b <- read.table("data.txt", header = T, sep = ",", stringsAsFactors = F)
head(b)
ggplot(b, aes(x = region, y = observations)) +
stat_summary(fun = mean, geom = "bar") +
xlab("region") +
ylab("population") +
theme_classic()
#2-2 a scatter plot of all of the observations
ggplot(b, aes(x = region, y = observations)) +
geom_jitter(size = 1)+
theme_classic()
31 changes: 31 additions & 0 deletions answer codes_Lan.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
setwd("Desktop/Biocomp_tutorial12/")
library(ggplot2)
rm(list = ls())
#1. a scatter plot of those two variables (time and the amount of cumulative drug release)
a <- read.table("drug_release.txt", header = T, sep = "", stringsAsFactors = F)
head(a)
ggplot(a,aes(x = hours, y = cumulative_drug_release)) +
geom_point(size = 3) +
stat_smooth(method = "loess", se=FALSE) +
xlab("Time (hour)") +
ylab("cumulative drug release (ng)") +
theme_classic() +
theme(legend.title=element_blank())

# 2-1 a barplot of the means of the four populations
b <- read.table("data.txt", header = T, sep = ",", stringsAsFactors = F)
head(b)
ggplot(b, aes(x = region, y = observations)) +
stat_summary(fun = mean, geom = "bar") +
xlab("region") +
ylab("population") +
theme_classic()

#2-2 a scatter plot of all of the observations
ggplot(b, aes(x = region, y = observations)) +
geom_jitter(size = 1)+
theme_classic()

#2-3 Do the bar and scatter plots tell you different stories? Why?
# Yes. Population for all groups seem to be the same in the bar plot but they are slightly different from the scatter plot.
# The reason is that bar plots mainly show the mean values, but less direct for showing the data distribution; instead, scatter plots can directly show the data distribution including outliers, but are hard to see the mean values.
9 changes: 9 additions & 0 deletions drug_release.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hours cumulative_drug_release
0 0
24 565.31
48 990.06
72 1330.44
96 1642.72
120 1870.39
144 2081.28
168 2224.73