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:
answer <- 7/9 + sin(2)
answer
## [1] 1.687075
num <- 2
text_me <- "chester"
happy <- "very happy"
Name <- "billy"
name <- "bernie"
nAme <- "Barack"
answer_squared <- answer^2
answer_squared
## [1] 2.846223
we can add italics by surrounding the word by a single underscore: italics
we could also surround the word by a singl asterisk to give the same result italic
to bold a word or give it strong emhasis we surround it with two unerscores or two asterisk: bolded or bolded
we can out both italics and emphasis together: both italics and bold.
Lastly, we can strikethrough a ohrase by using two tildes: strikethrough this sentence
next, we will add a link to Chester Ismay’s webpage. Here is the link
let’s create a grocery list:
we can also create an ordered lost using numbers.
If we forgot that we need to start heating up food before we make breakfast, we can add it into the list
Here is an example of text with only a line break.
You may expect this line to appear in a new paragraph but it doesn’t.
horizontal line above
Reproducible research is the idea that data analyses, and more generally, scientific claims, are published with their data and software code so that others may verify the findings and build upon them. - Roger Peng
Equations: \(y=mx+b\)
count20 <- 1:20
Count100_by_5 <- seq(from = 5, to = 100, by = 5)
Count100_by_5
## [1] 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85
## [18] 90 95 100
prod <- count20 * Count100_by_5
prod
## [1] 5 20 45 80 125 180 245 320 405 500 605 720 845 980
## [15] 1125 1280 1445 1620 1805 2000
multiplying 7 by 14 gives us the result of 98.
The value of one_value is less than 10.
You can also embed plots, for example:
download.file(url = "http://ismayc.github.io/periodic-table-data.csv",
destfile = "periodic-table-data.csv")
periodic_table <- read.csv("periodic-table-data.csv",
stringsAsFactors = FALSE)
str(periodic_table)
## 'data.frame': 118 obs. of 22 variables:
## $ atomic_number : int 1 2 3 4 5 6 7 8 9 10 ...
## $ symbol : chr "H" "He" "Li" "Be" ...
## $ name : chr "Hydrogen" "Helium" "Lithium" "Beryllium" ...
## $ name_origin : chr "composed of the Greek elements hydro- and -gen meaning 'water-forming'" "the Greek helios, 'sun'" "the Greek lithos, 'stone'" "beryl, a mineral" ...
## $ group : int 1 18 1 2 13 14 15 16 17 18 ...
## $ period : int 1 1 2 2 2 2 2 2 2 2 ...
## $ block : chr "s" "s" "s" "s" ...
## $ state_at_stp : chr "Gas" "Gas" "Solid" "Solid" ...
## $ occurrence : chr "Primordial" "Primordial" "Primordial" "Primordial" ...
## $ description : chr "Non-metal" "Noble gas" "Alkali metal" "Alkaline earth metal" ...
## $ atomic_weight : num 1.01 4 6.94 9.01 10.81 ...
## $ aw_uncertainty : int NA 2 NA 5 NA NA NA NA 6 6 ...
## $ any_stable_nuclides: chr "Yes" "Yes" "Yes" "Yes" ...
## $ density : num 8.99e-05 1.78e-04 5.34e-01 1.85 2.34 ...
## $ density_predicted : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ melting_point : num 14.01 0.956 453.69 1560 2349 ...
## $ mp_predicted : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ boiling_point : num 20.28 4.22 1560 2742 4200 ...
## $ bp_predicted : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ heat_capacity : num 14.3 5.19 3.58 1.82 1.03 ...
## $ electronegativity : num 2.2 NA 0.98 1.57 2.04 2.55 3.04 3.44 3.98 NA ...
## $ abundance : num 1.40e+03 8.00e-03 2.00e+01 2.80 1.00e+01 2.00e+02 1.90e+01 4.61e+05 5.85e+02 5.00e-03 ...
periodic_table$name[10:20]
## [1] "Neon" "Sodium" "Magnesium" "Aluminium" "Silicon"
## [6] "Phosphorus" "Sulfur" "Chlorine" "Argon" "Potassium"
## [11] "Calcium"
periodic_table[41:50, c(1, 2, 4)]
## atomic_number symbol
## 41 41 Nb
## 42 42 Mo
## 43 43 Tc
## 44 44 Ru
## 45 45 Rh
## 46 46 Pd
## 47 47 Ag
## 48 48 Cd
## 49 49 In
## 50 50 Sn
## name_origin
## 41 Niobe, daughter of king Tantalus from Greek mythology
## 42 the Greek molybdos meaning 'lead'
## 43 the Greek tekhn??tos meaning 'artificial'
## 44 Ruthenia, the New Latin name for Russia
## 45 the Greek rhodos, meaning 'rose coloured'
## 46 the then recently discovered asteroid Pallas, considered a planet at the time
## 47 English word (argentum in Latin)
## 48 the New Latin cadmia, from King Kadmos
## 49 indigo
## 50 English word (stannum in Latin)
periodic_table[(periodic_table$name %in% c("Hydrogen", "Oxygen")),
c("atomic_weight", "state_at_stp")]
## atomic_weight state_at_stp
## 1 1.008235 Gas
## 8 15.999000 Gas
friend_names <- c("Bertha", "Herbert", "Alice", "Nathaniel")
friend_names
## [1] "Bertha" "Herbert" "Alice" "Nathaniel"
friend_ages <- c(25L, 37L, 22L, 30L)
friend_ages
## [1] 25 37 22 30
class(friend_names)
## [1] "character"
class(friend_ages)
## [1] "integer"
periodic_table$block <- factor(periodic_table$block,
levels = c("s", "p", "d", "f"))
table(periodic_table$block)
##
## s p d f
## 14 36 40 28
friends <- data.frame(names = friend_names,
ages = friend_ages,
stringsAsFactors = FALSE)
friends
## names ages
## 1 Bertha 25
## 2 Herbert 37
## 3 Alice 22
## 4 Nathaniel 30
friend_names[1:3]
## [1] "Bertha" "Herbert" "Alice"
friend_names[c(1,3)]
## [1] "Bertha" "Alice"
friend_names[-c(2, 4)]
## [1] "Bertha" "Alice"
friend_names[c(TRUE, FALSE, TRUE, FALSE)]
## [1] "Bertha" "Alice"
friend_names == "Bertha"
## [1] TRUE FALSE FALSE FALSE
friend_names[friend_names %in% c("Bertha", "Alice")]
## [1] "Bertha" "Alice"
sequence_by_2 <- seq(from = 0L, to = 100L, by = 2L)
sequence_by_2
## [1] 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32
## [18] 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66
## [35] 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100
class(sequence_by_2)
## [1] "integer"
dec_frac_seq <- seq(from = 10, to = 3, by = -0.2)
dec_frac_seq
## [1] 10.0 9.8 9.6 9.4 9.2 9.0 8.8 8.6 8.4 8.2 8.0 7.8 7.6 7.4
## [15] 7.2 7.0 6.8 6.6 6.4 6.2 6.0 5.8 5.6 5.4 5.2 5.0 4.8 4.6
## [29] 4.4 4.2 4.0 3.8 3.6 3.4 3.2 3.0
class(dec_frac_seq)
## [1] "numeric"
ages_numeric <- c(25L, 37L, 22L, 30L)
five_years_older <- ages_numeric + 5L
five_years_older
## [1] 30 42 27 35
##Functions
seq()
## [1] 1
ages_numeric
## [1] 25 37 22 30
mean( x = ages_numeric)
## [1] 28.5
mean(ages_numeric, na.rm = TRUE)
## [1] 28.5
mean(ages_numeric, na.rm = TRUE)
## [1] 28.5
comments