R Programming

How to Start Using (pgf)Sweave in LyX in One Minute

October 30, 2010 | Yihui Xie

regor Gorjanc published an interesting article “Using Sweave with LyX” in R News in 2008, which (I believe) makes it much easier to use Sweave. I use command-line tools a lot every day, but I am still “GUI-addicted”. (I don’t want to comment more about Microsoft Word here.) LyX is ... [Read more...]

On the Gory Loops in R

October 17, 2010 | Yihui Xie

his blog post is mainly for Stat 579 students on the homework for week 7, since I received too many “gory” loops in the homework submissions and I think it would help a bit to write my thoughts on R loops for beginners. The immortal motto for newbies in programming is: If ... [Read more...]

A Slider to Control Two Plotting Windows

September 28, 2010 | Yihui Xie

One of my readers asked two weeks ago how to control two graphics windows with the slider in gWidgets. Here is a simple example: if (!require("gWidgetsRGtk2")) install.packages("gWidgetsRGtk2") library(gWidgetsRGtk2) options(guiToolkit = "RGtk2") graphics.off() x11() x11() dev.set() gslider(from = 1, to = 100, value = 10,     container = gwindow("Two Plotting Windows"), ... [Read more...]

formatR: farewell to ugly R code

April 13, 2010 | Yihui Xie

It is not uncommon to see messy R code which is almost not human-readable like this: # rotation of the word "Animation" # in a loop; change the angle and color # step by step for (i in 1:360) { # redraw the plot again and again plot(1,ann=FALSE,type="n",axes=FALSE) # rotate; use ... [Read more...]

Demonstrating the Power of F Test with gWidgets

April 2, 2010 | Yihui Xie

e know the real distribution of the F statistic in linear models — it is a non-central F distribution. Under H0, we have a central F distribution. Given 1 – α, we can compute the probability of (correctly) rejecting H0. I created a simple demo to illustrate how the power changes as other parameters ... [Read more...]

Looking for Software Paths in Windows Registry

March 28, 2010 | Yihui Xie

hen we want to call external programs in R under Windows, we often need to know the paths of these programs. For instance, we may want to know where ImageMagick is installed, as we need the convert (convert.exe) utility to convert images to other formats, or where OpenBUGS is ... [Read more...]

R Tips in Stat 511

March 22, 2010 | Yihui Xie

Here are some (trivial) R tips in the course Stat 511. I’ll update this post till the semester is over. Formatting R Code Reading code is pain, but the well-formatted code might alleviate the pain a little bit. The function tidy.source() in the animation package can help us format ... [Read more...]

Press Enter in LyX Sweave as You Wish

February 18, 2010 | Yihui Xie

or a long time I’ve been wondering why we are not able to use Enter in the LyX Scrap environment which was set up by Gregor Gorjanc for Sweave. Two weeks ago, I (finally!) could not help asking Gregor about this issue, as I’m using “LyX + Sweave” more ...
[Read more...]

hash-1.99.x

February 17, 2010 | Christopher Brown

hash-2.0.0 has been released please read about it here: Earlier today, hash-1.99.x was released to CRAN. This is a stable release and adds some more functions to an already full-featured hash implementation. This version fixes some bugs, adds some features, improves performance and stability. You can read about the ... [Read more...]

“Introducing Monte Carlo Methods with R” is out!

December 9, 2009 | xi'an

That’s it!, “Introducing Monte Carlo Methods with R” is out, truly out, I have received a copy from Springer by express mail today! (If you need any further proof, it is also advertised as In stock by Amazon.) Given that the printer exactly reproduces the pdf file sent to ...
[Read more...]

Create Animations in PDF Documents Using R

November 11, 2009 | Yihui Xie

ince animation 1.0-9, we will be able to create a PDF document with an animation embedded in it; the function is saveLatex(), and its usage is similar to saveMovie() and saveSWF(): you pass an R expression for creating animations to this function, and this expression will be evaluated in the ... [Read more...]

How to Import MS Excel Data into R

September 26, 2009 | Yihui Xie

s Sir Francis Bacon said, “Histories make men wise; poets witty; the mathematics subtile; natural philosophy deep; moral grave; logic and rhetoric able to contend.” And Windows stupid. He should have added the last sentence if he were a Windows user in this age. 1. Avoid Using M$ Excel A lot ... [Read more...]

Formatting Decimals in Texts with R

August 30, 2009 | Yihui Xie

anping Chen raised a question in the Chinese COS forum on the output of Eviews: how to (re)format the decimal coefficients in equations as text output? For example, we want to round the numbers in CC = 16.5547557654 + 0.0173022117998*PP + 0.216234040485 * PP(-1) + 0.810182697599 * (WP + WG) to the 3rd decimal places. [...] [Read more...]

Simulation of Burning Fire in R

June 11, 2009 | Yihui Xie

inlin Yan posted a cool (hot?) simulation of burning fire with R in the COS forum yesterday, which was indeed a warm welcome. I’m not sure whether our forum members will be scared by the “fire” under the title “Welcome to COS Forum”. The fire was mainly created by ... [Read more...]

Design Flaws in R #2 — Dropped Dimensions

August 19, 2008 | Radford Neal

In a comment on my first post on design flaws in the R language, Longhai remarked that he has encountered problems as a result of R’s default behaviour of dropping a dimension of a matrix when you select only one row/column from that dimension. This was indeed the ... [Read more...]

Design Flaws in R #1 — Reversing Sequences

August 6, 2008 | Radford Neal

The R language for statistical computing has become the standard for academic statistical research, for the very good reason that it’s better than the alternatives. It’s far from perfect however. I could come up with a long “wish list” of desired features it lacks, but that’s not ... [Read more...]
1 2

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)