Lecture 3 R code - mlloyd23/bio211_JAN2018 GitHub Wiki
#Write notes after '#'
#Get Working directory
getwd()
#set working directory; tell R where to find your files
setwd("C:/Users/Melanie/Desktop/biostats 2/My lectures")
#import a data file; assign it to a variable 'data'
data<-read.table("human_phys.txt", header=TRUE)
#Look at the first few lines
head(data)
#what are the dimensions of the variable?
dim(data)
#what kind of variable is 'data'?
class(data)
#Access specific columns in an R data frame with '$'
#name_of_data_frame$name_of_column
data$HR_increase
#assign that column of data to a variable
HR_increase<-data$HR_increase
mean(HR_increase)
var(HR_increase)
sd(HR_increase)
hist(HR_increase)
#Now what about standar error?
std.error(HR_increase)
#We need to access a the plotrix package to use this function
install.packages("plotrix")
library(plotrix)