Skip to main content
Social Sci LibreTexts

1. Getting Started

  • Page ID
    33753
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Don't be afraid! You don't have to be a master computer-programmer to work with R; it is very flexible and uses syntax that is simple and intuitive. 

    Where to Get R? 

    To download R, go to www.cran.r-project.org. Click on the link to download for your specific computer.

    clipboard_e69b394147cec3300f922260de99ad062.png

    How do I use R?

    To use R, you will want to use RStudio, an integrated development environment. To download, go to www.rstudio.com/products/rstudio/ and choose "RStudio Desktop". 

    clipboard_e09335176b25a00ee65f463f61257954d.png

    Working RStudio

    There are 4 main components to RStudio: 

    Screen Shot 2019-10-28 at 6.16.26 PM.png

    Source

    The built-in text editor for writing scripts. Always write code in the source panel so that you can save it.

    Console

    Where commands are entered and output is printed.

    Environment & History

    An interactive list of all loaded objects and a list of keystrokes entered into the console.

    Files, Plots, Packages, Help:

    Where you can navigate C drive files, find output for plots, search for and install packages, and output for help commands. 

    Tip:

    Using a darker background and a larger font in RStudio will help reduce eye strain. See the image below for instructions. 

    Screen Shot 2019-10-28 at 6.29.09 PM.png

    Starting a Project

    To start a project, first, you must create a script.

    Screen Shot 2019-10-28 at 6.38.56 PM.png

    Code in R

    After creating a new R script, you will have to write in code to perform the actions you wish to complete your statistical analyses. 

    • To run code in R, type into each line the command/argument you want to run and use command (⌘) + enter. (For PC, use control + enter).
      • Functions are always followed by parentheses. A common mistake is forgetting a close parenthesis!
    • To run multiple lines of code, highlight the section then use command (⌘) + enter.

    Screen Shot 2019-10-09 at 12.06.30 PM.png


    1. Getting Started is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?