Strings Flashcards

1
Q

toupper(vector_argument)

A
  • Function that makes all the letters of the entries to upper case.
  • Use with strings.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

tolower(vector_argument)

A
  • Function that makes all the letters of the entries to lower case.
  • Use with strings.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

gsub(“thing_to_remove”, “thing_to_replace_with”, what_I_want_to_remove_it_from)

A
  • A function that performs “global” substitutions.
  • Will substitute every occurrence of something.
  • | (vertical bar) is “or” in a gsub().
  • \s is interpreted as white space.
  • \s+ means one or more occurrences of white spaces.
  • \s+$ does \s+ matches to the end of the lines.
  • =! means “not equal to”.
  • ^\s+ does \s+ for spaces before the name.
  • KNOW HOW TO REPLACE A COMA AND A DOLLAR SIGN (gsub(“\$|,”,”“,money) will strip all $ and , from money).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Regular Expression

A
  • Provides a concise + flexible way to specify or recognize strings.
  • Its main purpose is to search, and maybe, replace.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

na.rm = TRUE

A
  • An option when using function mean() to remove all missing values so that the resulting mean is not NA.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

grep()

A
  • Function used to search strings and match patterns.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

grepl()

A
  • Function used to search strings and matching patterns and will indicate whether it found the pattern in the string.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

nchar()

A
  • Function that counts the number of characters in a string, which includes spaces.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

paste()

A
  • Function that creates longer strings from shorter ones.
  • Useful for making variable names.
  • Clearest application of the recycling rule.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

strsplit()

A
  • Function that splits strings according to a specific “split”.
  • Outputs a list.
  • Need to use unlist to convert this list to a vector.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

which(object_name, %in% “word_we_want”)

A
  • Function that acts a locator for something in a vector and returns the indexes of where the occurrences happen.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly