[R] clusterMap: static vs dynamic scheduling
The clusterMap function provides the following argument .scheduling = c(static, dynamic) The default is static. When is it advisable to use dynamic? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Old g++ in Rtools
I recently downloaded Rtools. I see the g++ version is gcc version 4.6.3 20111208 (prerelease) (GCC) I also recently downloaded MinGW. Its version of g++ is gcc version 4.8.1 (GCC) I believe that later versions of g++ provide better support for C++11. Why does Rtools provide a version considerably older than the latest? Any plans to update the version? Is it bad practice to compile with a later version when interfacing with R? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mapply echoes function call when browser() is called from within FUN
When mapply is applied to a function that has a call to browser() within it, the result can be a disastrous amount of feedback. To clarify this situation please consider the following function, containing a call to browser within it: plus = function(a, b) {browser(); a + b} A plain vanilla call to plus() yields the following: LAPTOP_32G_01 plus(1,2) Called from: plus(1, 2) Browse[1] [1] 3 Now consider the following application of mapply to plus: LAPTOP_32G_01 mapply(plus, 1:2, 1:2) Called from: (function (a, b) { browser() a + b })(dots[[1L]][[1L]], dots[[2L]][[1L]]) Browse[1] Called from: (function (a, b) { browser() a + b })(dots[[1L]][[2L]], dots[[2L]][[2L]]) Browse[1] [1] 2 4 Notice that at each step, after the browser is called, mapply prints out the function call including its arguments: Called from: (function (a, b) { browser() a + b })(dots[[1L]][[1L]], dots[[2L]][[1L]]) etc. In the present case this does no harm except to make things a little harder to read. However, if one of the inputs happens to be a data frame with a million rows, the entire million rows are printed to the screen. I have been bitten by this, which is why I am writing this note. I have a question and a request: Question: Is there some way to prevent mapply (or browser) from echoing the function call when browser is called from within FUN? Request: If not, could the ability to turn off this echoing be provided. As things stand, calling browser from within FUN, when FUN is a realistically big function or has realistically big arguments, is a disaster. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot: vertical text annotation, outside plot region
In traditional R graphics I can generate text annotations that are vertical, and that lie outside the plot region, using the mtext function. I'd like to do the same thing in ggplot2. Is it possible? The documentation for 'annotate' does not mention such possibilities. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] identical applied to data frames
I have two data frames that I believe are identical, yet checking them with identical() fails. Each data frame has two columns named 'pk' and 'newv_f13__bool'. As shown below, the columns of the data frames are identical, according to the identical() function, yet the data frames themselves are not. How can this be? Browse[1] identical(shft$pk, shft_mat$pk) [1] TRUE Browse[1] identical(shft$newv_f13__bool, shft_mat$newv_f13__bool) [1] TRUE Browse[1] identical(shft, shft_mat) [1] FALSE I have attached a file in which the two data frames are saved (using the save() function). __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] remove failure
Platform: Windows 7, R version 3.0.1 Patched (2013-06-19 r62992) I have been running the following code (part of a larger program) for many months without problem: if ((gname %in% ls(envir=.GlobalEnv)) !is.null(cols)) { if (!identical(cols, names(get(gname, envir=.GlobalEnv remove(gname, envir=.GlobalEnv) } For some reason today I started to get the following error: Error in remove(gname, envir = .GlobalEnv) : (converted from warning) object 'gname' not found The error is illogical as the call to remove can only occur if gname is in the global environment. Furthermore, when I go into the debugger and run gname %in% ls(envir=.GlobalEnv) manually the expression returns TRUE. When I manually inspect the output of ls(envir=.GlobalEnv) I find that the value of gname is, indeed, present. I have tried re-booting my machine, but the error recurs even after a re-boot. Any insight on this error would be appreciated. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Accidentally replacing core R functions
I sometimes find that a function I have defined has the same name as an R core function. In most cases I have no desire to redefine the core R function and would prefer to give my function a different name. The problem is that R lets users redefine its core functions without any warning. Is there a way to cause R to generate a warning if a core function is being redefined? To give an actual example, in my personal library of functions I have a 'seek' function. I recently noticed that seek(con, ...) is part of base R. Now I plan to rename my personal 'seek' function but would have benefited from a warning when I first created this function. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Parallel processing random 'save' error
Platform: Windows 7 Package: parallel Function: parLapply I am running a lengthy program with 8 parallel processes running in main memory. The processes save data using the 'save' function, to distinct files so that no conflicts writing to the same file are possible. I have been getting errors like the one shown below on a random basis, i.e., sometimes at one point in the execution, sometimes at another, sometimes no error at all. I should note that the directory referred to in the error message ( 'D:\_pgf\quantile_analysis2_f13\_save\dbz084_nump48\bins') contains, as I write, 124 files saved to it by the program without any error; which underscores the point that most of the time the saves occur with no problem. Error in checkForRemoteErrors(val) : one node produced an error: (converted from warning) 'D:\_pgf\quantile_analysis2_f13\_save\dbz084_nump48\bins' already exists Enter a frame number, or 0 to exit 1: main_top(9) 2: main_top.r#26: eval(call_me) 3: eval(expr, envir, enclos) 4: quantile_analysis(2) 5: quantile_analysis.r#69: run_all(layr, prjp, np, rules_tb, pctiles_tb, parx, logdir, logg) 6: run_all.r#73: parLapply(cl, ctrl_all$vn, qa1, prjp, dfr1, iu__bool, parx, logdir, tstamp) 7: do.call(c, clusterApply(cl, x = splitList(X, length(cl)), fun = lapply, fun, ...), quote = TRUE) 8: clusterApply(cl, x = splitList(X, length(cl)), fun = lapply, fun, ...) 9: staticClusterApply(cl, fun, length(x), argfun) 10: checkForRemoteErrors(val) 11: stop(one node produced an error: , firstmsg, domain = NA) 12: (function () { error() utils::recover() })() Following the latest error I checked the system's connections as follows: Browse[1] showConnections() description class mode text isopen can read can write 3 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes 4 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes 5 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes 6 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes 7 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes 8 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes 9 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes 10 -LAPTOP_32G_01:11741 sockconn a+b binary opened yes yes Browse[1] It seems that the parallel processes might be sharing the same connection--or is it that they are utilizing connections that have the same name but are actually distinct because they are running in parallel? If the connections are the problem, how can I force each parallel process to use a different connection? If the connections are not the problem, then can someone suggest a diagnostic I might apply to tease out what is going wrong? Or perhaps some program setting that I may have neglected to consider? Thanks in advance for your help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Time of day
Is there a simple way to obtain the time of day in R? I want the time of day for computational purposes, not for display. I want to be able to create code like the following: if (time_of_day = 22:00 time_of_day = 06:00) then X otherwise Y I realize I could parse a date/time object and extract the time, but hopefully other people have already done this, or there is a straightforward representation of time of day in R that I have not been able to find in the documentation. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] boot, what am I doing wrong?
I am getting started with the boot package and boot command. As a first step I tried the following. Something is wrong, but i can't see what. Any advice would be much appreciated. x = runif(10) mean(x) [1] 0.467626212374307 boot(x, mean, R=100) Error in mean.default(data, original, ...) : 'trim' must be numeric of length one Enter a frame number, or 0 to exit 1: boot(x, mean, R = 100) 2: statistic(data, original, ...) 3: mean.default(data, original, ...) 4: stop('trim' must be numeric of length one) 5: (function () { utils::recover() })() When I enter a trim parameter I get the following: boot(x, mean, R=100, trim=0) [...some output omitted...] Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used Warning in if (na.rm) x - x[!is.na(x)] : the condition has length 1 and only the first element will be used ORDINARY NONPARAMETRIC BOOTSTRAP Call: boot(data = x, statistic = mean, R = 100, trim = 0) Bootstrap Statistics : original biasstd. error t1* 0.467626212374307 0 0 When I enter an na.rm value as well the following is output: boot(x, mean, R=100, trim=0, na.rm=T) ORDINARY NONPARAMETRIC BOOTSTRAP Call: boot(data = x, statistic = mean, R = 100, trim = 0, na.rm = T) Bootstrap Statistics : original biasstd. error t1* 0.467626212374307 0 0 Notice that the standard error is 0, indicating that no bootstrapping has actually taken place. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.