String Manipulation
String Basics
- Distinguish between a character and a string.
- Access the upper- and lower-case Roman letters using
letters and LETTERS.
- Recognize and use the whitespace characters
"\n" and "\t" for line breaks and tabs.
- Use
cat to print a string to the console with formatting.
- Create, access, and manipulate vectors, arrays, lists, etc., of strings.
Counting Characters in a String
- Use
nchar to count the number of characters in a string.
- Explain why
length is inappropriate to count the number of characters in a string.
- Use the vectorization capabilities of
nchar to count the number of characters in a vector or array of strings.
Substrings
- Use
substr to access and manipulate substrings in a string.
- Interpret commands involving
substr, including those that involve vectorization and recycling.
- Explain why
[ ] cannot be used to access or manipulate the characters in a string.
Splitting a String
- Use
strsplit to split a string.
- Explain why
strsplit returns a list of character vectors rather than a single character vector.
- Given a string and a desired splitting string, access a given substring returned by
strsplit.
Combining Strings
- Use
paste to join two or more strings with a desired delimiter.
- Interpret commands involving
paste, including those that involve vectorization and recycling.
- Use
paste with vectorization to collapse several strings into a single string.
Reading in and Summarizing Text
- Use
readLines to extract text from an online or offline file.
- Describe the data structure returned by
readLines.
- Perform “reconstitution” to combine a vector of strings into a single string and then split that string based on a delimiter.
- Use
table and reconstitution to count the number of words in a string.
- Explain the structure of
table in terms of names and counts.
- Use an output from
table to query for the number of times a given substring appears in a string.