Last active
October 13, 2020 14:39
-
-
Save mutolisp/4898bb2e25a33487385bf5ede8e553da to your computer and use it in GitHub Desktop.
Group calculation of R
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
mountain | aspect | species | cover | r | |
---|---|---|---|---|---|
SEN | W11 | A | 30 | 1 | |
SEN | W11 | B | 10 | 3 | |
SEN | W11 | C | 0.5 | 2 | |
SEN | W13 | A | 15 | 4 | |
SEN | W13 | D | 5 | 3 | |
SEN | W13 | E | 3 | 2 | |
SEN | W13 | F | 0.1 | 1 | |
SEN | W13 | G | 10 | 4 | |
SUN | E11 | A | 15 | 2 | |
SUN | E11 | B | 5 | 3 | |
SUN | E11 | C | 0.5 | 2 | |
SUN | E11 | E | 1 | 4 | |
SUN | S13 | D | 35 | 1 | |
SUN | S13 | E | 10 | 1 | |
SUN | S13 | F | 5 | 2 | |
SUN | S13 | G | 1 | 4 |
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
library(data.table) | |
exampleFile <- 'https://gist.githubusercontent.com/mutolisp/4898bb2e25a33487385bf5ede8e553da/raw/f101cc6e126eb2475d2345377bd02bbee3474799/dummy.csv' | |
dummy <- fread(exampleFile, sep = ',', header = T) | |
# calculate cover summation by mountain and aspect | |
dummy[, sum(cover), by = .(mountain, aspect)] | |
# calculate thermophilization indicator | |
Tsi <- dummy[, sum(cover*r)/sum(cover), by = .(mountain,aspect) ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment