#Example 1 #Check the working directory getwd() #Set the working directory setwd("C:/Users/RRWHITE/Documents") #Read in the csv you just created f <- read.csv("FeedData.csv") #Print the dataframe d f #Summarize the dataframe d summary(f) #Convert the data from wide to long format library(reshape2) f <- melt(f, id=c("Treatment", "Animal.ID")) f #Rename columns in f names(f) <- c("Treatment", "Animal.ID", "Period", "DMI") f #Merge f and m f <- merge(f, m, by=c("Treatment", "Animal.ID", "Period")) f #Make some calculations in f f$dDMI <- f$Dig/100 * f$DMI f #Visualize the data library(ggplot2) ggplot(f, aes(x=Period, y=dDMI, fill=Treatment))+geom_boxplot() ggplot(f, aes(x=dDMI))+geom_density() #Example vectorized conditional f$c_dDMI <- ifelse(f$dDMI < 8, 8, f$dDMI) f