07/06, 2022
usethis::use_git() # set your credentials if you must gitcreds::gitcreds_set() # if you dont have a pat you can use usethis::create_github_token() # if you need add your PAT usethis::edit_r_environ() # generate your readme usethis::use_readme_rmd() # Edit and upload to git usethis::use_github()
Variables:
# Title ## subtitle *cursive* **bold** [link](https://stackoverflow.com/users/3808018/derek-corcoran)
Inline
05:00
Get the template in this link
At its most basic you just need to do:
DT::datatable(Species)
# Extensions to reorder columns and to add buttons
Test <- DT::datatable(Species, extensions = c('Buttons', 'ColReorder'),
caption = 'Species abundances and explaining variables.',
## You can filter the data on top
filter = "top",
## https://datatables.net/reference/option/dom
options = list(dom = 'Blfrtip',
## you can reorder columns
colReorder = TRUE,
## You can scroll de table
scrollX='400px',
scrollY='200px',
## you can download or take away variables
buttons = c('copy', 'csv', 'excel', I('colvis')),
### how long you can make tables
lengthMenu = list(c(10,25,50,-1),
c(10,25,50,"All"))))
# round the digits of these columns
Test %>%
formatRound(columns = c("lon", "lat", "bio_1",
"bio_2", "bio_3", "bio_4", "bio_5", "bio_6",
"bio_7", "bio_8", "bio_9", "bio_10", "bio_11",
"bio_12", "bio_13", "bio_14", "bio_15", "bio_16",
"bio_17", "bio_18", "bio_19", "abund_sp1",
"abund_sp2", "abund_sp4"), digits = 3)
Species2 <- Species %>%
pivot_longer(cols = abund_sp1:abund_sp4, names_to = "Species",
values_to = "Abundance") %>%
mutate(Species = str_remove_all(Species, "abund_"),
Species = str_replace_all(Species, "sp", "Spp "))
G <- ggplot(Species2, aes(x = bio_12, y = Abundance)) +
geom_point(aes(color = Species)) + geom_smooth(aes(color = Species)) +
theme_bw()
ggplotly(G)
library(gapminder)
df <- gapminder
fig <- df %>%
plot_ly(x = ~gdpPercap, y = ~lifeExp, size = ~pop,
color = ~continent, frame = ~year, text = ~country,
hoverinfo = "text", type = "scatter", mode = "markers")
fig <- fig %>%
layout(xaxis = list(type = "log"))
fig
leaflet(data = Species) %>%
addTiles() %>%
addCircles(lng = ~lon, lat = ~lat)
sd <- SharedData$new(Species2)
crosstalk::filter_checkbox("Species", "Species", sd,
~Species)
crosstalk::filter_slider("Abundance", "Abundance",
sd, ~Abundance, step = 10, round = T, min = min(Species2$Abundance),
max = max(Species2$Abundance))
Lets see in this link
Check the template in this link and:
## ---- read-dataset --------
Species <- read_csv("https://raw.githubusercontent.com/derek-corcoran-barrios/OikosRepoducibleResearch/master/Species.csv")
## ---- species2 --------
Species2 <- Species %>%
pivot_longer(cols = abund_sp1:abund_sp4, names_to = "Species",
values_to = "Abundance") %>%
mutate(Species = str_remove_all(Species, "abund_"),
Species = str_replace_all(Species, "sp", "Spp "))
ReusableChunks.R has the chunks needed to run the codeknitr::read_chunk("ReusableChunks.R")
ReuseDocument.Rmd and ReusableChunks.R, to include models, and predictionsReuseDocument.Rmd to get the crossreference of the figure to work