Download & Install R, RStudio, Anaconda on Mac or Windows
What is Anaconda?
Anaconda free open source is distributing both Python and R programming language. Anaconda is widely used in the scientific community and data scientist to carry out Machine Learning project or data analysis.
Why use Anaconda?
Anaconda will help you to manage all the libraries required for Python, or R. Anaconda will install all the required libraries and IDE into one single folder to simplify package management. Otherwise, you would need to install them separately.
Step 1: Install Anaconda
Step 2 : Install R
- Step 1) Open the Anaconda command prompt
- Step 2) In the command prompt
- Enter the R install command
- Environment will be determined
- List of packages to be installed will be listed
- Step 3) Enter y and hit the return key to start installation
- Step 4) Installation will take time, and you will get done message.
R Tutorial: Installation of R
Let me guide you through the process of installing R on your system. Just follow the below steps:
Step 1 : Go to the link- https://cran.r-project.org/
Step 2 : Download and install R 3.3.3 on your system.
Refer to the below screenshot to get a better understanding.
By following the above steps, you are done with the R installation part. Now, you can directly start coding in R by downloading RStudio IDE. To download this, follow the below steps:
Step 1: Go to the link- https://www.rstudio.com/
You can download the Windows installer version of R from https://cran.r-project.org/bin/windows/base/ and save it in a local directory.
As it is a Windows installer (.exe) with a name “R-version-win.exe”. You can just double click and run the installer accepting the default settings. If your Windows is 32-bit version, it installs the 32-bit version. But if your windows is 64-bit, then it installs both the 32-bit and 64-bit versions.
After installation you can locate the icon to run the Program in a directory structure “R\R3.2.2\bin\i386\Rgui.exe” under the Windows Program Files. Clicking this icon brings up the R-GUI which is the R console to do R Programming.
Best and Simple way to Install Python and R both on Jupyter Notebook
- Step 1: Download & Install Python 3
- Step 2: pip install jupyter
- Step 3: Download & Install R
- Step 4: Installing via CRAN
- install.packages(‘IRkernel’)
- Setp 5: Making the kernel available to Jupyter
- IRkernel::installspec()
- IRkernel::installspec(user = FALSE)
print("Hello World")
[1] "Hello World"
# This is an example of Single Line Comment
Basics types
- Logical :: TRUE, FALSE
- Numeric :: 12.3, 5, 999
- Integer :: 2L, 34L, 0L
- Complex :: 3 + 2i
- Character :: ‘a’ , ‘”good”, “TRUE”, ‘23.4’
- Raw :: “Hello” is stored as 48 65 6c 6c 6f
3.15 is a decimal value called numerics. 4 is a natural value called integers. Integers are also numerics. TRUE or FALSE is a Boolean value called logical. The value inside ” ” or ‘ ‘ are text (string). They are called characters.
First way to declare a variable: use the <-
name_of_variable <- value
Second way to declare a variable: use the =
name_of_variable = value
Print Data Type of a Variable – class()
# Numeric
x <- 28
print(x)
class(x)
[1] 28
# Numeric
x = 28
print(x)
class(x)
[1] 28
# String
y <- "Itronix Solutions"
print(y)
class(y)
[1] "Itronix Solutions"
# Boolean
z <- TRUE
print(z)
class(z)
[1] TRUE
# Complex
v <- 2+5i
print(v)
print(class(v))
[1] 2+5i [1] "complex"
# Raw
v <- charToRaw("Hello")
print(v)
print(class(v))
[1] 48 65 6c 6c 6f [1] "raw"
print(ls())
[1] "a" "v" "x" "y" "z"
a="hello"
print(a)
rm(a)
print(a)
[1] "hello"
Error in print(a): object 'a' not found Traceback: 1. print(a)
# We can use the print() function
print("Hello World!")
# Quotes can be suppressed in the output
print("Hello World!", quote = FALSE)
# If there are more than 1 item, we can concatenate using paste()
print(paste("How","are","you?"))
[1] "Hello World!" [1] Hello World! [1] "How are you?"
typeof(5)
typeof(45.L)
typeof('Itronix')
typeof(TRUE)
typeof(3+2i)
a=readline()
print(a)
hello [1] "hello"
a=readline(prompt="Enter name: ")
print(a)
print(class(a))
typeof(a)
Enter name: Itronix Solutions [1] "Itronix Solutions" [1] "character"
a=readline(prompt="Enter Integer: ")
b=readline(prompt="Enter Float: ")
c=readline(prompt="Enter String: ")
typeof(a)
typeof(b)
typeof(c)
Enter Integer: 34 Enter Float: 3.643 Enter String: Itronix Solutions
a=readline(prompt="Enter Integer: ")
a=as.integer(a)
print(a)
typeof(a)
Enter Integer: 34 [1] 34
a=as.integer(readline(prompt="Enter Integer: "))
print(a)
typeof(a)
Enter Integer: 12121 [1] 12121