Spaces:
Running
Running
File size: 1,481 Bytes
8fe5327 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
library(reactablefmtr)
# import specific functions from relevant libraries
box::use(reactable[reactable, colDef])
box::use(dplyr[filter])
#* @param df the data frame containing the data
#* @param vernacular the vernacular names of the animals
#* @param locality regions in Poland
tableFunction <- function(df, vernacular) {
# set default values if arguments are NULL or empty
if (is.null(vernacular) || vernacular == "") {
vernacular <- "Mandarin Duck"
} else {
vernacular
}
# filter the data based on vernacular and locality
filtered_df <- df |>
filter(vernacularName == vernacular)
# ensure there is data to display
if (nrow(filtered_df) == 0) {
reactable(data.frame(
Message = "No data available for the selected filters"
))
}
# return table
reactable(
filtered_df,
filterable = TRUE,
searchable = TRUE,
striped = TRUE,
highlight = TRUE,
bordered = TRUE,
compact = TRUE,
defaultPageSize = 10,
columns = list(
vernacularName = colDef(name = "Common Name"),
longitudeDecimal = colDef(name = "Longitude"),
latitudeDecimal = colDef(name = "Latitude"),
individualCount = colDef(name = "Count"),
eventDate = colDef(name = "Date"),
locality = colDef(name = "Location")
),
theme = reactableTheme(
highlightColor = "#627cfc",
borderColor = "#1239fe",
borderWidth = 2
)
)
}
|