R-people I wonder if one could change a list of table with number of the form 1,200.44 , to 1200.44 Regards JG ------------------------------------------------------------------------------ This e-mail and any attachment may be confidential and may also be privileged. If you are not the intended recipient, please notify us immediately and then delete this e-mail and any attachment without retaining copies or disclosing the contents thereof to any other person. Thank you. ------------------------------------------------------------------------------ [[alternative HTML version deleted]]
Hi Jim I'm not sure if I understand your problem correctly. Is this a solution? (li <- list(a=1,b=200.44)) as.numeric(paste(unlist(li), collapse = "")) Best regards, Christoph Buser -------------------------------------------------------------- Christoph Buser <buser at stat.math.ethz.ch> Seminar fuer Statistik, LEO C11 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-5414 fax: 632-1228 http://stat.ethz.ch/~buser/ -------------------------------------------------------------- Jim Gustafsson writes: > > R-people > > I wonder if one could change a list of table with number of the form > 1,200.44 , to 1200.44 > > Regards > JG > > > ------------------------------------------------------------------------------ > This e-mail and any attachment may be confidential and may also be privileged. > If you are not the intended recipient, please notify us immediately and then > delete this e-mail and any attachment without retaining copies or disclosing > the contents thereof to any other person. > Thank you. > ------------------------------------------------------------------------------ > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Jim Gustafsson <jgu at codan.dk> writes:> R-people > > I wonder if one could change a list of table with number of the form > 1,200.44 , to 1200.44 > > Regards > JGOn input, I assume? Read as character variable, get rid of the comma(s) using (g)sub, then use as.numeric. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Hi Jim Something like> x<-"1,200.44" > as.numeric(sub(",", "" , x))[1] 1200.44 Petr On 16 Feb 2005 at 15:08, Jim Gustafsson wrote:> > R-people > > I wonder if one could change a list of table with number of the form > 1,200.44 , to 1200.44 > > Regards > JG > > > ---------------------------------------------------------------------- > -------- This e-mail and any attachment may be confidential and may > also be privileged. If you are not the intended recipient, please > notify us immediately and then delete this e-mail and any attachment > without retaining copies or disclosing the contents thereof to any > other person. Thank you. > ---------------------------------------------------------------------- > -------- > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
use 'gsub'> x <- c('1,200.44', '23,345.66') > gsub(',','',x)[1] "1200.44" "23345.66"> as.numeric(gsub(',','',x))[1] 1200.44 23345.66>__________________________________________________________ James Holtman "What is the problem you are trying to solve?" Executive Technical Consultant -- Office of Technology, Convergys james.holtman at convergys.com +1 (513) 723-2929 Jim Gustafsson <jgu at codan.dk> To: r-help at stat.math.ethz.ch Sent by: cc: r-help-bounces at stat.m Subject: [R] (no subject) ath.ethz.ch 02/16/2005 09:08 R-people I wonder if one could change a list of table with number of the form 1,200.44 , to 1200.44 Regards JG ------------------------------------------------------------------------------ This e-mail and any attachment may be confidential and may also be privileged. If you are not the intended recipient, please notify us immediately and then delete this e-mail and any attachment without retaining copies or disclosing the contents thereof to any other person. Thank you. ------------------------------------------------------------------------------ [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html