Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 26, 2020 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/2cf4b2a760e1ee5ca9aca84f2ed86802 to your computer and use it in GitHub Desktop.
Save codecademydev/2cf4b2a760e1ee5ca9aca84f2ed86802 to your computer and use it in GitHub Desktop.
Codecademy export
---
title: "Standard Deviation"
output: html_notebook
---
```{r message=FALSE, warning=FALSE, error=TRUE}
library(readr)
library(dplyr)
```
```{r error=TRUE}
load("project.Rda")
```
```{r error=TRUE}
# Change these variables to be the standard deviation of each dataset.
# Inspect Data
head(london_data)
print (nrow(london_data))
temp <- london_data$TemperatureC
# Variance and SD for the year
average_temp <- mean(temp)
print(average_temp)
temperature_var <- var (temp)
print(temperature_var)
temperature_standard_deviation <- sd(temp)
print(temperature_standard_deviation)
#Inspect once again
head(london_data)
tail(london_data)
# Get monthly temperature average
june <- london_data %>%
filter(month == '06')
june
july <- london_data %>%
filter(month == '07')
print(mean(june$TemperatureC))
print(mean(july$TemperatureC))
# Analyze by month
sd(june$TemperatureC)
sd(july$TemperatureC)
monthly_stats <- london_data %>%
group_by(month) %>%
summarise(mean= mean(temperatureC), standard_deviation = sd(temperatureC))
print(monthly_stats)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment