Classwork 5
Classwork 5
Q1. Store the first 50 names of the babynames dataframe as a vector names50.
• Use the is.vector() function to check that names50 is indeed a vector.
Q2. Using a for loop, print the following statement for all names in vector names50. You should google
and use the paste() and nchar() function to make your life easier. Your for loop should print all
the following in a single run:
• “The name Mary consists of 4 characters.”
• “The name Anna consists of 4 characters.”
• …
• “The name Josephine consists of 9 characters.”
Q3. Redo Q2 but with the str_c() function but without seperators.
Q4. Redo Q2 but with the str_c() function and with seperators.
Strictly confidential – Do not distribute without prior permission from the author(s).