This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(ggtext) | |
| library(openalexR) | |
| library(httr2) | |
| ##### OpenAlex ##### | |
| query_url <- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Finding text pattern in files on Linux | |
| https://stackoverflow.com/questions/16956810 | |
| grep --include=\*.R -rnw '/home/francois/' -e "tidyverse" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe_data_df <- function(x) { | |
| res_1 <- paste0("data is a dataframe with ", ncol(x), " colums", ":") | |
| res_2 <- sapply(x, class) | |
| res_2 <- sapply(1:length(res_2), function(x) { | |
| paste0("- Column ", x, " is named '", names(res_2)[x], "' and is of class ", res_2[x], ".") | |
| }) | |
| res_2 <- paste(res_2, collapse = "\n") | |
| res <- paste(res_1, res_2, sep = "\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Convert vegan specaccum results to tidy format | |
| #' | |
| #' @param x result returned by specaccum | |
| #' | |
| #' @return A data.frame in "long format". | |
| #' | |
| tidy_specaccum <- function(x) { | |
| data.frame( | |
| site = x$sites, | |
| richness = x$richness, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(vegan) | |
| library(tidyverse) | |
| data(varespec) | |
| vare.dist <- vegdist(wisconsin(varespec)) | |
| mds.null <- monoMDS(vare.dist, y = cmdscale(vare.dist)) | |
| mds.alt <- monoMDS(vare.dist) | |
| x <- protest(mds.alt, mds.null) | |
| rot <- x$rotation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Convert vegan rarecurve results to tidy format | |
| #' | |
| #' @param x a list of rarefy results returned by rarecurve | |
| #' @param sites a vector of site names | |
| #' | |
| #' @return A data.frame in "long format". | |
| #' | |
| tidy_rarecurve <- function(x, sites) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| col_bar_v <- function(col, data.min, data.max){ | |
| plot(c(0, 10), c(data.min, data.max), type = "n", bty = "n", xaxt = "n", yaxt = "n", xlab = "", ylab = "") | |
| tk <- pretty(c(data.min, data.max), 7) | |
| tk <- tk[c(-which(tk < data.min), -which(tk > data.max))] | |
| axis(2, las = 1, at = tk, col = NA, col.ticks = 1) | |
| inc <- (data.max - data.min)/ length(col) | |
| for(i in seq(1, length(col))){ | |
| rect(0, data.min + inc * (i- 1), 10, data.min + inc * i, col = col[i], border = NA) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Read and parse "jean.dat" from the Stanford GraphBase (C) 1993 Stanford University | |
| library(tidyverse) | |
| library(stringr) | |
| library(igraph) | |
| library(tidygraph) | |
| jean <- readLines("http://ftp.cs.stanford.edu/pub/sgb/jean.dat") | |
| jean <- jean[!str_detect(jean, "^\\*")] | |
| jean_sep <- which(jean == "") |