Created
March 16, 2017 15:14
-
-
Save andrewbtran/5f251dd7fe3634b2c9bd703beac9b5e2 to your computer and use it in GitHub Desktop.
Generalized code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save the dataframe as a consistent name | |
any_df <- sb | |
# Rename the first column to "Abbrev" | |
colnames(any_df)[1] <- "Abbrev" | |
# Join by the similar name | |
df_adjusted <- left_join(any_df, pop, by="Abbrev") | |
# Do the calculations based on the values in the second column | |
df_adjusted$per_capita <- df_adjusted[,2] / df_adjusted$Population * 100000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment