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:
Jacks.Equation <- function(a,
b,
c) {
output <- (a * b) - c * 324 + log(a)
return(output)
}
Jacks.Equation
## function(a,
## b,
## c) {
## output <- (a * b) - c * 324 + log(a)
## return(output)
## }
Jacks.Equation(a = 1000,
b = 30,
c = 7)
## [1] 27738.91
data <- c(6, 3, 8, 6, 3, 2, 3, 2, 100)
standardise.me <- function(x) {
output <- c((x - mean(x))/ sd(x))
return(output)
}
standardise.me
## function(x) {
## output <- c((x - mean(x))/ sd(x))
## return(output)
## }
standardise.me(data)
## [1] -0.2740789 -0.3677514 -0.2116305 -0.2740789 -0.3677514 -0.3989756
## [7] -0.3677514 -0.3989756 2.6609937
data1 <- c(1, 1, 9, 3, 2, 1, 1)
how.many <- function(x,
value
) {
output <- length(x[x == value])
return(output)
}
how.many(data1, 1)
## [1] 4
data2 <- c(1, 1, 9, 3, 2, 1, 1)
how.many(data2, -100)
## [1] 0
recode.numeric <- function(x,
lb,
ub) {
x[x < lb] <- NA
x[x > ub] <- NA
output <- x
return(output)}