search for: formatc

Displaying 20 results from an estimated 313 matches for "formatc".

Did you mean: format
2000 Jan 04
0
formatC (bug and fix) (PR#394)
OK: > formatC(as.double(c(1,0,NA))) [1] "1" "0" "NA" NOT OK: > formatC(as.integer(c(1,0,NA))) [1] "0" "1072693248" "NA" > formatC(as.integer(c(0,1,NA))) [1] "0" "0" "NA" BUG TRACED TO R-code of form...
2008 Jun 09
1
Bug/Error in formatC? (Was: Why doesn't formatC( x, digits=2, format= "g")...)
Hi all After posting what follows, Duncan Murdoch suggested perhaps a bug in formatC, or an error on documentation. Any comments? In particular, bug, error or not, any ideas about how I can consistently get two significant figures to print? P. ---------- Original Message ---------- Hi all I am not a C programmer, but I am trying to understand formatC to get consistent...
2008 Jun 06
2
Why doesn't formatC( x, digits=2, format="g") doesn't always give 2 sig figs?
Hi all I am not a C programmer, but I am trying to understand formatC to get consistent printing of reals to a given number of significant digits. Can someone please explain this to me? These first three give what I expect on reading ?formatC: > formatC(0.0059999, digits=2,format="fg",flag="#") [1] "0.0060" > formatC(0.5999...
2001 Oct 26
1
Bug or new concept in formatC?
As a sequel to my previous mail on cut, formatC does not produce what I have been taught is significant digits: > x <- c(1.0793,1.0796, 11.0954, 11.0736 ) > formatC(x,digits=3,format="g") [1] "1.08" "1.08" "11.1" "11.1" (3,3,3,3) significant digits OK > formatC(x,digits=3,format=&...
1999 Feb 28
0
Formatting in formatC and format (PR#129)
[This turned into a bug report which will go to r-devel, so I have taken it off r-help.] Bugs reported here: (1) formatC's help page need some clarification. (2) formatC needs to treat modes "double" and "real" as equivalent. (3) format's help page or (preferably) format needs correction re the meaning of `digits' On Sun, 28 Feb 1999, Martin Maechler wrote: > >>>>&g...
2012 Feb 23
3
I'm sure I'm missing something with formatC() or sprintf()
I have a four-digit string I want to convert to five digits. Take the following frame: zip 2108 60321 60321 22030 91910 I need row 1 to read '02108'. This forum directed me to formatC previously (thanks!) That usually works but, for some reason, it's not in this instance. Neither of the syntaxes below change '2108' to '02108.' The values in cand_receipts[,1] are of type 'character.' cand_receipts[,1] <- formatC(cand_receipts[,1], width = 5, format...
2019 May 30
1
Possible bug in formatC
I do not know if this is a bug or a case of improper documentation. The documentation for formatC() implies that the difference between the options format="f" and format="g" is that with "g", scientific format is sometimes used. There is another difference between them that is not mentioned in the documentation. drop0trailing=FALSE is ignored when format is set to...
2012 Apr 03
3
Sweave xtable
...s problemas porque saltan al abrir el pdf que se obtiene como resultado. #################################3 código R #########################3 library(xtable) da <- data.frame(id=letters[1:5], score=1:5*2) col <- function(x){ ifelse(x>7, paste("\textcolor{blue}{", formatC(x, dig=2, format="f"), "}"), paste("\textcolor{red}{", formatC(x, dig=2, format="f"), "}")) } da$score.string <- col(da$score) xtable(da[,c("id","score.string")]) ####################################################...
2005 Nov 22
2
(PR#8337) formatC adds leading space -- on some Windoze
...KevinW> Apologies if my expectations (or reading of the man page) are incorrect. KevinW> I seem unable to left-justify exponential format KevinW> numbers. There appears to always be an extra space KevinW> inserted to the left. KevinW> Using the example from the formatC help page: R> xx <- pi * 10^(-5:4) R> cbind(formatC(xx, wid = 9, flag = "-")) KevinW> [,1] KevinW> [1,] " 3.142e-05" KevinW> [2,] "0.0003142" KevinW> [3,] "0.003142 " KevinW> [4,] "0.0...
2009 Jan 27
1
small bug in base::formatC (PR#13474)
Full_Name: Bernd Bischl Version: 2.8.1 OS: Windows XP Professional Submission from: (NULL) (129.217.207.95) Hi, there seems to be a small bug in formatC: formatC("foo", format="s", mode="charcacter") Error in formatC("foo", format = "s", mode = "charcacter") : 'mode' must be "double" ("real") or "integer" ?formatC says: mode: "double"...
2008 May 12
5
Format integer
Hi, What's one way to convert an integer to a string with preceding 0's? such that '13' becomes '00000000013' to be put into a string I've tried formatC, but they removes all the zeros and replace it with blanks Thanks -- Regards, Anh Tran [[alternative HTML version deleted]]
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 jus...
2008 Apr 10
6
How to create a legend without plot, and to use scientific notation for axes label ?
Hi, I have a 3 by 2 plots per page, and would like to place a legend on the last region. How to do that ? Also, is there any way to specify scientific notation for axes label ? [[alternative HTML version deleted]]
2005 Jun 23
1
the dimname of a table
i have a data frame(dat) which has many variables.and i use the following script to get the crosstable. >danx2<-c("x1.1","x1.2","x1.3","x1.4","x1.5","x2","x4","x5","x6","x7","x8.1","x8.2","x8.3","x8.4","x11",
2006 Dec 09
2
Floating point maths in R
...00000000000007 [1] FALSE > (4.2300000000000000-2.230000000000000) == 2.0000000000000008 [1] FALSE > (4.2300000000000000-2.230000000000000) == 2.0000000000000009 [1] FALSE > (4.2300000000000000-2.230000000000000) == 2.0000000000000010 This is an example of junk being added in the FPU > formatC(a, digits=20) [1] "2.0000000000000004441" I don't know if this is just a formatC error when using more than 16 decimal places or if this junk is what is stopping the equality from being true: > formatC(a, digits=16) [1] " 2" > formatC(a, digits=17)...
2005 Oct 08
1
add leading 0s to %d from png() {was Automatic creation of file names}
...ans to me with leading 0s, so that the PNGs become easy to navigate in a file/image browser. Lacking a better solution I ended up using the code below, but would much prefer something like png("test_%d.png",bg="white",width=1000,height=700) where %d could be formatted like formatC(%d,digits=0,wid=3,flag="0",mode="integer") Thank you, b. #---works, but is rather complicated--- pngno <- 0 ; i <- 1 for (w in 1:53) { if (i %in% c(4*0:100+1)) { pngno <- pngno + 1 png(paste("test_",formatC(pngno,digits=0,wid=4,flag="0",m...
2005 Sep 22
7
Automatic creation of file names
Dear R-Help members, I have a question about how to save to the hard drive the one thousand datasets I generated in a simulation. The datasets are created in a "for" loop that repeatedly creates normally distributed datasets, such as the example below: Library(MASS) for (number in 1:1000) { dataset = mvrnorm(n = 400, mu = c(0,0,0), Sigma =
2003 Feb 24
2
printing decimal numbers
hi, this is a very basic question -- sorry for posing it: how can i force R to print 0.0001 instead of 1e-04??? .--------------------. | > 0.0001 | | [1] 1e-04 | `--------------------' i tried the functions format, formatC, ... and changed options()$digits with no success! thanks for advice, tomy -- no signature
2003 May 22
4
grep, gsub, sub have problems with NA values (PR#3078)
In a string context, grep, gsub, sub are improperly treating NA (missing) as the string "NA", and returning unexpected results > grep("A", c(NA,"NA")) [1] 1 2 # expected: # [1] 2 > gsub("A", "X", c(NA,"NA")) [1] "NX" "NX" # expected # [1] NA "NX" > sub("A", "X",
2006 Jan 23
1
formatC slow? (or how can I make this function faster?
...#39;m having problems doing this in a speedy way. The simplest solution (calc_history below, using apply, paste and collapse) takes about 2 seconds for a 10,000 x 10 matrix. I thought perhaps paste might be building up the string in an efficient manner, so I tried using matrix multiplication and formatC (as in calc_history2). This is about 25% faster, but still seems slow. smp <- matrix(rbinom(100000, 1, 0.5), nrow=10000) calc_history <- function(smp) { apply(smp, 1, paste, collapse="") } calc_history <- function(smp) { mul <- 10 ^ ((ncol(smp)-1):0) as.vector(formatC(s...