If you are reading this, then you may not need much intro about what R is. But still, it deserves a mention about it’s history.. And without reinventing anything, here is what wikipedia says about R (Ref: https://en.wikipedia.org/wiki/R_(programming_language) )
The R language is widely used among statisticians and data miners for developing statistical software and data analysis. R is an implementation of the S programming language combined with lexical scoping semantics inspired by Scheme. S was created by John Chambers while at Bell Labs. R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, and is currently developed by the R Development Core Team, of which Chambers is a member. R is named partly after the first names of the first two R authors and partly as a play on the name of S.
First things first, how do you get help in R if you know the function name?
?median
help("median") #gives same output as below
This will give you below output in your help window:
Object Summaries
Description
summary is a generic function used to produce result summaries of the results of various model fitting functions. The function invokes particular methods which depend on the class of the first argument………
example("median") #gives an example of the function - Output of example command is shown below for your ref.
##
## median> median(1:4) # = 2.5 [even number]
## [1] 2.5
##
## median> median(c(1:3, 100, 1000)) # = 3 [odd, robust]
## [1] 3
R is very simple to use, for example you can type this directly and expect the answer, just like a calculator:
2+2 # returns 4
## [1] 4
print(2+2) #same as above
## [1] 4
You may also want to try the other operators:
3*4
## [1] 12
4-2
## [1] 2
6/2
## [1] 3
Assign variables & few other basic commands. After running this code, I recommend you to read this discussion on Assignment operators in R: ‘=’ and ‘<-’ (Link: http://stackoverflow.com/questions/1741820/assignment-operators-in-r-and)
var <- 20 #assigned 10 to a variable named var
var
## [1] 20
var1 <- 10
var1
## [1] 10
var+var1
## [1] 30
var-var1
## [1] 10
var*var1
## [1] 200
var/var1
## [1] 2
x = var/7
x
## [1] 2.857143
round( x, digits = 2 ) #note the difference in output of x and this rounded value!
## [1] 2.86