Re: [R] removing specified length of text after a period in dataframe of char's

2011-12-07 Thread Aidan Corcoran
Hi Sarah, this is a neat solution. Thanks very much for your help, and your patience with my poorly posed questions. I've learned a lot from your approach. best regards, Aidan On Wed, Dec 7, 2011 at 1:40 PM, Sarah Goslee wrote: > Hi, > > If you really wanted precision (significant figures) rath

Re: [R] removing specified length of text after a period in dataframe of char's

2011-12-07 Thread Sarah Goslee
Hi, If you really wanted precision (significant figures) rather than decimal places, it would be easy: format() handles that, I believe. Your original email said you'd been reading about regular expressions; continuing that reading will lead you to the meaning of the cryptic ^ and all the \. As

Re: [R] removing specified length of text after a period in dataframe of char's

2011-12-07 Thread Aidan Corcoran
Hi Sarah, apologies for the excess. A smaller example: f<-structure(list(c("GDP per capita (LCU)", "Ratio to EZ GDP Per Cap" ), `2005` = c(32128, 0.1), `2009` = c(52163, 0.1), `2010` = c(63100, 0.1), `2011` = c(72461, 0.1), `2012` = c(81313, 0.1)), .Names = c("", "2005", "2009", "2010", "2011", "

Re: [R] removing specified length of text after a period in dataframe of char's

2011-12-07 Thread Sarah Goslee
Hi, Example data is crucial, but small simple example data is even better. I'm too lazy to figure out which bits I need from your data, so here's a simple example of one way to approach your question. You could use gsub() in very much the same manner if you need more complex output. > testdata <-

[R] removing specified length of text after a period in dataframe of char's

2011-12-07 Thread Aidan Corcoran
Dear all, I'm trying to remove some text after the period (a decimal point) in the data frame 'hi', below. This is one step in formatting a table. So I would like e.g. "2.0" to become "2" and "5.3" to be "5.3", where the variable digordered contains the number of digits after the decimal that I