:ext QuasiQuotes import qualified H.Prelude as H H.initialize H.defaultConfig -- print output [rprint| lm(mpg ~ wt, data = mtcars) |] -- plot stuff -- we just require ggplot2 as we do everything directly in R [rgraph| require(ggplot2) ggplot(diamonds, aes(carat, price)) + geom_point() + theme(aspect.ratio = 1) |] [rprint| fact <- function(n) if(n == 0) 1 else n * fact(n - 1) fact(10) |] [rprint| fact(10) |] [r| fact <<- function(n) if(n == 0) 1 else n * fact(n - 1) |] [rprint| fact(25) |] -- a Haskell list xs = [1..10] :: [Double] xs [rprint| mean(xs_hs) |] import Data.Int fact :: Int32 -> Int32 fact 0 = 1 fact n = n * fact (n - 1) factR x = return $ fact x :: H.R s Int32 n = 6 :: Int32 [rprint| factR_hs(n_hs) |] get_normals :: Double -> H.R s [Double] get_normals n = do H.dynSEXP <$> [r| rnorm(n_hs) |] result <- H.runRegion $ get_normals 4 result :t result