matthew.ttd.nguyen
2012-Jan-30 22:51 UTC
[R] Need to Write a Code that can find the molecular weight of various compounds
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.
hpbenton
2012-Jan-31 02:58 UTC
[R] Need to Write a Code that can find the molecular weight of various compounds
Matthew, I would try first looking at the Rcdk package. From it sound like what you want to do they already have some very efficient code to that. If you don't want all of CDK then you could try Rdisop from Bioconductor. The package will take a formula and give you it's mass. It won't do a matrix but just 'sapply' the function. http://cran.r-project.org/web/packages/rcdk/index.html http://www.bioconductor.org/packages/2.6/bioc/vignettes/Rdisop/inst/doc/Rdisop.pdf ## code from above link## library(Rdisop)> molecule <- getMolecule("C2H5OH") > getFormula(molecule)[1] "C2H6O"> getMass(molecule)[1] 46.04186
Reasonably Related Threads
- vignettes are installed but not viewable?
- DSViewerPro molecular modelling program
- Package for Molecular Properties
- Statistics and Bioinformatics Positions, Novartis Molecular Diagnostics, Cambridge MA USA and Basel, Switzerland
- Package for Molecular Properties