This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Working with a variable in R: 1.If the variable was entered on its own (i.e. varname <- c(...)), then you just use the name. 2.If the variable is part of a table with multiple variables in it, then you need both the name of the table and the name of the variable, separated by a “$”, like so: tablename$varname. 3.If you know you're just using one table, you can “attach” the table, so that you don't have to type the table name and the $ all the time. To attach, you type: attach(tablename) and then you can just use the variable name (no “tablename$” necessary!) Of course, when you're done using the table, you need to type: detach(tablename) to be able to use another table this way. Please note: from this point on, I'm assuming that the variable is either entered (1) on its own, or (2) as an attached table. If you have the variable in R as part of a table, but don't want to attach it, just remember to put the table name, followed by the “$”, before any variable name. Also, from here on, I will use “varname” as a place holder for the variable's actual name. Graphing categorical data in R (note: all graphs come up in a separate window) 1.Make your frequency table, making sure it has it's own name: vartable<-table(varname)...
View Full Document
- Summer '11