Skip to content

Instantly share code, notes, and snippets.

View simon-anders's full-sized avatar

Simon Anders simon-anders

  • University of Heidelberg
  • Heidelberg, Germany
View GitHub Profile
# Swiss roll and Sleepwalk
n <- 10000
# Draw random position on a rectangle
x0 <- runif( n, 0, 2*pi )
y0 <- runif( n, 0, 6*pi )
# Roll up the rectangle to form a Swiss roll
x <- x0 + rnorm( n, 0, .3 )
library( quantreg )
x <- runif( 1000, 0, 10 )
y <- 30*exp(-(x-5)^2) + rnorm(1000) + x*rnorm(1000)
plot( x, y )
fit <- rq( y ~ x + I(x^2), .9 )
xg <- seq( 0, 10, l=1000 )
lines( xg, predict( fit, data.frame( x=xg, `I(x^2)`=xg^2 ) ), col="red" )
@simon-anders
simon-anders / lissajous.R
Created May 15, 2017 09:15
Example for R code to generate a table in HTML with an image by the side that displays a plot about the table row under the mouse cursor
# A sketch on how one can use hwriter to display an image when hovering
# over a table row.
library( hwriter )
# Make a data frame with some parameters or other data
df <- data.frame(
name = sprintf( "Lissajous-%02d", 0:99 ),
freq.x = floor( runif( 100, min=2, max=8 ) ),
freq.y = floor( runif( 100, min=2, max=8 ) ) )