- No authority
- Official reference is writing r extentions (joke extentions)
- If you thought writing regular r packages was tricky, hold on
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
#include <iostream> | |
#include <boost/shared_ptr.hpp> | |
#include <gdal/ogrsf_frmts.h> | |
#include <geos_c.h> | |
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | |
#include <CGAL/Polygon_with_holes_2.h> | |
#include <CGAL/create_straight_skeleton_from_polygon_with_holes_2.h> | |
typedef CGAL::Exact_predicates_inexact_constructions_kernel K ; |
This is certainly not the intended purpose of mapedit
, but I thought it would be fun to use some accumulated R knowledge to use mapedit
and leaflet
to edit an igraph
layout. To run the code, make sure to run the edit_map
and Shiny
parts separately.
library(igraph)
library(leaflet)
library(mapedit)
karate <- graph.famous("Zachary")
igrf_layout <- layout.auto(karate)
d3r
aims to make d3.js
easy in R. Here is an example of combining d3.quadtree
with base graphics in R using the new d3_v8()
function.
# d3.quadtree example
library(d3r)
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
############################################ | |
### Extract NSIDC geotiff data to points ### | |
############################################ | |
#Many thanks to mdsumner for help with this: | |
#https://github.com/mdsumner/extractNSIDC/blob/master/extract_script.R | |
#Load libraries | |
require(tidyverse) | |
require(lubridate) |
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
mk_name <- function(name=NULL) { | |
v <- as.character(packageVersion('rayrender')) | |
dir <- file.path('~', 'Downloads', 'rr-tests') | |
if(is.null(name)) { | |
name <- sprintf( 'a_%s.png', format(Sys.time(), "%Y-%m-%d_%H%M%S")) | |
} else { | |
name <- sprintf('%s.png', name) | |
} | |
file.path(dir, v, name) | |
} |
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
#include <Rcpp.h> | |
using namespace Rcpp; | |
// turmite function to be called from R | |
// [[Rcpp::export]] | |
NumericMatrix flame(int iter, int layers) { | |
NumericMatrix points(iter, 3); // initially zero | |
NumericMatrix coeffs(9, layers); | |
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(rgl) | |
pan3d <- function(button, dev = rgl.cur(), subscene = currentSubscene3d(dev)) { | |
start <- list() | |
begin <- function(x, y) { | |
activeSubscene <- par3d("activeSubscene", dev = dev) | |
start$listeners <<- par3d("listeners", dev = dev, subscene = activeSubscene) | |
for (sub in start$listeners) { |
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(rgl) | |
sl <- shapelist3d(cube3d(alpha = 1, | |
color = 'grey90', | |
specular = 'black', | |
lit = TRUE), | |
plot = FALSE) | |
create_next_level <- function(sl, level) { | |
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
MIT Licensed. Copyright (c) 2021 [email protected] | |
Share and Enjoy. | |
## Introduction | |
This code was a personal challenge to write a simple ray-tracer in pure R. | |
Ray tracing is an example of something which is really silly to do in base R, | |
and I'd be interested to see how others would approach this problem. |
OlderNewer