1/35
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
= or <-
used to assign something to a variable or object name
#
Use to add comments to your code (this is extremely useful, especially when you are first learning a coding language.
str()
provides the structure of an object, meaning it will show the object’s value as well as its class
c()
stands for concatenate or combine, this combines objects to form a vector
$
allows you to access the different columns within a data frame
-
removes whatever you put after it from the object
:
allows you to access a sequence of entries from an object
head()
displays the first 6 rows of a data set
[ ]
this is the notion used to index elements in a list
vectorname[#]
use to access elements in a certain position for a vector
Data Frames
allows you to combine multiple vectors together and create a data frame with a certain number of rows and columns
datasetname[#,#]
because data frames possess two dimensions, you must use at least two values separated by a comma to pull specific entries; [rows,columns]
seq()
allows you to make a vector that follows a certain pattern from a starting point
rep()
this can be used to repeat a vector, a number, or just an object a certain number of times
data.frame()
allows you to combine multiple vectors and create a data frame with a certain number of rows and columns
+
This is the notion in R for addition, which can be used to add two vectors together or add a number to a vector.
^
exponentiation operator, it is used to raise a number to a power
*
this is the notion in R for multiplication, can be used to multiply a number to a vector
The console
Bottom-left corner, where code is run. Generally, don’t write much code here because the code is not saved for later use.
The environmental pane
Top-right corner, find objects you have made and their values and properties (structure).
Broom
In the environment, it is very important. clicking the icon will sweep away all your objects and get rid of them forever.
File/Help Pane
Bottom-right corner, files, where plots will pop up when code is ran, where list of installed packages will be, help on functions when writing codes.
The Script
Top-left corner. Where we spend most of our time. Where we write code because it saves, send code to the console.
list()
joins objects into a list
Objects
Data structure with attributes: things that take values.
Classes
The types of objects and determine how the objects’ values are saved.
Strings vector
Text vector, character
What are comments for?
Are used to explain what a line of code is doing, either to remind yourself for later or to tell someone else what your code is doing if you are sending your code.
data[2]
This is accessing the element in the 2nd position in the data vector
data[c(1,4,6)]
This allows you to access more than one element in a given position in the data vector that is not in a sequence. So, in this case, the numbers in the 1st, 4th, and 6th positions.
data[-c(2,3,5,7)]
This is using the negative sign and the c() function which means we are removing more than one element that is not a sequence. So, for this part, the elements in the 2nd, 3rd, 5th, and 7th elements are removed.
typeof()
outputs the type of variable that the object is
Collection
A group of things that we’re considering all together. The objects inside my grocery cart, for example. form a collection. The students in the class form a collection.
Elements
things inside of a collection. grocery collection has eggs, lettuce, milk which are all elements.
Homogeneous
every element into the same category. Homogenous diet.
Heterogeneous
Elements can fall into different categories. Varied diet.