Week 2 Notes
Week 2 Notes Comm106
Popular in Communication Research Methods
Popular in Communication Studies
verified elite notetaker
This 2 page Class Notes was uploaded by Erica Evans on Thursday January 14, 2016. The Class Notes belongs to Comm106 at Stanford University taught by Jennifer Pan in Fall 2016. Since its upload, it has received 13 views. For similar materials see Communication Research Methods in Communication Studies at Stanford University.
Reviews for Week 2 Notes
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 01/14/16
Comm106 Class 3 1/13/2015 Use R as a calculator • In R, spacing doesn’t matter • Order of operations applies • Press enter to find the result • Examples: • 5+5 • 5-‐5 • 5*5 • 5/5 • sqrt(5) • log(5) Look up a function • type a question mark before the function to get an explanation of it • Ex: type ?log() to figure out what the log() function does Create a new r script • Fileà new file à r script • Press run (or command enter) to get code into the console • To send all the code at once, highlight the code • The console does not get saved, but the R script is saved like a document Type ‘#’ to write notes Objects • R stores information as objects. Once you make objects, you want to refer to them by that name. • <-‐ is the assignment operator • You can assign values to certain objects • Or a string of characters using quotation marks • If you reassign a new value to the same object name, the original object will be overwritten • Object names are case sensitive • Object names cannot start with a number, but they can include a number • Object names cannot include space • Object names can include periods or underscores Functions • ls() this function shows you all the objects in your environment • class() shows you what class that object is: is it a number, string, function etc? Vectors • Vectors are one dimensional lists of information • c() creates the vector • name the vector by typing: vector_name <-‐ c( “element”, “element2”, “element3”, “etc”) • Every element in the vector is separated by a comma • Put quotations around the elements in the vector, otherwise R will think they are each objects • You can combine vectors into a new vector with the c() function as well • Find certain ordered elements of a vector with square brackets. Ex: vector • Find two elements of a vector with Ex: vector[c(1,9)] • Remove an element of a vector with negative numbers Ex: vector[-‐4]
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'