title: Assign numbers to each letter so that r calculates the sum of the letters in a word
body: <p>I'm trying to create a tool in R that will calculate the atomic composition (i.e. number of carbon, hydrogen, nitrogen and oxygen atoms) of a peptide chain that is input in single letter amino acid code. For example, the peptide KGHLY consists of the amino acids lysine (K), glycine (G), histidine (H), leucine (L) and tyrosine (Y). Lysine is made of 6 carbon, 13 hydrogen, 1 nitrogen and 2 oxygen. Glycine is made of 2 carbon, 5 hydrogen, 1 nitrogen and 2 oxygen. etc. etc.
  I would like the r code to either read the peptide string (KGHLY) from a data frame or take input from the keyboard using readline()
  I am new to R and new to programming. I am able to make objects for each amino acid, e.g. G &lt;- c(2, 5, 1, 2) or build a data frame containing all 20 amino acids and their respective atomic compositions.
  The bit that I am struggling with is that I don't know how to get R to index from a data frame in response to a string of letters. I have a feeling the solution is probably very simple but so far I have not been able to find a function that is suited to this task. </p>