Skip to content

Instantly share code, notes, and snippets.

@bmpvieira
Last active August 29, 2015 14:08
Show Gist options
  • Save bmpvieira/86d846603a57c5311586 to your computer and use it in GitHub Desktop.
Save bmpvieira/86d846603a57c5311586 to your computer and use it in GitHub Desktop.
getCountryAgainstElevation <- function(genus) {
table1 <- read.csv('http://bmpvieira.github.io/temp/alabamaants-myrmicinaepheidole_obscurithorax.csv', h=T)
table2 <- read.csv('http://bmpvieira.github.io/temp/allantwebants-myrmicinaesolenopsis_invicta.csv', h=T)
mergedtable <- # put code here to merge table1 and table2
# Once you have the merged table:
# 1. Subset the table to a new one with only the rows that match the Genus provided by the argument of the function
# 2. Use the function table() to get Country against Elevation
# e.g., something like table(countryColumn, elevationColumn)
# 3. return the resulting table
# The output should look like this:
#
# -53 5 11 20 62 100 145
# 0 0 0 0 0 0 0
# Brazil 0 0 0 0 0 0 0
# Paraguay 0 0 0 0 2 0 0
# U.S.A. 12 0 1 0 0 0 0
# United States 0 11 0 17 0 5 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment