R Language

Nuts and Bolts of R Language!

Bonjour,

  • Basic arithmetic is the same. 1+1 = 2 | 5*6 = 30  and so on
  • Printing a string is just typing in  “Hello, World!”.
  • T and F are short hand for True and False simultaneously. i.e., T == True and F == False
  • To store a value in a variable. You do this : x <- 35
  • You can reassign any value to a variable any time. You can assign a string like this: x <- “Hello DataScience! R lang is awesome”
  • printing the value of x is simple.. Just type x and hit return! That will do the magic.It should print 35 as we assigned it earlier
  • you can assign logical values to the variables too.. Do this: x <- T or x <- True
  • You have a sweet function called sum to add up numbers.. like this sum(2,3,4) gives you 9 as output
  • To repeat a string or a number you can use “rep” function like this rep(“Bonjour”, times = 3)
  • Like everywhere.. there is a function called sqrt to find the square root. sqrt(16) gives 4
  • help(functionname) gives you the function’s documentation and syntax. For ex: help(sum) gives all the details of the function
  • example(functionname) gives you the usage of the function and what arguments are valid for the function
  • One can write the script in a file and can save it with .R extension for later usage and execution
  • list.files() gives you the list of files in the current directory
  • To run a script. We need to use source function and the argument is the file name. like: source(hello.R)

Hmm. That ends the basics of R Language. You’ve learned how to create and access variables, and how to call functions. You’ve learned how to run pre-made scripts. And you’ve learned how to access R’s help functionality when you need it.

Cheers,

SZ

IRC.. Blog… Learning and Programming in R…. Tweeting…. simultaneously! – Nerd Life

Bonjour,

Tonight I am doing something very crazy which I haven’t done since very long time. The title of the blogpost says it all. But yes, I want to make it a habit now. Though I don’t have a beer in my hand right now like Mark did when he was coding, I do have chilled H2O to cheer me up.

Lets get started. I have been going through the courses on codeschool . There are plenty of uber cool courses on it. But many are paid. Some are free and they do let you to download some of their screencasts which is pretty amazing. There are some courses on drive, how to use the drive api for the application development and today I was encountered with the R language tutorials which were sponsored by O’Reilly [hence they are free].

I started with R now. I am going through baby steps right now in R. Learning how to evaluate expressions and logical values in R 😀

More to come!

Cheers,

SZ