Skip to Main Content

Learn R

This guide focuses on transformation and cleaning functions in R that are especially useful for working with tabular datasets.

Common Operators


One of the most important operators in R because this is the equivalent of a help button. When used in combination with a function, such as “?read.csv”, a webpage on the CRAN will open explaining what the function does, what its arguments are, and what are some associated functions.


This operator assigns the value on the right side to that of the left, so “five<-5” means that the numerical value 5 is assigned to the character value of five. Therefore, inputting “five+5” would result in 10. 


To access one variable in a dataset, use the dollar sign “$”. For example, $vote1 returns the vote1 variable (the vote1 column).


All information put between quotation marks must be literal because R will search for those exact characters.


You might find this operator in at the start of a command line in CRAN files or any descriptions of R functions. This tells R not to run that line and to move on to the next, so it is a way to provide line-by-line commentary without interrupting R’s ability to run the script.



As seen in the vector example on the previous page, c(), which stands for concatenate, will combine its arguments, both numbers and words, into a vector.


Another form of concatenation used typically in writing long scripts which span multiple lines, so rather than R interpreting each new line as a new command, it reads it all as one single command.


A boolean (meaning there are two possible values, true or false) operator which ensures that the values on the left side are the exact same as the values on the right, i.e., 5==5 would be true and 5==9 would be false.

Liaison Librarian

Profile Photo
Martin Morris
Schulich Library of Physical Sciences, Life Sciences and Engineering
Macdonald-Stewart Library Building
809 rue Sherbrooke Ouest
Montréal, Québec H3A 0C1
(514) 398 8140
Website Skype Contact: martinatmcgill
Social: Twitter Page

McGill LibraryQuestions? Ask us!
Privacy notice