R Markdown

#summary(cars)

#install.packages("remotes") #Allows R to install functions/packages from other sources

#remotes::install_github("forestgeo/allodb") #directly from GitHub repositories
#install.packages("allodb", repos = c("https://ropensci.r-universe.dev", "https://cloud.r-project.org")
#)
library(allodb) #allometric equations and functions to calculate AGB based on user-provided tree data. #https://forestgeo.si.edu

#data(scbi_stem1) #viewing data
#head(scbi_stem1)
#colnames(scbi_stem1)
#View(scbi_stem1)
#setwd('/Users/stellamarti/Desktop/Hopkins')
#dbh<-read.csv(file = "dbhtestforAGB.csv")

#Tree 1: 1  49.8    Fagus   grandifolia Fagaceae    -76.62  39.33
agb1 <- get_biomass(dbh = 49.8,
  genus = "Fagus",
  species = "grandifolia",
  coords = c(-76.6, 39.3))

#Tree 2: 1  94.1    Liriodendron    tulipifera  Magnoliaceae    -76.62  39.33
agb2 <- get_biomass(dbh = 94.1,
  genus = "Liriodendron",
  species = "tulipifera",
  coords = c(-76.6, 39.3))

#Tree 3: 1  4.4 Fraxinus    Americana   Oleaceae    -76.62  39.33
agb3 <- get_biomass(dbh = 4.4,
  genus = "Fraxinus",
  species = "americana",
  coords = c(-76.6, 39.3))

#Tree 4: 1  14.7    Pinus   strobus Pinaceae    -76.6   39.3
agb4 <- get_biomass(dbh = 14.7,
  genus = "Liriodendron",
  species = "tulipifera",
  coords = c(-76.6, 39.3))

#Tree 5: 1  30.5    Juglans nigra   Juglandaceae    76.62397    39.33
agb5 <- get_biomass(dbh = 30.5,
  genus = "Juglans",
  species = "nigra",
  coords = c(-76.6, 39.3))

##okay that is cool now lets combine this! i think is the next move

total_agb <- agb1 + agb2 + agb3 + agb4 + agb5
agb <- c(agb1, agb2, agb3, agb4, agb5)
dbh <- c(49.8, 94.1, 4.4, 14.7, 30.5)
genus <- c("Fagus", "Liriodendron", "Fraxinus", "Pinus", "Juglans")
species <- c("grandifolia", "tulipifera", "americana", "strobus", "nigra" )

#this code was give to us and I don't need it but want to keep it!
#The get_biomass() function can also be used to estimate the AGB of all trees in one (or several) censuses.
#trees$agb <- get_biomass(
 # dbh = trees$dbh,
 # genus = trees$genus,
 # species = trees$species,
  #coords = c(-76.62, 39.33))

sum(agb)   # Add up total biomass
## [1] 9454.588
plot(
  x = dbh,
  y = agb,
  col = factor(genus),
  xlab = "DBH (cm)",
  ylab = "AGB (kg)") #make a plot