0% found this document useful (0 votes)
11 views

R Studio Notes

This document provides an overview of the key sections and functions of R Studio. It describes the four quadrants of R Studio - the coding, console, environment, and tabs sections. It then explains how to create R projects, import data files into projects, and view data using basic functions like head(), tail(), and View(). The document also covers installing and loading packages, using the pipe operator, and manipulating data through functions like select(), filter(), and arrange(). Finally, it provides steps for importing Excel files into R projects.

Uploaded by

Sidd Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

R Studio Notes

This document provides an overview of the key sections and functions of R Studio. It describes the four quadrants of R Studio - the coding, console, environment, and tabs sections. It then explains how to create R projects, import data files into projects, and view data using basic functions like head(), tail(), and View(). The document also covers installing and loading packages, using the pipe operator, and manipulating data through functions like select(), filter(), and arrange(). Finally, it provides steps for importing Excel files into R projects.

Uploaded by

Sidd Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

R Studio Notes

1. R Studios Overview – Four Quadrants


a. Coding Section: Upper Left-Hand Quadrant
i. Place where code is written
b. Console/Output Section: Lower Left-hand Quadrant
i. Place where output of code in ULHQ is located
c. Environment Section: Upper Right-Hand Quadrant
i. Place where “objects”/variables are located
d. Tabs Section: Lower Right-Hand Quadrant
i. Consists of Files, Plots, Packages, Help, and Viewer Tabs
e. Zoom Commands
i. Shift + Ctrl + 1 = ULHQ
ii. Shift + Ctrl + 2 = URHQ
iii. Shift + Ctrl + 0 = Zooms Out
2. Creating a Project
a. Coding Section, click “Create New Project” button
b. Click “New Directory”
c. Click “New Project”, and type in name (will appear in Tabs section in “Files” tab)
i. On Windows, you will see the Project under “Documents”
3. Importing Data into a Project
a. Download CSV File onto Computer. Drag CSV File from “Downloads” to “Documents”, where
the R Project will be located. Make sure to put the CSV file in the R Project folder of interest.
b. Data will now be listed in Tabs section in R (note has NOT been imported yet, it is just
recognized by R.)
c. To import data into R/manipulate it, data can be assigned to an object. Assigning Data to an
“Object” : my_data <- read.csv(“filename.csv”).
d. Press ctrl + enter  object will show up in the Environment Section, ready to be
manipulated!
4. Viewing Data - Basic R Functions (NOTE: R is “caps” sensitive so type functions in exactly as they are
written below!)
a. In Coding Section:
i. head(my_data) = shows first six rows of data
ii. tail(my_data) = shows last six rows of data
iii. View(my_data) = turns data into spreadsheet into Coding Section
iv. my_data[Row,Column] = shows specific data in a given row and column
1. example 1: my_data[1,3], which stands for row 1 and column 3 gives the
value in that specific row and column intersection
2. example 2: my_data[ ,3], which stands for all of column 3 (due to lack of
specific row), gives values all the way down column 3
5. Installing Packages
a. install.packages(“packagename”)  installs package. Only need to download once.
i. Example: install.packages(“tidyverse”)
b. library(“packagename”) or require(“packagename”)  runs package
i. example: library(“tidyverse”) or require(“tidyverse”)
6. “Pipe-Operator” Function
a. “Pipe-Operator” Function = %>%
i. Function of this code is to string data from a previous line in the Coding Section to a
subsequent line

ii.
7. Manipulating Data – Basic R Functions
a. Using “Pipe-Operator” Function:
i. my_data %>%, press enter
ii. select(Column Name 1, Column Name 2, Column Name 3, etc), press ctrl + enter):
includes only selected named columns
iii. filter (Column Name < Value & Column Name > Value): Includes column values with
only those ranges of values
iv. arrange(Column Name): arranges spreadsheet by specific column
8. Importing Data from Excel into R Studio
a. Download Excel File, drag it to Documents Folder under Project of interest
b. Excel File will show up under Tabs Section
c. Click on .xlsx file, will give option for “import dataset”
d. Once you click “import dataset”, will see the following screen
e.
i. Data Preview shows the spreadsheet in preview form. You can change the variable
type of the column by clicking the drop-down arrow
ii.

iii. In “Import Options”,


1. Name: can change the name of the dataset under Name
2. Sheet: Default is the first sheet in the excel file, but can change the sheet
important with the drop-down arrows

3. Range: Maximum Number of Rows (can edit, leaving it as is will import max
rows)
4. Skip: Will skip designated amount of rows (example: “2” will skip first two
rows)
5. First Row as Names: R will automatically use the first row as the name of the
column unless specified otherwise by unclicking
6. Open Data Viewer: will open data immediately after importing it
7. NA: input specific value from excel will rename it as NA in the imported file
iv. To Import Excel Sheet into R, click the clipboard icon, then press cancel. Once back
in R studios, in the Coding Section, paste the code
1. NOTE: If you haven’t already, making sure to download and run (library or
require readxl)  library(readxl) or require(readxl)

You might also like