13  Lecture: R Character Manipulation

13.1 R Character Manipulation lecture

Here’s a recording of this lecture (42 minutes 49 seconds):

Recording

13.2 R Character Manipulation slides

PDF slide set

13.3 Questions

13.3.1 Question 1

Given the two vectors of alleles below, which of the following R commands would correctly combine them to produce a single vector of genotypes?

> a1 <- c("A","T","A")
> a2 <- c("A","A","T")

13.3.2 Question 2

Given a vector of genotypes separated by a forward slash, which of the following R commands would correctly change it into a vector of alleles?

> g <- c("A/A","A/T","A/T","T/T","A/A")

13.3.3 Question 3

Given a vector of multi-part IDs, which of the following R commands would correctly change it into a vector containing only the β€œPerson” part of each ID?

> id <- c("Person1-Sample1","Person1-Sample2", "Person2-Sample1", "Person30-Sample1")

13.3.4 Question 4

Suppose you have a data frame called df with a column named V1 containing journal names. Which of the following R commands would correctly determine the number of journals in the list that start with the phrase β€œGENET”?

13.3.5 Question 5

Suppose you have a data frame named df. Which of the following R commands would correctly add a new, unique journal ID column named jid that consists of a β€œJ” followed by the row number in the style of J1, J2, J3, etc.?