15-09-2021

  • Use R outside RStudio
  • Use R inside RStudio
    • Set your working directory
  1. How To Update R Studio On Mac
  2. How To Download R And R Studio On Mac
  3. How To Install R Studio On Mac
  4. How To Uninstall R Studio On Mac


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.

Install R and RStudio. Installing R on Mac can be problematic. What I’ve heard from my students is that software dependencies can be a huge problem when installing not just R but also Python, Ruby and more tools. In this document R refers to the core, command-line-based R system while R.app refers to the GUI-based Mac OS application that controls the underlying R. This `R for Mac OS X FAQ' is rather incomplete at the moment and requires contributions from users.

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.

How To Update R Studio On Mac

Under Windows and MAC OSX

For the first time you use R, the suggested procedure, under Windows and MAC OSX, is as follow:

  1. 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.

  2. Launch R by double-clicking on the icon.

  3. Specify your working directory to R:
    • On Windows: File –> Change directory
    • On MAC OSX: Tools –> Change the working directory

Under Linux

  1. Open the shell prompt

  2. Create a working directory, named “R”, using “mkdir” command:



  1. Start the R program with the command “R”:

$ R

  1. To quit R program, use this:

$ q()

Using R inside RStudio is the recommended choice.

How

Launch RStudio under Windows, MAC OSX and Linux

After installing R and RStudio, launch RStudio from your computer “application folders”.

RStudio screen

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.

  1. 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.

  2. Bottom-left panel: R console for typing R commands

  3. 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
  4. 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:


  1. Create a sub-directory named “R” in your “Documents” folder

  2. From RStudio, use the menu to change your working directory under Session > Set Working Directory > Choose Directory.
  3. 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).


Enjoyed this article? I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Twitter, Facebook or Linked In.
Show me some love with the like buttons below... Thank you and please don't forget to share and comment below!!
Avez vous aimé cet article? Je vous serais très reconnaissant si vous aidiez à sa diffusion en l'envoyant par courriel à un ami ou en le partageant sur Twitter, Facebook ou Linked In.
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!



Recommended for You!




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

Data science

  • 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

Trending Courses

  • 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

Our Books

  • 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)

Others

  • 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

How To Download R And R Studio On Mac



Want to Learn More on R Programming and Data Science?
Follow us by EmailOn Social Networks:

How To Install R Studio On Mac


How To Uninstall R Studio On Mac

Get involved :
Click to follow us on Facebook and Google+ :
Comment this article by clicking on 'Discussion' button (top-right position of this page)