Question

In: Computer Science

Discuss how to use R programming to solve the following problem. You’re not just writing the...

Discuss how to use R programming to solve the following problem. You’re not just writing the R code, you are also discussing the process.

  1. Given a person’s full name in the format of firstName middleName lastName such as Michael Carlos Dumas,
    1. write R code(s) to convert it to the format of lastName, middleInitial, firstName.

      In the case of Michael Carlos Dumas, the converted name is Dumas, C. Michael. Your solution should work with any names that comply with the format.
      (Hint: use str_split in stringr library to parse the full name).

Solutions

Expert Solution

Below is the R code. str_split() function is used to split the given string by space. The splitted string is now converted to list after split. Using the paste function separate words are again combined into the given format. The code will work for any 3 word string.

R Code-

name <- "Michael Carlos Dumas"
name
# Splitting the 3 words of name into 3 string
name <- strsplit(name, " ")
# Combining the names in given format using paste() function
new_name <- paste(name[[1]][1], paste(substring(name[[1]][2],1,1),".",sep=""),name[[1]][3], sep = " ")
new_name

Code Screenshot-

Output-


Related Solutions

Discuss how your organization could use an operations management linear programming application to solve a problem...
Discuss how your organization could use an operations management linear programming application to solve a problem or improve a business process.
Discuss how your organization could use an operations management linear programming application to solve a problem...
Discuss how your organization could use an operations management linear programming application to solve a problem or improve a business process.
1. Basic use of R/R Studio. Solve the following problem in R and print out the...
1. Basic use of R/R Studio. Solve the following problem in R and print out the commands and outputs. (a) Create a vector of the positive odd integers less than 100; Remove the values greater than 60 and less than 80; Find the variance of the remaining set of values (b) What’s the difference in output between the commands 2*1:5 and (2*1):5? Why is there a difference? (c) If you wanted to enter the odd numbers from 1 to 19...
Use R to solve the following problem: A study was carried out to investigate the variation...
Use R to solve the following problem: A study was carried out to investigate the variation of rainbow trout weights in a certain creek. The weights (in kilograms) of 10 randomly selected fish are listed below: 0.78, 0.45, 0.35, 0.76, 0.57, 0.42, 0.33, 0.68, 0.66, 0.42 Assume that the population is approximately normally distributed. Test the hypothesis that the unknown population variance is less than 0.08 kg2 at alpha=0.05. Be sure to list (i) your hypotheses, (ii) test statistic, (iii)...
PLEASE USE R PROGRAMMING TO SOLVE THIS AND PASTE A COPYABLE CODE Photoresist is a light-sensitive...
PLEASE USE R PROGRAMMING TO SOLVE THIS AND PASTE A COPYABLE CODE Photoresist is a light-sensitive material applied to semiconductor wafers so that the circuit pattern can be imaged on to the wafer. After application, the coated wafers are baked to remove the solvent in the photoresist mixture and to harden the resist. Here are measurements of photoresist thickness (in kA) for eight wafers baked at two different temperatures. We want to see whether different temperatures make difference. The data...
Consider the following transportation problem. Formulate this problem as a linear programming model and solve it...
Consider the following transportation problem. Formulate this problem as a linear programming model and solve it using the MS Excel Solver tool. Shipment Costs ($), Supply, and Demand: Destinations Sources 1 2 3 Supply A 6 9 100 130 B 12 3 5 70 C 4 8 11 100 Demand 80 110 60 (4 points) Volume Shipped from Source A __________ (4 points) Volume Shipped from Source B __________ (4 points) Volume Shipped from Source C __________ (3 points) Minimum...
3. Solve the following linear programming problem. You must use the dual. First write down the...
3. Solve the following linear programming problem. You must use the dual. First write down the dual maximization LP problem, solve that, then state the solution to the original minimization problem. (a) Minimize w = 4y1 + 5y2 + 7y3 Subject to: y1 + y2 + y3 ≥ 18 2y1 + y2 + 2y3 ≥ 20 y1 + 2y2 + 3y3 ≥ 25 y1, y2, y3 ≥ 0 (b) Making use of shadow costs, if the 2nd original constraint changed...
(C programming) Use a one-dimensional array to solve the following problem. Read in 20 numbers, each...
(C programming) Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it’s not a duplicate of a number already read. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem. Your solution must include a function called isUnique() that returns 1 (true) if the number input is...
Solve the following linear programming problem. You must use the dual. First write down the dual...
Solve the following linear programming problem. You must use the dual. First write down the dual maximization LP problem, solve that, then state the solution to the original minimization problem. (a) Minimize w = 4y1 + 5y2 + 7y3 Subject to: y1 + y2 + y3 ≥ 18 2y1 + y2 + 2y3 ≥ 20 y1 + 2y2 + 3y3 ≥ 25 y1, y2, y3 ≥ 0 (b) Making use of shadow costs, if the 2nd original constraint changed to...
Use the method of this section to solve the linear programming problem. Minimize   C = 2x...
Use the method of this section to solve the linear programming problem. Minimize   C = 2x − 3y + 6z subject to   −x + 2y − z ≤ 9 x − 2y + 2z ≤ 10 2x + 4y − 3z ≤ 12 x ≥ 0, y ≥ 0, z ≥ 0   The minimum is C =   at (x, y, z) =    .
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT