- Use R outside RStudio
- Use R inside RStudio
- Set your working directory
So to get to R studio you need to go to WWW.RSTUDIO.COM one word and then just click R studio over here in the bottom and next in this on this page just scroll down and download R studio desktop so it's a free software just as R is free.
After installing R and RStudio, the question is now how to start using R/RStudio. In this article, we’ll describe how to run RStudio and to set up your working directory.
- R-Studio for Mac can first copy the entire disk or its part into an image file and then process the image file. This is especially useful when new bad sectors are constantly appearing on the hard disk, and remaining information must be immediately saved.
- R-Drive Image Hard Disk Backup Software v.4.3 R-Drive Image creates disk image files for backup or duplication purposes. Disk image file contains exact, byte-by-byte copy of a hard drive, partition or logical disk and can be created with various compression levels on the fly without stopping.
- This will start the updating process of your R installation by: “finding the latest R version, downloading it, running the installer, deleting the installation file, copy and updating old packages to the new R installation.” From within RStudio, go to Help Check for Updates to install newer version of RStudio (if available, optional).
Note that, it’s possible to use R outside or inside RStudio. However, we highly recommend to use R inside RStudio. RStudio allows users to run R in a more user-friendly environment.
Under Windows and MAC OSX
For the first time you use R, the suggested procedure, under Windows and MAC OSX, is as follow:
Create a sub-directory, say R, in your “Documents” folder. This sub-folder, also known as working directory, will be used by R to read and save files.
Launch R by double-clicking on the icon.
- Specify your working directory to R:
- On Windows: File –> Change directory
- On MAC OSX: Tools –> Change the working directory
Open the shell prompt
Create a working directory, named “R”, using “mkdir” command:
- Start the R program with the command “R”:
- To quit R program, use this:
Using R inside RStudio is the recommended choice.
Launch RStudio under Windows, MAC OSX and Linux
After installing R and RStudio, launch RStudio from your computer “application folders”.
RStudio is a four pane work-space for 1) creating file containing R script, 2) typing R commands, 3) viewing command histories, 4) viewing plots and more.
Top-left panel: Code editor allowing you to create and open a file containing R script. The R script is where you keep a record of your work. R script can be created as follow: File –> New –> R Script.
Bottom-left panel: R console for typing R commands
- Top-right panel:
- Workspace tab: shows the list of R objects you created during your R session
- History tab: shows the history of all previous commands
- Bottom-right panel:
- Files tab: show files in your working directory
- Plots tab: show the history of plots you created. From this tab, you can export a plot to a PDF or an image files
- Packages tab: show external R packages available on your system. If checked, the package is loaded in R.
For more about RStudio read the online RStudio documentation.
Set your working directory
Recall that, the working directory is a folder where R reads and saves files.
Change your working directory
You can change your working directory as follow:
Create a sub-directory named “R” in your “Documents” folder
- From RStudio, use the menu to change your working directory under Session > Set Working Directory > Choose Directory.
- Choose the directory you’ve just created in step 1
It’s also possible to use the R function setwd(), which stands for “set working directory”.
For Windows, the command might look like :
Note that, if you want to know your current (or default) R working directory, type the command getwd(), which stands for “get working directory”.
Set a default working directory
A default working directory is a folder where RStudio goes, every time you open it. You can change the default working directory from RStudio menu under: Tools –> Global options –> click on “Browse” to select the default working directory you want.
Each time you close R/RStudio, you will be asked whether you want to save the data from your R session. If you decide to save, the data will be available in future R sessions.
- Previous chapters
- Next chapters
This analysis has been performed using R software (ver. 3.2.3).
Show me some love with the like buttons below... Thank you and please don't forget to share and comment below!!
Montrez-moi un peu d'amour avec les like ci-dessous ... Merci et n'oubliez pas, s'il vous plaît, de partager et de commenter ci-dessous!
R-studio Free Download
Recommended for You!
Download New R Studio For Mac Osx
More books on R and data science
Recommended for you
This section contains best data science and self-development resources to help you on your path.
Coursera - Online Courses and Specialization
- Course: Machine Learning: Master the Fundamentals by Standford
- Specialization: Data Science by Johns Hopkins University
- Specialization: Python for Everybody by University of Michigan
- Courses: Build Skills for a Top Job in any Industry by Coursera
- Specialization: Master Machine Learning Fundamentals by University of Washington
- Specialization: Statistics with R by Duke University
- Specialization: Software Development in R by Johns Hopkins University
- Specialization: Genomic Data Science by Johns Hopkins University
Popular Courses Launched in 2020
- Google IT Automation with Python by Google
- AI for Medicine by deeplearning.ai
- Epidemiology in Public Health Practice by Johns Hopkins University
- AWS Fundamentals by Amazon Web Services
- The Science of Well-Being by Yale University
- Google IT Support Professional by Google
- Python for Everybody by University of Michigan
- IBM Data Science Professional Certificate by IBM
- Business Foundations by University of Pennsylvania
- Introduction to Psychology by Yale University
- Excel Skills for Business by Macquarie University
- Psychological First Aid by Johns Hopkins University
- Graphic Design by Cal Arts
Books - Data Science
- Practical Guide to Cluster Analysis in R by A. Kassambara (Datanovia)
- Practical Guide To Principal Component Methods in R by A. Kassambara (Datanovia)
- Machine Learning Essentials: Practical Guide in R by A. Kassambara (Datanovia)
- R Graphics Essentials for Great Data Visualization by A. Kassambara (Datanovia)
- GGPlot2 Essentials for Great Data Visualization in R by A. Kassambara (Datanovia)
- Network Analysis and Visualization in R by A. Kassambara (Datanovia)
- Practical Statistics in R for Comparing Groups: Numerical Variables by A. Kassambara (Datanovia)
- Inter-Rater Reliability Essentials: Practical Guide in R by A. Kassambara (Datanovia)
- R for Data Science: Import, Tidy, Transform, Visualize, and Model Data by Hadley Wickham & Garrett Grolemund
- Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems by Aurelien Géron
- Practical Statistics for Data Scientists: 50 Essential Concepts by Peter Bruce & Andrew Bruce
- Hands-On Programming with R: Write Your Own Functions And Simulations by Garrett Grolemund & Hadley Wickham
- An Introduction to Statistical Learning: with Applications in R by Gareth James et al.
- Deep Learning with R by François Chollet & J.J. Allaire
- Deep Learning with Python by François Chollet
Want to Learn More on R Programming and Data Science?
Follow us by EmailOn Social Networks:
Click to follow us on Facebook and Google+ :
Comment this article by clicking on 'Discussion' button (top-right position of this page)
When was the last time you update your R and RStudio?
I installed RStudio and R a year ago, and never update it since then. Today I just noticed I cannot install new R packages because of my old R version. So I explore some ways to update R and would like to share with someone who is also looking to update R on RStudio.
RStudio and R cannot update on their own because some packages may not work after switching to the new version (You can still downgrade R version in RStudio if something went wrong though). After you install the new version, the previously installed packages will not go to next version. So it is required extra procedures to move the packages.
Here are 3 ways you can update R version in RStudio. Note that we need to move the install R packages, which I will show how at the end.
3 Solutions to update R on RStudio
Solution 1) Manually install (Recommended if you don't care about the old packages)
The first method is to download a new version of R from R website > CRAN. Then restart your RStudio. The new R version will be loaded automatically.
The new R version appear right after I install R and restart RStudio
Update 29/05/2019: For Mac users, solution 3 is too painful and not working well for me. This method is fast and working well. I would recommend to save your time from headache and use this method. Take note of your previous packages so you can install them again as needed.
Solution 2) Windows only – use installr
installr is the R package which helps install and update software.
The R code you will need for updating R is: (credit goes to Cara Wogsland for the code)
You can find the tutorial on how to use installr to update RStudio on R-Statistics website.
Solution 3) Mac only – use updateR
Similar to installr, updateR is the package to help updating R on Mac OS.
The R code you will need is these 5 lines: (credit goes to jroberayalas for the code)
install.packages('devtools') #assuming it is not already installed
updateR(admin_password = 'Admin user password')
You can find in-depth tutorial on how to use updateR package on this blog.
How to move the previously installed R packages
This is the instructions for Mac OS user (who used solution 1 or 3 above). For Windows user, installr package will do this for you
(credit goes to RyanStochastic and micstr):
1. Move all folders from your old R version to new R version.
Replace x.xx with the old and new R version at a time.
Note that you have to move only the packages that are not currently in the destination folder (because those are the base packages, and you don’t want to ruin them). But if you already did replaced everything, the next step will solve this for you.
If you cannot find the proper path, you can run this command to check: installed.packages()
2. Update the moved packages
Run the following command in R. Type ‘y’ for every question that popped up.
3. Type the following command in R to check if everything went well
R For Mac
That’s it! Hope you guys success in updating R. If not, please check in the reference link below.
Download R Studio For Mac