Question: please answer all the question. if you don't know any of them, please do not answer all of them. (a) [10 marks] Write an R
please answer all the question. if you don't know any of them, please do not answer all of them.

![please do not answer all of them. (a) [10 marks] Write an](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f32e1b36556_08266f32e1a9e782.jpg)
(a) [10 marks] Write an R function, called same.family(), that takes two strings, name1 and name2, as input, and returns TRUE if the names appear to be from the same family. For simplicity, do this by checking whether the surnames match. Your function should behave like this when called: > same.family("John Smith", "Jane Smith") [1] TRUE > same.family("John Smith", "jane smith") # Case shouldn't matter [1] TRUE > same.family("Edward Scissorhands", "Edward Zhou") [1] FALSE > same.family("Tinkerbell", "Antonio Sanchez") Warning message: Name contains no spaces. [1] FALSE (b) (5 marks] Write another function, same.family2(), that does the same thing, but where you can give a collection of names in a single character vector of length two or more: 2 "Jane Smith", "Jack Smith")) > same.family2(c("John Smith", [1] TRUE > same.family2(c("Edward Scissorhands", "Edwina Scissorhands", "Ria Scissorfeet")) [1] FALSE > same.family2("Steve Dobbs") Warning message: Input vector should have length 2 or more. [1] NA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
