Exercises
- How can you subset only a single character from
substr()
, e.g. getting the 5th character inhello
? - What happens when you try to subset the 5th character when the string has fewer than 5 characters.
- Is
substr()
vectorized, i.e. if we pass the column as a vector as the first argument, would the outcome be the same as using the function?- What’s the advantage of writing a function?