Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporating a few of the Paraty fixes #30

Open
dsrivast opened this issue Feb 17, 2016 · 0 comments
Open

Incorporating a few of the Paraty fixes #30

dsrivast opened this issue Feb 17, 2016 · 0 comments

Comments

@dsrivast
Copy link

We made a lot of progress at Paraty, it would be nice sometime to have these incorporated into the BWGtools pkg as we now have snippets of code on some papers' R scripts and not others. Only when you have time @aammd !

(1) make site a factor within BWGtools (I need to do it manually outside)
(2) make this summarize code below part of the hydro function, not having it in the function threw me for a loop by creating duplication of rownames (as two leaves per bromeliad) in the final fulldata:
mean_hydro <- hydro %>%
ungroup %>%
select(c(2,7:17, long_dry, long_wet, n_driedout, n_overflow)) %>%
group_by(site_brom.id) %>%
summarise_each(funs(median(., na.rm = TRUE))) %>%
replace_na(list(long_dry = 0, long_wet = 0, n_driedout = 0, n_overflow = 0))

when_last <- hydro %>%
ungroup %>%
select(site_brom.id, last_dry, last_wet) %>%
group_by(site_brom.id) %>%
summarise_each(funs(min(., na.rm = TRUE))) %>%
replace_na(list(last_dry = 65, last_wet = 65))

brom_hydro <- mean_hydro %>% left_join(when_last)

(3) adding this code to summarize the ibutton data, which I think is not yet part of BWGtools:
ibuttons <- combine_tab(sheetname = "bromeliad.ibuttons")
ibutton_data <- ibuttons %>%
group_by(site, site_brom.id) %>%
summarise(mean_max = mean(max.temp, na.rm = TRUE), mean_min = mean(min.temp, na.rm = TRUE),
mean_mean = mean(mean.temp, na.rm = TRUE), sd_max = sd(max.temp, na.rm = TRUE),
sd_min = sd(min.temp, na.rm = TRUE), sd_mean = sd(mean.temp, na.rm = TRUE),
cv_max = 100_(sd_max/mean_max), cv_min = 100_(sd_min/mean_min),
cv_mean = 100*(sd_mean/mean_mean)) %>%
ungroup %>%
gather(variable, observed, 3:11) %>%
replace_na(list(observed = "NA")) %>%
select(-site) %>%
spread(variable, observed, fill = 0) %>%
rename(max_temp = mean_max, min_temp = mean_min, mean_temp = mean_mean,
sd_max_temp = sd_max, sd_min_temp = sd_min, sd_mean_temp = sd_mean,
cv_max_temp = cv_max, cv_min_temp = cv_min, cv_mean_temp = cv_mean)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant