This file contains 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(rvest) | |
library(xml2) | |
library(sf) | |
library(geojsonio) | |
url = "http://www.landxml.org/webapps/landxmlsamples.aspx" | |
url_file = paste0("http://landxml.org/schema/LandXML-2.0/", | |
"samples/Carlson%20Software/nunosurf.xml") | |
xml_file = file.path("~/Downloads", basename(url_file)) | |
if (!file.exists(xml_file)) { |
This file contains 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
#' @title Find matlab path | |
#' | |
#' @description This tries to find matlab's path using a system which | |
#' command, and then, if not found, looks at \code{getOption("matlab.path")}. If not path is found, it fails. | |
#' @export | |
#' @return Character of command for matlab | |
get_matlab = function(){ | |
find.matlab <- system("which matlab", ignore.stdout=TRUE) | |
matcmd <- 'matlab -nodesktop -nosplash -nodisplay -r ' | |
if (find.matlab != 0){ |
This file contains 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
# rm(list=ls()) | |
convert_index <- function(infile="index_original.html", outfile = "index.html"){ | |
trim <- function (x) gsub("^\\s+|\\s+$", "", x) | |
ff <- file(infile) | |
dat <- readLines(ff) | |
close(ff) | |
where.scene <- which(dat == " r0 = new X.renderer('r0');") |
This file contains 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
#!/bin/bash | |
echo "I ran a script" > blah.txt | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends \ | |
file \ | |
git \ | |
libapparmor1 \ | |
libgc1c2 \ |
This file contains 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
better_fetch_pubmed_data = function (pubmed_id_list, retstart = 0, retmax = 500, format = "xml", | |
encoding = "UTF8") | |
{ | |
myIDlist <- pubmed_id_list | |
if ((!is.list(myIDlist)) | is.na(myIDlist$WebEnv) | is.na(myIDlist$QueryKey) | | |
is.na(myIDlist$Count) | !is.integer(as.integer(retstart)) | | |
!is.integer(as.integer(retmax))) { | |
message("There is an issue with the PubMed ID list you supplied. Please, call the function again and supply the result of a <get_pubmed_ids()> call as argument. Thank you.") | |
return(NULL) | |
} |
This file contains 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
old_package_version = function(repos = getOption("repos")) { | |
all_info = vector(mode = "list", length = length(repos)) | |
names(all_info) = repos | |
for (repo in repos) { | |
# taken from remotes:::package_find_archives | |
archive <- tryCatch({ | |
tf <- tempfile(fileext = ".gz") | |
on.exit(unlink(tf), add = TRUE) | |
remotes:::download(tf, sprintf("%s/src/contrib/Meta/archive.rds", | |
repo)) |
This file contains 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
#!/bin/bash | |
# https://gist.github.com/muschellij2/64f9104ccec09deb85d4928071b3c9e8 | |
# set -e | |
# Comment out this line for quieter output: | |
# set -x | |
export cran_set='options(repos = "http://cran.rstudio.com"); ' | |
# we may be able to change to remotes | |
export ig_package=devtools |
This file contains 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
# remotes::install_github('muschellij2/knitr') | |
library(knitr) | |
rmd_to_df = function(file) { | |
x = xfun::read_utf8(file) | |
on.exit(knitr::knit_code$restore(), add = TRUE) | |
res = knitr:::split_file(x, patterns = knitr::all_patterns$md) | |
classes = sapply(res, attr, "class") | |
blocks = res[classes %in% "block"] | |
params = lapply(blocks, function(el) { |
This file contains 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_mat = function(mat) { | |
L = try({ | |
R.matlab::readMat(mat) | |
}) | |
if (!inherits(L, "try-error")) { | |
return(L) | |
} | |
names = rhdf5::h5ls(mat)$name | |
convert_mat_string = function(x) { |
This file contains 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
walk_source <- function( | |
file = NULL, | |
delay = 1.5, | |
clear_each_cmd = TRUE, | |
wait_for_press = TRUE, | |
style = styler::tidyverse_style, | |
record_screen = TRUE, | |
... | |
) { | |
if (record_screen) { |
NewerOlder