Skip to content

Commit

Permalink
Include ternary plot
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpelu committed Sep 8, 2023
1 parent d1568b4 commit d124fc3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ library(sf)
library(mapSpain)
library(leaflet)
library(lubridate)
library(ggtern)
library(stringr)


source("R/readAllsheets.R")
source("R/prepareGeo.R")
source("R/preparePopup.R")
source("R/ternaryPlot.R")

hojas_validas <- "data/hojas_oficiales.csv" |> read.csv() |> pull()


Expand Down Expand Up @@ -44,6 +48,11 @@ cards <- list(
full_screen = TRUE,
card_header("Mapa"),
leaflet::leafletOutput("map")
),
card(
full_screen = TRUE,
card_header("Suelos"),
plotOutput("suelos")
)
)

Expand All @@ -68,6 +77,7 @@ ui <- page_navbar(
theme_color = "secondary"
)),
cards[[2]]),
nav_panel("Suelos", cards[[5]]),
nav_panel("Biometria", cards[[3]])
)

Expand Down Expand Up @@ -135,6 +145,19 @@ server <- function(input, output, session) {
xlab("") + ylab("")
})

ternary_data <- reactive({
data()$suelo |>
dplyr::select(limo_g, limo_f, arcilla, arena) |>
mutate(limo = sum(c_across(starts_with("limo"))))
})

output$suelos <- renderPlot({
print(
ternaryPlot(ternary_data(), xvar = "arena", yvar = "arcilla", zvar = "limo", bsize =20)
) # Note that the ggtern need to be plotted in a print environment
})


leaflet_map <- reactive({

coord_data <- st_transform(prepareGeo(data()$datos_generales), 4326)
Expand Down

0 comments on commit d124fc3

Please sign in to comment.