Skip to content

Instantly share code, notes, and snippets.

View muschellij2's full-sized avatar

John Muschelli muschellij2

View GitHub Profile
@muschellij2
muschellij2 / rgl_tryout.Rmd
Created October 30, 2018 03:01
Example of 3D Image using RGL and misc3d
---
title: "RGL Example"
author: "John Muschelli"
date: "10/29/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@muschellij2
muschellij2 / mime_type_extensions.R
Last active October 22, 2018 14:30
Mime Helpers
library(rvest)
library(dplyr)
library(tidyr)
url = "https://www.freeformatter.com/mime-types-list.html"
doc = read_html(url)
#############################
# Read in the table
@muschellij2
muschellij2 / mime_type_extensions.R
Created October 22, 2018 02:18
Mime Type Extensions
library(rvest)
library(dplyr)
library(tidyr)
url = "https://www.freeformatter.com/mime-types-list.html"
doc = read_html(url)
#############################
# Read in the table
@muschellij2
muschellij2 / mime_type_extensions.R
Last active October 22, 2018 01:34
Gathering extensions for mime_types
library(rvest)
library(dplyr)
library(tidyr)
url = "https://www.freeformatter.com/mime-types-list.html"
doc = read_html(url)
#############################
# Read in the table
@muschellij2
muschellij2 / Add_to_rows.R
Created September 26, 2018 14:56
Adding to Rows in #rstats faster with transposition.
n = 1e5
p = 500
x = matrix(rnorm(n * p),
nrow = n, ncol = p)
z = rnorm(p)
xx = x
f1 = function() {
for (i in 1:nrow(x)) {
xx[i,] = x[i,] + z
}
@muschellij2
muschellij2 / test_blurring.R
Created August 15, 2018 18:55
Blurring in R versus Scipy
library(reticulate)
library(AnalyzeFMRI)
library(neurobase)
sc <- reticulate::import("scipy")
np <- reticulate::import("numpy")
set.seed(1)
dims = rep(80, 3)
man = list.files(path = "man", full.names = TRUE)
library(tools)
ll = lapply(man, function(x) {
o = tempfile(fileext = ".R")
tools::Rd2ex(x, out = o)
if (file.exists(o)) {
return(readLines(o))
}
return("")
})
@muschellij2
muschellij2 / each_example_coverage.R
Created July 17, 2018 22:42
Coverage for each example file
library(dplyr)
library(covr)
library(tidyr)
library(desc)
library(purrr)
library(devtools)
# get package name
desc = desc::desc(file = "DESCRIPTION")
package_name = desc$get("Package")
@muschellij2
muschellij2 / cds_consistency.R
Created May 9, 2018 19:28
Consistency checks for CDS classes
library(didactr)
library(pdftools)
library(dplyr)
library(httr)
library(googledrive)
library(broom)
library(tidyr)
n_pdf_pages = function(file) {
if (length(file) == 0) {
return(NA)
@muschellij2
muschellij2 / NAMESPACE_R_Packages.Rmd
Created March 12, 2018 18:33
NAMESPACE questions with R packges
## Initial Question
From my understanding, there are three general ways to replace "library" statements in R packages:
1. List all packages on which our package relies in the "Imports" section of the DESCRIPTION file, and use the "@imports" statement in the NAMESPACE file to attach these packages to R.
2. List all packages on which our package relies in the "Imports" section of the DESCRIPTION file, and use package::function in our R code whenever we want to call a function from another package. For example, if we wanted to use the mutate() function from dplyr, we would write: dplyr::mutate().
3. List all packages on which our package relies in the "Depends" section of the DESCRIPTION file.
## Answer
I combo option 1 and 2 and heavily suggest not using option 3: