R in Five Minutes

by Karl-Kuno Kunze

Become an insideR within five minutes? Here’s how:

First, open the site r-fiddle.org. Delete demo("graphics")

Now your are ready to enter your first commands. On the right of the ‘>’ enter the following and click ‘Run Code’ on the bottom right. The R Fiddle console should now show the same results as below. R Fiddle Output is preceeded by ##.

2 + 2
## [1] 4
cat('Hello World!')
## Hello World!

Define a vector and print it to the screen with:

myVector <- c(1,2,3,4,5,6,7,8,9)
## [1] 1 2 3 4 5 6 7 8 9

Don’t forget to click the button ‘Run Code’ at the bottom right for executing the command.

Now, square the vector with:

myVector2 <- myVector^2
## [1]  1  4  9 16 25 36 49 64 81

And now, let’s go for a plot:

plot(myVector, myVector2)

plot of chunk unnamed-chunk-4

The plot should look like the title graphics. The output of R Fiddle should look like the screenshot below. You can see the plot in R Fiddle on the top right.


Now, you are an R Wizard. Have fun!