similar to: Beginner's question: number formatting

Displaying 20 results from an estimated 10000 matches similar to: "Beginner's question: number formatting"

2018 May 25
4
options other than regex
Hi -- I'm looking for alternatives to regex for a fairly simply 'reformatting' problem. Alternatives only because a lot of folks have trouble parsing/interpreting regex expressions, and I'm looking for suggestions for something more 'transparent'. Here is an example of what I'm trying to do. Take the following string, which I call x, and for each character in the
2019 Mar 22
2
prettyNum digits=0 not compatible with scientific notation
FWIW, it doesn't seem to be happening on Mac OS: > format(2^30, digits=0) [1] "1.e+09" > prettyNum(12345.6, digits=0) [1] "1.e+04" A glibc misfeature? -pd > On 22 Mar 2019, at 10:10 , Martin Maechler <maechler at stat.math.ethz.ch> wrote: > > Thank you, Robert for raising this here ! > >>>>>> Robert McGehee
2019 Mar 21
3
prettyNum digits=0 not compatible with scientific notation
R developers, Seems I get a bad result ("%#4.0-1e" in particular) when trying to use prettyNum digits=0 with scientific notation. I tried on both my Linux box and on an online R evaluator and saw the same problem, so it's not limited to my box at least. I see the problem in both R 3.5.3 and R 3.3.2. options(scipen=-100) prettyNum(1, digits=0) [1] "%#4.0-1e" prettyNum(2,
2018 May 25
0
options other than regex
Hi I am not sure if it is more readable > paste(paste(unlist(strsplit(x,"")),".", sep=""), collapse="") [1] "1.0.1.1.0.1.1.1." If you did not want last dot, it is a bit shorter. > paste(unlist(strsplit(x,"")),collapse=".") [1] "1.0.1.1.0.1.1.1" > Cheers Petr Tento e-mail a jak?koliv k n?mu p?ipojen?
2010 Feb 15
2
Printing 2 digits after decimal point
Hi there, i'm not getting along with the following problem. I'd like to print a real number, e.g. x <- 12.3 with exactly two digits after the decimal point, e.g. 12.30 I've tried the whole format(), formatC() and prettyNum() functions but did not have any success with it. This should work with all real numbers, in case even with 0.0 (-> 0.00). For cracks this thing is pretty
2002 May 13
1
prettyNum inserts leading commas (PR#1548)
Under R-1.5.0 on Solaris 2.6: R> prettyNum(123456789, big.mark=",") [1] ",123,456,789" and that bad behavior (leading comma) spills into formatC as well: R> formatC(123456789, digits=0, format="f", big.mark=",") [1] ",123,456,789" Looks to me like a bug in src/library/base/R/format.R, in function prettyNum: B.[i.big] <-
2006 Jun 08
1
Formatting numbers for printing
Colleagues I have numbers like "12012" that I will be printing in a graphic. I would like to format them as follows: 012-012, i.e., the first two digits padded to the left by a zero, followed by a dash, followed by the final three digits, also padded to the left by zeros. I can do this with brute force: FirstPart <- sprintf("%03d", floor(Number / 1000))
2002 Mar 13
1
Commas in formatC
formatC() is great for formatting numbers! But it would be even better if it could optionally insert commas (or semicolons), e.g. R> formatC(1234567.89, digits=2, format="f", commas=T) [1] "1,234,567.89" Here's a snippet of code that does that, which could more or less just be inserted into at the end of formatC if any R-core guru were so inclined. "r"
2011 Mar 23
2
Estimating correlation in multiple measures data
Dear R-helpers, This may sound simple to you, but I'm a beginner in this, so please be forgiving. I have a following problem: two analytes were measured in patient's blood on 4 occasions: ProteinA and ProteinB. How to correctly evaluate correlation between ProteinA and ProteinB? I tried: x <- data.frame(Patient.ID=rep(1:10, each=4), Visit=rep(c(1:4),10), ProteinA=rnorm(m=10,
2010 May 26
3
Problem with plotting survival predictions from cph model
Dear R-helpers, I am working with 'cph' models from 'rms' library. When I build simple survival models, based on 'Surv(time, event)', everything is fine and I can make nice plots using plot(Predict(f, time=3)). However, recently I tried to be more specific and used 'Surv(start, stop, event)' type model. Using this model 'plot(Predict(f))' works OK, but
2019 Mar 22
0
prettyNum digits=0 not compatible with scientific notation
Thank you, Robert for raising this here ! >>>>> Robert McGehee >>>>> on Thu, 21 Mar 2019 20:56:19 +0000 writes: > R developers, > Seems I get a bad result ("%#4.0-1e" in particular) when trying to use prettyNum digits=0 with scientific notation. I tried on both my Linux box and on an online R evaluator and saw the same problem, so
2008 Aug 07
1
Bug in format.default(): na.encode does not have any effect for (PR#12318)
Hi! If I use format() on numeric vector, na.encode argument does not have any e= ffect. This was reported before: - https://stat.ethz.ch/pipermail/r-help/2007-October/143881.html - http://tolstoy.newcastle.edu.au/R/e2/devel/06/09/0360.html It works for other (say character) classes! > format(c("a", NA), na.encode=3DTRUE) [1] "a " "NA" >
2008 Sep 23
1
Newbie: Formatting numbers with commas
Hi, Search through the R archives, and couldn't find my answer... how do you format numbers with commas (standard American, one every three digits)? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas
2010 Mar 30
5
Problem comparing hazard ratios
Dear R-Helpers, I am a novice in survival analysis. I have the following code: for (i in 3:12) print(coxph(Surv(time, status)~a[,i], data=a)) I used it to fit the Cox Proportional Hazard models separately for every available parameter (columns 3:12) in my data set - with intention to compare the Hazard Ratios. However, some of my variables are in range 0.1 to 1.6, others in range 5000 to
2010 Aug 16
4
print numbers
Hi, When I plot, the axis ticks are printed as "50.00 25.00 10.00 1.00 0.05 0.01", is there any way to print them as "50 25 10 1 0.05 0.01" instead? Thanks John
2019 Mar 22
0
prettyNum digits=0 not compatible with scientific notation
>>>>> peter dalgaard >>>>> on Fri, 22 Mar 2019 17:30:19 +0100 writes: > FWIW, it doesn't seem to be happening on Mac OS: >> format(2^30, digits=0) > [1] "1.e+09" >> prettyNum(12345.6, digits=0) > [1] "1.e+04" > A glibc misfeature? It seems (and note we are talking about format.default()
2012 May 02
2
Problem with 'nls' fitting logistic model (5PL)
Dear R-Helpers, I'm working with immunoassay data and 5PL logistic model. I wanted to experiment with different forms of weighting and parameter selection, which is not possible in instrument software, so I turned to R. I am using R 2.14.2 under Win7 64bit, and the 'nls' library to fit the model - I started with the same model and weighting type (1/y) as in the instrument to see
2009 Aug 05
1
Starting NONMEM (nmfe6) from R
Hello, I have made an R script that prepares a NONMEM dataset and I would like to start the NONMEM run right after the dataset is ready. I am using windows XP, R 2.9.1 and NONMEM 6. I have prepared a run.bat file that looks like this: ---------------------------------------- call K:\nmvi\NMdirectories.bat call K:\nmvi\nmfe6 "path\control.txt" "path\output.txt"
2008 Jun 10
1
Problem with by(... , median)
Hello everyone, I am new to R, I have been using SAS for a while. Not surprisingly, I find R much better in graphics, which is publication ready right away. Recently, I have been trying to calculate some basic statistics using R. I have a dataset of multiple rows per subject. For example: Subject Date Factor1 Factor2 Factor3 P1 0.5 1 1 3 P1 1 3 2 5 P1 2 3 5 NA ... P2 0.5 1 6 4 P2 1 2 NA 7 P2
2008 Jul 23
1
[Fwd: Re: Coefficients of Logistic Regression from bootstrap - how to get them?]
I think the argument supporting the use of bootstrap to determine coefficients, as opposed to just running linear regression on the whole dataset, is the comparison of Rsq and prediction errors between these two approaches - page 1502. There's a substantial difference in favor of the bootstrap approach. -- Michal J. Figurski Gustaf Rydevik wrote: > The url for the mentioned paper is