Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
@dlebauer
dlebauer / merge_covariates.R
Created February 4, 2015 15:53
Code that can be used to join specific managements types from tables. (originally written for extracting Krista's soil C flux data)
traits <- data.table(db.query("select * from traitsview;", con))
### return only soil respiration data entered by Moein
ghgtraits <- traits[trait %in% c("Rsoil_annual", "Rsoil_het_annual", "R_root_fine_annual", "Soil Het Respiration ", "Soil Respiration", "soil_respiration_m2"),]
# keycols <- c("site_id", "treatment_id", "scientificname", "citation_id", "date")
# setkeyv(ghgtraits, keycols)
#
# x <- ghgtraits[,interaction(site_id, treatment_id, scientificname, citation_id, date)]
# x <- ghgtraits[,.SD, by = list()]
setkey(entity, id)
@dlebauer
dlebauer / feng_luquillo.csv
Last active August 29, 2015 14:15
Field measurements from Xiaohui Feng to be uploaded to BETYdb; species records have been added and columns with NA have been removed.
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 15 columns, instead of 3 in line 7.
citation_author,citation_year,citation_title,species,site,treatment,year,month,day,SLA,leafP,leafN,leafC,c2n_leaf,access_level
Xiaohui Feng,2015,Luquillo census field data,Micropholis garciniifolia,Luquillo,Observations,1992,6,15,5.767714286,0.032078849,1.84,45.98,24.98913043,4
Xiaohui Feng,2015,Luquillo census field data,Ocotea moschata,Luquillo,Observations,1990,8,30,6.683,0.045924224,1.6395,49.0955,29.94541019,4
Xiaohui Feng,2015,Luquillo census field data,Rheedia portoricensis,Luquillo,Observations,1992,6,22,7.215833333,0.042370331,1.7025,49.6575,29.16740088,4
Xiaohui Feng,2015,Luquillo census field data,Ocotea spathulata,Luquillo,Observations,1992,6,22,7.297285714,0.13125,2.02,43.25,21.41089109,4
Xiaohui Feng,2015,Luquillo census field data,Matayba domingensis,Luquillo,Observations,1990,8,28,7.317,0.046564296,1.9855,45.1055,22.71745152,4
Xiaohui Feng,2015,Luquillo census field data,Cyrilla racemiflora,Luquillo,Observations,1990,12,5,7.963625,0.031024672,1.9,48.3,25.42105263,4
Xiaohui Feng,2015,Luquillo c
@dlebauer
dlebauer / miscanthus.csv
Created February 20, 2015 21:41
example miscanthus data
yields.id genus species sitename lat lon fertilizer_n irrigated planting_year year stand_age planting_density yield
971 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 0 TRUE 1999 1999 0 10000 1.495
972 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 50 TRUE 1999 1999 0 10000 1.573
973 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 100 TRUE 1999 1999 0 10000 1.644
974 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 150 TRUE 1999 1999 0 10000 1.508
975 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 200 TRUE 1999 1999 0 10000 1.56
976 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 0 TRUE 1999 2000 1 10000 6.56
977 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 50 TRUE 1999 2000 1 10000 7.04
978 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 100 TRUE 1999 2000 1 10000 7.17
979 Miscanthus Miscanthus x giganteus Selcuk University 37.86 32.48 150 TRUE 1999 2000 1 10000 6.58
trait_description variable units mean sd date
Leaf Percent Nitrogen leafN percent 2.48 1.07 2019-08-26
Specific Leaf Area SLA m2 kg-1 15.3 8.86 2019-08-26
maximum rubisco carboxylation capacity Vcmax umol CO2 m-2 s-1 64.5 48 2019-08-26
Leaf Area Index LAI m2 leaf m-2 ground 3.96 2.95 2019-08-26
rate of fine root respiration at reference soil temperature
@dlebauer
dlebauer / compile_doxygen.R
Created March 10, 2015 17:08
functions for compiling Doxygen for an R package
## Code provided by Corentin M. Barbu
## http://stackoverflow.com/a/28678741/513006
library("testthat")
library("devtools")
#' @title Replace a value for a given tag on file in memory
#' @description Scan the lines and change the value for the named tag if one line has this tag,
#' add a line at the end if no line has this tag and return a warning if several lines
#' matching the tag
yields.id genus species lat lon fertilizer_n planting_date planting_density year yield irrigated
971 Miscanthus Miscanthus x giganteus 37.86 32.48 0 1999 10000 1999 1.495 TRUE
972 Miscanthus Miscanthus x giganteus 37.86 32.48 50 1999 10000 1999 1.573 TRUE
973 Miscanthus Miscanthus x giganteus 37.86 32.48 100 1999 10000 1999 1.644 TRUE
974 Miscanthus Miscanthus x giganteus 37.86 32.48 150 1999 10000 1999 1.508 TRUE
975 Miscanthus Miscanthus x giganteus 37.86 32.48 200 1999 10000 1999 1.56 TRUE
976 Miscanthus Miscanthus x giganteus 37.86 32.48 0 1999 10000 2000 6.56 TRUE
977 Miscanthus Miscanthus x giganteus 37.86 32.48 50 1999 10000 2000 7.04 TRUE
978 Miscanthus Miscanthus x giganteus 37.86 32.48 100 1999 10000 2000 7.17 TRUE
979 Miscanthus Miscanthus x giganteus 37.86 32.48 150 1999 10000 2000 6.58 TRUE
citation_author citation_year citation_title cultivar species site treatment date rhizome_biomass root_biomass_area_SE root_biomass_area_n leaf_biomass_area stem_biomass root_biomass_area notes
rosenthal 2012 60444 Manihot esculenta SoyFace Ambient CO2
This file has been truncated, but you can view the full file.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<style>
.red { background-color: red }
.orange { background-color: orange }
.green { background-color: #19A319 }
.gray { background-color: gray }
@dlebauer
dlebauer / invalid_geom.sql
Last active August 29, 2015 14:17
invalid geom
select ST_isvalid(
ST_SetSRID (
ST_MakePolygon (
ST_GeomFromText (
'LINESTRING(-90.9112091064453 39.8377532958984 219.834060668945,
-87.9547500610352 38.8522682189941 136.305511474609,
-87.6338958740234 39.1731262207031 134.396545410156,
-87.5765991210938 39.0642623901367 131.822998046875,
-90.9112091064453 39.8377532958984 219.834060668945)'
)
@dlebauer
dlebauer / Midwest_boundary.csv
Created March 19, 2015 21:49
Boundary of Midwest
latitude longitude
49.369439 -95.126467
49.35317 -95.058404
49.356405 -95.014415
49.368897 -94.988908
49.370186 -94.957465
49.350176 -94.909273
49.308834 -94.824291
49.197791 -94.797527
49.120733 -94.773223