Skip to content

Instantly share code, notes, and snippets.

View davan690's full-sized avatar
💭
I may be slow to respond.

Anthony R Davidson davan690

💭
I may be slow to respond.
View GitHub Profile
@davan690
davan690 / rmd_yaml_variation1.yaml
Last active June 16, 2019 11:21 — forked from jennybc/yaml_frontmatter_r_github_document.yaml
YAML frontmatter for R Markdown to cause rmarkdown::render() to retain intermediate Markdown file for .R and .Rmd files, respectively
---
type: post
title: "Data Wrangling"
subtitle: "For Stoat control in Beech forest paper"
author: "Anthony Davidson"
date: '2019-05-16'
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
@davan690
davan690 / scrape-rviews.R
Created July 11, 2019 23:00 — forked from yihui/scrape-rviews.R
The R script I used to scrape the old RViews site (WordPress)
library(xml2)
page_post_links = function(
page = 1, baseurl = 'https://www.rstudio.com/rviews',
xpath = '//h2[@class="entry-title"]/a'
) {
html = read_html(sprintf('%s/page/%d/', baseurl, page))
xml_attr(xml_find_all(html, xpath), 'href')
}
## Curated stuff:
## * MetaCran: http://www.r-pkg.org/
## * List of Packages gathered by Garret G.: https://github.com/rstudio/RStartHere
## * List of popular packages https://awesome-r.com/
## * List of DataScience R tutorials https://github.com/ujjwalkarn/DataScienceR
## * List of machine elearning tutorials by subject: https://ujjwalkarn.github.io/Machine-Learning-Tutorials/
## Reproducible package management for R:
install.packages("devtools")
install.packages("tidyverse")
@davan690
davan690 / character2factor.r
Created August 21, 2019 07:11 — forked from ramhiser/character2factor.r
Convert all character columns to factors using dplyr in R
library(dplyr)
iris_char <- iris %>%
mutate(Species=as.character(Species),
char_column=sample(letters[1:5], nrow(iris), replace=TRUE))
sum(sapply(iris_char, is.character)) # 2
iris_factor <- iris_char %>%
mutate_if(sapply(iris_char, is.character), as.factor)
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species char_column
# "numeric" "numeric" "numeric" "numeric" "character" "character"
@davan690
davan690 / .RProfile
Created October 28, 2019 05:41
key-config-files
RPROJ <- list(PROJHOME = getwd())
attach(RPROJ)
cat("sourcing Project-specific .Rprofile\n")
cat('retrieve the top-level Project directory at any time with PROJHOME or via get("PROJHOME", "RPROJ"):\n',
get("PROJHOME", "RPROJ"), "\n")
rm(RPROJ)
@davan690
davan690 / .nojekyll
Created October 28, 2019 05:42
.nojekyll
.
@davan690
davan690 / _bookdown.ymal
Created October 28, 2019 05:46
A general template ymal config for bookdown
book_filename: "anova-book"
language:
ui:
chapter_name: " "
output_dir: "docs"
rmd_files: ["index.Rmd","01-outcome.Rmd","02-survey-design.Rmd","01-intro.Rmd","07-outcome.Rmd", "06-references.Rmd"]
delete_merged_file: true
@davan690
davan690 / _output.yaml
Created October 28, 2019 05:47
A general template _output yaml file for bookdown
bookdown::gitbook:
css: style.css
config:
toc:
before: |
<li><a href="./">Simple tests for seed and mouse dynamics</a></li>
after: |
<li><a href="https://github.com/davan690/simple-anova-beech" target="blank">Published with bookdown</a></li>
download: ["pdf", "epub", "docx"]
bookdown::pdf_book:
@davan690
davan690 / README-templates.md
Last active October 28, 2019 05:52 — forked from PurpleBooth/README-Template.md
A templates to make goods of README.mds

A collection of README.md templates for projects in R, Ruby and Markdown

@davan690
davan690 / paths_local_gist
Created January 2, 2020 23:00
a quick script to set location of R library to local program files library
myPaths <- .libPaths("C:/Program Files/R/R-3.6.2/library")
myPaths <- c(myPaths)
.libPaths(myPaths) # add new path
.libPaths()