[R] Need to Write a Code that can find the molecular weight of various compounds

matthew.ttd.nguyen matthew.ttd.nguyen at gmail.com
Mon Jan 30 23:51:14 CET 2012


Hi!

Just started working at a lab and have only minimal experience with R.

I was wondering if there was a way to write a code that would intake a data
set of chemical compounds (ex: H2O, CH3)
and be able to give an output column of the molecular weight?

I tried some really basic coding to try to work with a being a matrix of
data with the assigned variables.

if (A<-'H') A<-a[50,3]
else (B<-'O') B<-a[86,3]

ifelse (A=='H',A<-a[50,3],ifelse(B=='O',B<-a[86,3],0]

I was thinking to have the program read the formula and compute the output
of molecular mass by reading information off of a separate data sheet with
the individual weights of the molecules, and then output that into another
column.

Any suggestions? Thanks!

--
View this message in context: http://r.789695.n4.nabble.com/Need-to-Write-a-Code-that-can-find-the-molecular-weight-of-various-compounds-tp4342874p4342874.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list