]> git.donarmstrong.com Git - don.git/blob - posts/introducing_sweavealike.mdwn
clarify deletion review
[don.git] / posts / introducing_sweavealike.mdwn
1 [[!meta title="Introducing Sweavealike"]]
2
3 I use [R](http://www.r-project.org) a lot. It's one of the primary
4 tools I use in my day job as a scientist analyzing large datasets. If
5 you use [LaTeX](http://ctan.org) with R (as I often do), you probably
6 use Sweave to interleave R output and figures with your text
7 describing those figures using the noweb method of literate
8 programming.
9
10 [Sweavealike](http://git.donarmstrong.com/?p=ikiwiki_plugins.git;a=blob;f=sweavealike.pm;hb=HEAD)
11  is a plugin for [IkiWiki](http://ikiwiki.info) that tries
12 to do some of the useful things for IkiWiki that sweave does for R and
13 LaTeX. 
14
15 You use it like the following:
16
17     \[[!sweavealike echo=1 code="""
18     a <- 1
19     a <- a + 10
20     print(a)
21     """]]
22
23 which produces this result when run:
24
25 [[!sweavealike echo=1 code="""
26 a <- 1
27 a <- a + 10
28 print(a)
29 """]]
30
31 You can also generate figures with it:
32
33     \[[!sweavealike fig=1 echo=1 results="hide" code="""
34     plot(1:10,(1:10)^2,xlab="x",ylab=expression(x^2),main="Example Figure")
35     """]]
36
37 [[!sweavealike fig=1 echo=1 results="hide" code="""
38 plot(1:10,(1:10)^2,xlab="x",ylab=expression(x^2),main="Example Figure")
39 """]]
40
41 The plugin itself uses the neat Statistics::R perl module to handle
42 all of the heavy lifting. I personally plan on using this plugin to
43 help write some more entries in my learning R series of posts that I'm
44 beginning to work on. Hopefully I'll find and fix most of the bugs as
45 I embark on that process so anyone else who uses the plugin won't, but
46 feel free to e-mail me if something isn't working as it should.
47
48 Finally, you shouldn't run this plugin on a publicly editable
49 IkiWiki instance, because that would be a trivial local user exploit
50 as R can run arbitrary code, read and write to arbitrary files,
51 exhaust all memory, etc.
52
53 [[!tag ikiwiki debian tech r]]