This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(yarrr)
## Loading required package: jpeg
## Loading required package: dplyr
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(beanplot)
require(beanplot)
+++ here now +++
# A
x <- rnorm(100, mean = 100, sd = 10)
y <- x + rnorm(100, mean = 20, sd = 20)
x
## [1] 92.66460 102.46348 96.78262 92.23534 112.19286 99.40359 85.60302
## [8] 95.94630 98.89008 101.09260 94.01286 91.76836 116.25819 100.36473
## [15] 105.88279 103.27604 99.89662 106.37429 88.86085 98.38024 99.05075
## [22] 96.07376 80.01162 82.46762 86.96490 109.38879 95.10622 82.20975
## [29] 112.23021 88.42871 96.73067 97.32888 108.96151 102.03100 97.94437
## [36] 109.85728 101.70906 119.28109 89.25859 98.43414 100.83494 82.07022
## [43] 123.36878 121.14532 92.47592 105.08055 85.91407 103.72720 113.13637
## [50] 91.99819 95.25260 81.86964 92.63915 86.81363 99.63643 89.95275
## [57] 109.10437 93.70529 102.02750 116.78436 104.94522 100.73432 91.36302
## [64] 83.48644 97.15278 106.52897 95.16353 94.14947 100.96071 83.74045
## [71] 101.02263 101.74737 92.48485 101.04388 94.57970 99.15485 90.65331
## [78] 102.02790 109.58575 87.17877 116.73828 99.83106 90.03414 86.59814
## [85] 107.45404 112.19252 98.47692 96.34682 109.57363 103.10484 95.95827
## [92] 112.58005 104.15573 110.84794 90.85878 90.87442 97.51983 98.20716
## [99] 118.80560 115.60481
y
## [1] 100.58178 126.04133 117.69816 111.18223 84.04412 72.10042 95.68427
## [8] 107.94221 97.10619 116.99643 53.07600 128.66005 143.09836 110.18982
## [15] 112.96276 125.17067 111.72032 97.03256 129.99642 138.72420 104.71478
## [22] 116.82676 122.93851 70.20308 80.71397 128.71071 129.19643 95.95905
## [29] 140.67243 93.86026 112.84890 153.03089 129.41920 111.26041 119.39587
## [36] 134.77353 98.78702 118.21928 112.41301 106.68142 116.56667 135.23226
## [43] 130.14859 123.03212 110.41308 106.90843 71.78240 128.92005 106.98639
## [50] 120.28114 108.57172 78.98433 115.49132 112.93026 107.25638 109.40659
## [57] 146.67708 98.62860 119.36177 145.62460 124.30546 107.37762 85.69435
## [64] 97.18738 138.13844 104.24550 136.38799 126.56850 83.13455 96.85728
## [71] 134.39209 136.70106 95.45075 116.55870 88.45429 102.02003 121.13224
## [78] 104.40590 151.95087 138.79659 130.19067 121.42373 117.40860 92.55474
## [85] 126.70940 140.98916 129.79174 118.25322 119.09056 106.79902 97.69280
## [92] 154.03681 122.28050 117.96297 108.36268 140.06218 117.08055 122.00741
## [99] 145.25231 113.51888
# B
hist(x = x,
main = "Histogram of x",
xlab = "This is th x-label",
ylab = "Frequency")
# c
hist(x = y,
main = "Histogram of y",
xlab = "This is the x-label",
ylab = "Frequency")
# D
plot(x, y,
main = "This is the title",
xlab = "This is the x-label",
ylab = "This is the y-label")
# E
mean(x)
## [1] 99.16823
mean(y)
## [1] 114.8507
abline(v = (mean(x)), lty = 2)
abline(h = (mean(y)), lty = 2)
colors()[1:10]
## [1] "white" "aliceblue" "antiquewhite" "antiquewhite1"
## [5] "antiquewhite2" "antiquewhite3" "antiquewhite4" "aquamarine"
## [9] "aquamarine1" "aquamarine2"
sample(x = 1:100,
size = 10)
## [1] 27 40 65 80 12 75 71 81 84 82
samp.numbers <- sample(1:657, size = 10)
colors.to.use <- colors()[samp.numbers]
plot(1:10,
col = colors.to.use,
pch = 16,
cex = 2,
xlim = c(0, 11),
ylim = c(0, 11)
)
text(1:10,
1:10,
colors()[samp.numbers],
pos = 3
)
pirates <- read.table(file = “http://nathanieldphillips.com/wp-content/uploads/2015/11/pirates1.txt”, header = T, sep = “”, # tab-delimited stringsAsFactors = F )
boxplot(pirates$sword.time ~ pirates$sword.type,
data = pirates,
xlab = "Swordtype",
ylab = "Sword Swing Time",
main = "Sword swinging time by sword type")
beanplot(pirates$sword.time ~ pirates$sword.type,
data = pirates,
main = "Sword Swinging Time by Sword Type",
xlab = "sword type",
ylab = "sword swing time",
col = "white",
lwd = 1,
what = c(1, 1, 1, 1), log = ""
)
# A
plot(x = 1,
xlab = "Age",
ylab = "Beard Length",
xaxt = "n", yaxt = "n",
type = "n",
xlim = c(0, 50), ylim = c(0, 40),
main = "Here is a plot with gridlines waiting for data!")
abline(v = 10:50,
col = gray(.8))
abline(h = 0:40,
lwd = 1,
col = gray(.8))
# B
points(x = pirates$age[pirates$sex == "male"],
y = pirates$beard.length[pirates$sex == "male"],
pch = 16,
col = "red")
#C
points(x = pirates$age[pirates$sex == "female"],
y = pirates$beard.length[pirates$sex == "female"],
pch = 16,
col = "red")