search for: 1e6

Displaying 20 results from an estimated 270 matches for "1e6".

Did you mean: 16
2011 Nov 18
3
tip: large plots
Hi all, I'm working with a bunch of large graphs, and stumbled across something useful. Probably many of you know this, but I didn't and so others might benefit. Using pch="." speeds up plotting considerably over using symbols. > x <- runif(1000000) > y <- runif(1000000) > system.time(plot(x, y, pch=".")) user system elapsed 1.042 0.030 1.077
2007 Jul 17
2
SLLOOOWWW function ...
...er(frame[["Intensity"]],decreasing = TRUE),] # Establish output frame using the most intense candidate newframe <- frame[1,] # Establish overlap-checking vector using the most intense candidate lowppm <- round(newframe[1,][["Mass"]]-newframe[1, [["Mass"]]/1E6*ppmrange,digits=digit) highppm <- round(newframe[1,][["Mass"]]+newframe[1, [["Mass"]]/1E6*ppmrange,digits=digit) presence <- seq(from=lowppm,to=highppm,by=10^(-digit)) # Walk through the entire original frame and check whether peaks are overlap-free ... do so until m...
2008 Dec 05
1
Trouble with gridBase and inset plots
...he generation of the 3rd inset and I paste below everything I do in this (a bit complicated) figure. Any suggestion is welcome. Cheers Lorenzo pdf("./post-processing-plots/exploratory_research_figure_2.pdf") par( mar = c(4.5,5, 2, 1) + 0.1) plot(time[1:time_end],tot_num_150[1:time_end]/1e6,type="b",lwd=2,col="blue",lty=2, xlab=expression(paste(tau,"[s]")), ylab=expression(paste("N[", cm^{-3},"]")),cex.lab=1.6,ylim=range(c(7.4e7,1.43e8)),yaxt="n",cex.axis=1.4) #lines(time[1],ini_pop/1e6, "p",col="red&...
2005 Feb 11
1
Re: [R-SIG-Mac] Bug running pbinom() in R-GUI?
On Feb 10, 2005, at 7:38 PM, George W. Gilchrist wrote: > Today I was running a graduate level stats lab using R and we > encountered a > major problem while using the current build of the Cocoa GUI: > >> From the GUI: >> system.time(pbinom(80, 1e5, 806/1e6)) > [1] 14.37 4.94 30.29 0.00 0.00 >> > >> From the command line on the same machine: >> system.time(pbinom(80, 1e5, 806/1e6)) > [1] 0.02 0.00 0.02 0.00 0.00 >> > > I've tried the CRAN version and the latest build of the R-GUI and both > deliver the...
2011 Aug 10
1
Sequential Naming of ggplot .pngs using plyr
...facet onto multiple pages of a pdf or something) because these need to go into reports as individually labelled and titled plots. As a bit of a corollary, is it really worth the headache to resolve this if I am only using melt/plyr to split on the four letter variables? With a larger set of data (1e6 rows), the melt/plyr version takes a significant amount of time but .parallel=T drops the time significantly. Is the right answer a foreach loop and can I do that with the increasing counter? (I haven't gotten beyond Hadley's .parallel feature in my parallel R dealings.) > dat<-data...
2006 Jun 27
3
reading a matrix from a file
Hello everyone, I'm writting a little script that will read a matrix from a file i.e. 0,.11,.22,.4 .11,0,.5,.3 .22,.5,0,.7 anb so on and will then calculate some standard stats for nets (i.e. centralization, degree, etc). So far I have opened the file and read the contents, however I' m using readLines(filename) to read the file and it returns it as
2005 Apr 22
1
RE: [R] when can we expect Prof Tierney's compiled R?
...raction. The loops below are typical in any recursive calculation where the new value of a vector is based on its immediate neighbor say to the left. Specifically we assign the previous value to the current element. # this shows that the assignment x[i]<- is the bottleneck in the loop > n = 1e6; iA = seq(2,n); x = double(n); system.time(for (i in iA) x[i] = x[i-1]) [1] 4.29 0.00 4.30 0.00 0.00 > n = 1e6; iA = seq(2,n); x = double(n); system.time(for (i in iA) x[i-1]) [1] 1.46 0.01 1.46 0.00 0.00 # the overhead of the loop itself is reasonably low, just 0.17 sec > n = 1e6; iA = seq(...
2012 May 06
2
unlist crashes 32-bit R on WinXP when use.names=TRUE
...r evaluation: recursive default argument reference or earlier problems? > traceback() Error: C stack usage is too close to the limit > # evaluating an expression at this point would cause R to exit ungracefully Here's an example that avoids a lot of unnecessary code: L1 <- list(one=1:1e6, two=1:1e6, three=1:1e6) # no issue with smaller list elements U1 <- unlist(L1, recursive=TRUE, use.names=TRUE) C1 <- c(L1, recursive=TRUE, use.names=TRUE) L2 <- list(one=1:1e7, two=1:1e7, three=1:1e7) # crashes after ~2min with error above U2 <- unlist(L2, recursive=TRUE, use.names=TR...
2012 Dec 27
4
vectorization & modifying globals in functions
...100) { a <- sample.int(length(d), size = 2) if (d[a[1]] >= 1) { d[a[1]] <- d[a[1]] - 1 d[a[2]] <- d[a[2]] + 1 } } --8<---------------cut here---------------end--------------->8--- it does what I want, i.e., modified vector d 100 times. Now, if I want to repeat this 1e6 times instead of 1e2 times, I want to vectorize it for speed, so I do this: --8<---------------cut here---------------start------------->8--- update <- function (i) { a <- sample.int(n.agents, size = 2) if (d[a[1]] >= delta) { d[a[1]] <- d[a[1]] - 1 d[a[2]] <- d[a[...
2004 May 01
5
skip lines on a connection
Hi, I am looking for an efficient way of skipping big chunks of lines on a connection (not necessarily at the beginning of the file). One way is to use read lines, e.g. readLines(1e6), but a) this incurs the overhead of construction of the return char vector and b) has a (fairly remote) potential to blow up the memory. Another way would be to use scan(), e.g. scan(con, skip=1e6, nmax=0) but somehow this doesn't work: > scan(con, skip=10, nmax=0) Error in scan(co...
2019 Feb 26
2
bias issue in sample() (PR 17494)
...hould be fixed as part of the upcoming changes: R.version.string ## [1] "R Under development (unstable) (2019-02-25 r76160)" .Machine$double.digits ## [1] 53 set.seed(123) RNGkind() ## [1] "Mersenne-Twister" "Inversion"??????? "Rejection" length(table(runif(1e6))) ## [1] 999863 I don't expect any collisions when using Mersenne-Twister to generate a million floating point values. I'm not sure what causes this behavior, but it's documented in ?Random: "Do not rely on randomness of low-order bits from RNGs. Most of the supplied uniform...
2018 Sep 18
3
memory footprint of readRDS()
Dear all, I tried to read in a 3.8Gb RDS file on a computer with 16Gb available memory. To my astonishment, the memory footprint of R rises quickly to over 13Gb and the attempt ends with an error that says "cannot allocate vector of size 5.8Gb". I would expect that 3 times the memory would be enough to read in that file, but apparently I was wrong. I checked the memory.limit() and that
2019 Feb 26
1
bias issue in sample() (PR 17494)
Ralf I don't doubt this is expected with the current implementation, I doubt the implementation is desirable. Suggesting to turn this to pbirthday(1e6, classes = 2^53) ## [1] 5.550956e-05 (which is still non-zero, but much less likely to cause confusion.) Best regards Kirill On 26.02.19 10:18, Ralf Stubner wrote: > Kirill, > > I think some level of collision is actually expected! R uses a 32bit MT > that can produce 2^32 differen...
2018 Sep 20
3
A different error in sample()
Good day, The use of "rounding" also doesn't make sense. If The number is halfway between two integers, it is rounded to the nearest even integer. > round(2.5) [1] 2 -------------------------------------- Dario Strbenac University of Sydney Camperdown NSW 2050 Australia
2009 Feb 11
3
Generating Numbers With Certain Distribution in R
Dear all, Is there a way to generate K numbers of integer (K = 10^6). The maximum value of the integer is 200,000 and minimum is 1. And the occurrences of this integer follows a lognormal distribution. - Gundala Viswanath Jakarta - Indonesia
2005 Apr 27
1
RE: [R] when can we expect Prof Tierney's compiled R?
...obably not much as these simple > benchmarks are rarely representative of real code and so need > to be taken with a huge chunk of salt) here is what happens > with your examples in R 2.1.0 with the current byte compiler. > > Define your examples as functions: > > n = 1e6; iA = seq(2,n); x = double(n); > f1 <- function(x, iA) for (i in iA) x[i] = x[i-1] > f2 <- function(x, iA) for (i in iA) x[i-1] > f3 <- function(x, iA) for (i in iA) 1 > f4 <- function(x, iA) for (i in iA) x[i] = 1.0 > f5 <- function(x, iA) for...
2018 Sep 20
2
A different error in sample()
...72356, or the way this function is used in do_sample in src/main/random.c. 20.9.18 08:19, Wolfgang Huber scripsit: > Besides wording of the documentation re truncating vs rounding, there is > something peculiar going on with the fractional part of n: > > > table(sample.int(2.5, 1e6, replace = TRUE)) > > ???? 1????? 2????? 3 > 399051 401035 199914 > > > table(sample.int(3, 1e6, replace = TRUE)) > > ???? 1????? 2????? 3 > 332956 332561 334483 > > > table(sample.int(2.01, 1e6, replace = TRUE)) > > ???? 1????? 2????? 3 > 4971...
2010 Oct 27
2
must .Call C functions return SEXP?
...eturns nothing, the do_dotcall's retval should simply remain set to R_NilValue, which should be fine. I must be misunderstanding something here, but I don't know what, and would definitely appreciate any help. Thanks! My R code looks like this: result.1 <- vector("list" ,1e6) result.2 <- vector("list" ,1e6) .Call("my_C_function", result.1, result.2, other.input) My C code looks like this: SEXP result_v; result_v = Rf_allocVector(REALSXP, 5); SET_VECTOR_ELT(result_list_1, k1, result_v); REAL(result_v)[0] = some_number; REAL(res...
2013 Jul 02
3
Ctrl+C in R will terminate the child process which is spawned by using "pipe"
Hi, all, I pressed Ctrl+C in R process, and found that the child process which was spawned by using "pipe" is terminated due to this. Are there any way to work around it, so that the child process can run happily without being terminated? Or can we block the signal for the child process? 1. I used pipe to spawn one C++ process, which will running in a loop without exiting immediately.
2018 Sep 18
0
memory footprint of readRDS()
...tor of repeated values can be compressed into a smaller file than a bunch of random bytes). f <- function (data, ...) { force(data) tf <- tempfile() on.exit(unlink(tf)) save(data, file = tf) c(`obj/file size` = as.numeric(object.size(data)/file.size(tf))) } > f(rep(0,1e6)) obj/file size 1021.456 > f(rep(0,1e6), compress=FALSE) obj/file size 0.9999986 > f(rep(89.7,1e6)) obj/file size 682.6555 > f(log(1:1e6)) obj/file size 1.309126 > f(vector("list",1e6)) obj/file size 2021.744 > f(as.list(log(1:1e6))) obj/file size...