14. Spelling/punctuation
• Dave ≠ dave
• comma quotation – ,” –≠
quotation comma – “,
Object names are
letters, numbers and the
dot or underline
characters and start with
a letter or the dot not
followed by a number
• Dave
• Dave.one
• Dave_one
15. Spelling/punctuation
• Dave ≠ dave
• comma quotation – ,” – ≠
quotation comma – “,
Object names are
letters, numbers and the
dot or underline
characters and start with
a letter or the dot not
followed by a number
• Dave
• Dave.one
• Dave_one
Comments begin with
hashtag, are never
executed, but are
important
• #This is a comment
Use “assignment”
operator <- (left arrow
and dash) not =
• As in a <- b, which means
“b replaces a”
RScripts help
reproduction, so save
them within your project
16.
17.
18. Numeric – Decimal numbers in R.The default
computational data type (e.g., 24.54).
Integer – Whole numbers in R (e.g., 24).
Character – Used to represent string of values
in R. Arithmetic operations are not
possible (e.g., “david”, “245” can’t be added).
19. Factor – Small number of integers with
corresponding character values used when
factor is displayed.
Logical – Returned based on the “truth” of a
statement (eitherTRUE or FALSE).
20. class (objectname)
Returns the data type of the object
If the object, dd, is numeric, then the command,
class(dd)
returns “numeric”
If the object, bb, is character, the the command
Class(bb)
returns “character”
21. typeof(objectname)
Returns the data type of the object
If the object, dd, is numeric, then the command,
typeof(dd)
returns “numeric”
If the object, bb, is character, the the command
typeof(bb)
returns “character”
22. Object dd to integer as new object dd1.
• dd1 <- as.integer(dd)
• class(dd1) will show “integer”.
Object dd to a character as new object dd2.
• dd2 <- as.character(dd)
• class(dd2) will show “character”.
Object dd to numeric as new object dd2.
• dd3 <- as.character(dd)
• class(dd2) will show “numeric”.