# Lesson 2. What Could be Improved In this R Code?

## Learning Objectives

After completing this tutorial, you will be able to:

## What You Need

You will need a computer with internet access to complete this lesson.

#start my analysis
plot(data)

myData$newcolumn <- mydata$precip * 12 / 2
my.data$newcolumn <- mydata$precip * 12 / 2
my.data$newcolumn <- mydata$precip * 12 / 2
my.data$newcolumn <- mydata$precip * 12 / 2
my.data$newcolumn <- mydata$precip * 12 / 2
plot(mydata)
#export stuff -  i should do this for all of my csv files
write.csv(mydata)

my.data$newcolumn <- mydata$month
#testing some stuff with pipes
outputs <- my.data %>%
mutate(newcolumn = "fredyymack") %>%
group_by(month) %>%
summarise(mean(Precip_MM))

plot(mydata)
#export stuff
write.csv(mydata)

my.data$newcolumn <- mydata$month
#testing some stuff with pipes
outputs <- my.data %>%
mutate(newcolumn = "fredyymack") %>% #i dont think i need this column do i?
group_by(month) %>%
summarise(mean(Precip_MM))

plot(mydata)
#export stuff
write.csv(mydata)

my.data$newcolumn <- mydata$month
#testing some stuff with pipes
outputs2 <- my.data %>%
mutate(newcolumn = "fredyymack") %>%
group_by(month) %>%
summarise(mean(Precip_MM))

plot(mydata)
#export stuff
write.csv(mydata)

#not sure why everything isn't plotting
plot(my.data)
plot(my.data)
plot(mydata)
plot(my.data)
plot(my.data)

#testing some stuff with pipes
my.data %>%
mutate(newcolumn = "fredyymack") %>%
group_by(month) %>%
summarise(mean(Precip_MM))

#testing some stuff with pipes
outputs <- my.data %>%
mutate(newcolumn = "fredyymack") %>%
group_by(month) %>%
summarise(mean(Precip_MM))

ggplot(outputs, aes(y=month, x=precipmm)) +
geom_point()

#need to do this to all of my data
#testing some stuff with pipes
#mydata <- my.data %>%
#  mutate(newcolumn = "fredyymack") %>%
#  group_by(month) %>%
#  summarise(mean(Precip_MM))

#export the data to a csv
write.csv(mydata)

library(dplyr)
library(ggplot2)