Re: [R] [External] Re: Building Packages. (fwd)
[forgot to copy to R-help so re-sending] -- Forwarded message -- Date: Thu, 21 Mar 2024 11:41:52 + From: luke-tier...@uiowa.edu To: Duncan Murdoch Subject: Re: [External] Re: [R] Building Packages. At least on my installed version (which tells me it is out of date) they appear to just be modifying the "package:utils" parent frame of the global search path. There seem to be a few others: checkUtilsFun <- function(n) identical(get(n, "package:utils"), get(n, getNamespace("utils"))) names(which(! sapply(ls("package:utils", all = TRUE), checkUtilsFun))) ## [1] "bug.report" "file.edit""help.request" ## [4] "history" "install.packages" "remove.packages" ## [7] "View" I don't know why they don't put these overrides in the tools:rstudio frame. At least that would make them more visible. You can fix all of these with something like local({ up <- match("package:utils", search()) detach("package:utils") library(utils, pos = up) }) or just install.packages with local({ up <- match("package:utils", search()) unlockBinding("install.packages", pos.to.env(up)) assign("install.packages", utils::install.packages, "package:utils") lockBinding("install.packages", pos.to.env(up)) }) Best, luke On Thu, 21 Mar 2024, Duncan Murdoch wrote: Yes, you're right. The version found in the search list entry for "package:utils" is the RStudio one; the ones found with two or three colons are the original. Duncan Murdoch On 21/03/2024 5:48 a.m., peter dalgaard wrote: Um, what's with the triple colon? At least on my install, double seems to suffice: identical(utils:::install.packages, utils::install.packages) [1] TRUE install.packages function (...) .rs.callAs(name, hook, original, ...) -pd On 21 Mar 2024, at 09:58 , Duncan Murdoch wrote: The good news for Jorgen (who may not be reading this thread any more) is that one can still be sure of getting the original install.packages() by using utils:::install.packages( ... ) with *three* colons, to get the internal (namespace) version of the function. Duncan Murdoch On 21/03/2024 4:31 a.m., Martin Maechler wrote: "Duncan Murdoch on Wed, 20 Mar 2024 13:20:12 -0400 writes: > On 20/03/2024 1:07 p.m., Duncan Murdoch wrote: >> On 20/03/2024 12:37 p.m., Ben Bolker wrote: >>> Ivan, can you give more detail on this? I've heard this >>> issue mentioned, but when I open RStudio and run >>> find("install.packages") it returns >>> "utils::install.packages", and running dump() from >>> within RStudio console and from an external "R >>> --vanilla" gives identical results. >>> >>> I thought at one point this might only refer to the GUI >>> package-installation interface, but you seem to be >>> saying it's the install.packages() function as well. >>> >>> Running an up-to-date RStudio on Linux, FWIW -- maybe >>> weirdness only happens on other OSs? >> >> On MacOS, I see this: >> >> > install.packages function (...) .rs.callAs(name, hook, >> original, ...) >> >> I get the same results as you from find(). I'm not sure >> what RStudio is doing to give a different value for the >> function than what find() sees. > Turns out that RStudio replaces the install.packages > object in the utils package. > Duncan Murdoch Yes, and this has been the case for several years now, and I have mentioned this several times, too (though some of it possibly not in a public R-* mailing list). And yes, that they modify the package environment as.environment("package:utils") but leave the namespace asNamespace("utils") unchanged, makes it harder to see what's going on (but also has less severe consequences; if they kept to the otherwise universal *rule* that the namespace and package must have the same objects apart from those only in the namespace, people would not even have access to R's true install.packages() but only see the RStudio fake^Hsubstitute.. We are still not happy with their decision. Also help(install.packages) goes to R's documentation of R's install.packages, so there's even more misleading of useRs. Martin __ 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.
Re: [R] [External] Function environments serialize to a lot of data until they don't
ed memory computing in general, so there are various tools that help. A very simple tool available in the snow package for snow clusters is snow.time(), which can produce some summary times and a Gantt chart (patterned after ones produced by xpvm and xmpi). For example, going back to the first definition of mkLL1 you can try mkLL1 <- function(m, s) function(x) sum(dnorm(x, m, s, log = TRUE)) ll <- f(1e7) library(snow) cl <- makeCluster(2, type = "SOCK") tm <- snow.time(clusterCall(cl, ll, 1)) print(tm) plot(tm) stopCluster(cl) snow.time() is not very sophisticated, not very well tested, and may be a bit brittle. It has not been not ported to the parallel package, but it looks like most of the plumbing is there so porting it might not be too hard. If this really is due to promises, what would be the downsides of forcing them during serialization? Many. Think NSE, defaults that assume something happens in the body before the are evaluated ... Best, luke -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Re: Error in setwd(dir) when initializing R
On Mon, 20 Nov 2023, Ivan Krylov wrote: On Mon, 20 Nov 2023 12:18:11 +0100 Ana de las Heras Molina wrote: Error in setwd(dir) : no es posible cambiar el directorio de trabajo If you run traceback() first thing after getting this error, does it say anything useful? (Anything besides "No traceback available" would count as useful.) Do you have a file named .RData in your home directory? If yes, it may help to move it away (or remove it if you don't use the saved session). Also check for .Rprofile or other profile that might contain a setwd() call. Starting R with --vanilla should work if the issue is a startup file. Best, luke -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] alist() and missing variables
On Mon, 2 May 2022, Ivan Krylov wrote: Hi, I've been playing around with formals() and stumbled upon some behaviour which surprised me: a <- alist(x=) .Internal(inspect(a$x)) # @55b0ebae67b0 01 SYMSXP g0c0 [MARK,REF(5761)] "" (has value) x <- a$x .Internal(inspect(x)) # Error: argument "x" is missing, with no default missing(x) [1] TRUE Apparently, the elements corresponding to formal arguments without a default value can be passed to functions as arguments (and look like empty symbols, which can't be created by as.symbol()), but when assigned to a variable, they turn missing and can't be accessed. How can I safely detect and work with such values? You can detect them as you did here using missing(). This is what the byte code compiler implementation does. [https://homepage.stat.uiowa.edu/~luke/R/compiler/compiler.pdf] It's not ideal but it's what we have and not likely to change any time soon. Best, luke -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Re: Package installation help: Stuck at "** byte-compile and prepare package for lazy loading"
When I do full CRAN/BIOC installs I use Xvfb via something like Xvfb :5 -screen 0 1280x1024x24 & setenv DISPLAY :5 Best, luke On Thu, 30 Sep 2021, Brodie, Kent via R-help wrote: Bill-- BINGO.You have found the answer. After some testing on one of my environments where it was always hanging, connecting to the same server with an X-Sever running on my workstation did indeed allow the package to be installed. **GOOD LORD THAT’S RIDICULOUS** But at least I know.And why it doesn’t error out without X running, who knows. After a ton more research, I ALSO discovered that there IS a timeout thing I can make use of, should I decide to continue just building things and ignoring the X-Server requirement for this (and probably some other?) packages. Before executing R and installing things, set this: export _R_INSTALL_PACKAGES_ELAPSED_TIMEOUT_=500 (value is seconds). So, the previously-hanging R CMD INSTALL inside of the install.packages call will eventually die, and then move on to the next package. This is buried in the documentation but- it’s there and I confirmed it works. My example above times out a package install at 5 minutes. While knowing the X requirement is a huge win (thanks again!), I will probably stick with just using the timeout thing for what I’m trying to accomplish. Installing EVERYTHING from cran will take forever, and more than likely my VPN connection to my data center will be disconnected (thank you internal IT department) before it finishes.They have some sort of internal “you’ve been connected too long” timer that disconnects things overnight. Grr. [[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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Handling interrupts in long-running R functions
Some variation of this might do it: tryCatch(for (i in seq_len(100)) Sys.sleep(1), interrupt = function(e) i) If you want the option to inspect and continue you would need to use withCallingHandlers and invoke a 'resume' restart. Best, luke On Fri, 10 Sep 2021, Ivan Krylov wrote: Hello everyone, I'm writing an R function that may be running for "long" periods of time (think tens of minutes), and I would like to be able to tell it: "please stop what you're doing and return the not-yet converged results as they are for inspection". The behaviour I'm striving for is 1) User presses interrupt 2) Function handles the interrupt and returns as if the convergence test passed 3) By some black magic, the interrupt condition is raised on the previous function call level (to avoid the situation where my function is called in a loop by some other function and the user wants to interrupt the whole process, not just my function). Is this a good idea? Is (3) even possible? (I guess I could check the length of sys.parents() and avoid recovering from the interrupt if called from some other function, but that feels dirty.) Could something similar be achieved with options(error = recover) and R restarts? Are there other ways of, well, interrupting the execution of R functions without changing the semantics of interrupts in R? I've been working with MATLAB lately (when in Rome, do as Romans do...), and their idiom for my desired behaviour is "create a plot window and return when that window is closed", but that doesn't translate well to R. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Unexplained behaviour of .Last.value
Thanks for the report. Fixed in R-devel in r80530; will port to R-patched soon. Best, luke On Fri, 18 Jun 2021, Bickis, Mikelis wrote: Hello: Here is a bit of R-code: mvr [1] 2.2658 (sin(.Last.value)+sin(2*.Last.value)) [1] -0.2156507 acos((-sqrt(17)-1)/8) [1] 2.2658 (sin(.Last.value)+sin(2*.Last.value)) [1] 1.76745 (sin(mvr)+sin(2*mvr)) [1] -0.2156507 Note that my variable mvr is the value of acos((-sqrt(17)-1)/8). However, if I use .Last.value after invoking the acos function in a further calculation, I get a nonsensical result. What is going on? I am running R version 4.0.0 (2020-04-24) on an iMac, operating system MacOS 11.4 “Big Sur”. Mik Bickis __ 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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Why is R making a copy-on-modification after using str?
On Mon, 30 Nov 2020, luke-tier...@uiowa.edu wrote: On Mon, 30 Nov 2020, Georg Kindermann wrote: Dear list members, I was wondering why R is making a copy-on-modification after using str. m <- matrix(1:12, 3) tracemem(m) #[1] "<0x559df861af28>" dim(m) <- 4:3 m[1,1] <- 0L m[] <- 12:1 str(m) # int [1:4, 1:3] 12 11 10 9 8 7 6 5 4 3 ... dim(m) <- 3:4 #Here after str a copy is made #tracemem[0x559df861af28 -> 0x559df838e4a8]: dim(m) <- 3:4 str(m) # int [1:3, 1:4] 12 11 10 9 8 7 6 5 4 3 ... dim(m) <- 3:4 #Here again after str a copy #tracemem[0x559df838e4a8 -> 0x559df82c9d78]: As of R 4.0.0 it is in some cases possible to reduce reference counts internally and so avoid a copy in cases like this. It would be too costly to try to detect all cases where a count can be dropped, but it this case we can do better. It turns out that the internals of pos.to.env were unnecessarily creating an extra reference to the call environment (here in a call to exists()). This is fixed in r79528. Thanks. Also I was wondering why a copy is made when having a Task Callback. TCB <- addTaskCallback(function(...) TRUE) m <- matrix(1:12, nrow = 3) tracemem(m) #[1] "<0x559dfa79def8>" dim(m) <- 4:3 #Copy on modification #tracemem[0x559dfa79def8 -> 0x559dfa8998e8]: removeTaskCallback(TCB) #[1] TRUE dim(m) <- 4:3 #No copy This _may_ be related to references created in the process of protecting the return value from evaluation. If so, addressing the debug issue raised by Duncan may resolve this. If not, someone will have to take a closer look. It turns out there were some issues with the way calls to the callbacks were handled. This has been revised in R-devel in r79541. This example will no longere need to duplicate in R-devel. Thanks for the report. luke Best, luke I am using R version 4.0.3. Kind regards, Georg __ 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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Re: Why is R making a copy-on-modification after using str?
On Mon, 30 Nov 2020, Duncan Murdoch wrote: On 30/11/2020 5:12 a.m., Georg Kindermann wrote: Dear list members, I was wondering why R is making a copy-on-modification after using str. This isn't really an explanation, but adds a bit more data. If you inspect m before and after str(), you'll see that str(m) leaves it with two references: m <- matrix(1:12, 3) .Internal(inspect(m)) @7fcb0ad682c8 13 INTSXP g0c4 [REF(1),ATT] (len=12, tl=0) 1,2,3,4,5,... ATTRIB: @7fcaf5f7b8a0 02 LISTSXP g0c0 [REF(1)] TAG: @7fcafd091a80 01 SYMSXP g1c0 [MARK,REF(65535),LCK,gp=0x6000] "dim" (has value) @7fcb0afecc80 13 INTSXP g0c1 [REF(65535)] (len=2, tl=0) 3,4 str(m) int [1:3, 1:4] 1 2 3 4 5 6 7 8 9 10 ... .Internal(inspect(m)) @7fcb0ad682c8 13 INTSXP g0c4 [REF(2),ATT] (len=12, tl=0) 1,2,3,4,5,... ATTRIB: @7fcaf5f7b8a0 02 LISTSXP g0c0 [REF(1)] TAG: @7fcafd091a80 01 SYMSXP g1c0 [MARK,REF(65535),LCK,gp=0x6000] "dim" (has value) @7fcb0afecc80 13 INTSXP g0c1 [REF(65535)] (len=2, tl=0) 3,4 It's not just str(): this sequence also does it. m <- matrix(1:12, 3) debug(mean) mean(m) This is due to the restarts needed by do_browser() creating links to the environment that could be cleaned up in endcontext. There is a runtime cost to doing so, but probably worth looking into. Best, luke Hit c a couple of times now to get out of debugging, and m is left with two references to it. I don't see that if mean isn't being debugged. Duncan Murdoch m <- matrix(1:12, 3) tracemem(m) #[1] "<0x559df861af28>" dim(m) <- 4:3 m[1,1] <- 0L m[] <- 12:1 str(m) # int [1:4, 1:3] 12 11 10 9 8 7 6 5 4 3 ... dim(m) <- 3:4 #Here after str a copy is made #tracemem[0x559df861af28 -> 0x559df838e4a8]: dim(m) <- 3:4 str(m) # int [1:3, 1:4] 12 11 10 9 8 7 6 5 4 3 ... dim(m) <- 3:4 #Here again after str a copy #tracemem[0x559df838e4a8 -> 0x559df82c9d78]: Also I was wondering why a copy is made when having a Task Callback. TCB <- addTaskCallback(function(...) TRUE) m <- matrix(1:12, nrow = 3) tracemem(m) #[1] "<0x559dfa79def8>" dim(m) <- 4:3 #Copy on modification #tracemem[0x559dfa79def8 -> 0x559dfa8998e8]: removeTaskCallback(TCB) #[1] TRUE dim(m) <- 4:3 #No copy I am using R version 4.0.3. Kind regards, Georg __ 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-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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Why is R making a copy-on-modification after using str?
On Mon, 30 Nov 2020, Georg Kindermann wrote: Dear list members, I was wondering why R is making a copy-on-modification after using str. m <- matrix(1:12, 3) tracemem(m) #[1] "<0x559df861af28>" dim(m) <- 4:3 m[1,1] <- 0L m[] <- 12:1 str(m) # int [1:4, 1:3] 12 11 10 9 8 7 6 5 4 3 ... dim(m) <- 3:4 #Here after str a copy is made #tracemem[0x559df861af28 -> 0x559df838e4a8]: dim(m) <- 3:4 str(m) # int [1:3, 1:4] 12 11 10 9 8 7 6 5 4 3 ... dim(m) <- 3:4 #Here again after str a copy #tracemem[0x559df838e4a8 -> 0x559df82c9d78]: As of R 4.0.0 it is in some cases possible to reduce reference counts internally and so avoid a copy in cases like this. It would be too costly to try to detect all cases where a count can be dropped, but it this case we can do better. It turns out that the internals of pos.to.env were unnecessarily creating an extra reference to the call environment (here in a call to exists()). This is fixed in r79528. Thanks. Also I was wondering why a copy is made when having a Task Callback. TCB <- addTaskCallback(function(...) TRUE) m <- matrix(1:12, nrow = 3) tracemem(m) #[1] "<0x559dfa79def8>" dim(m) <- 4:3 #Copy on modification #tracemem[0x559dfa79def8 -> 0x559dfa8998e8]: removeTaskCallback(TCB) #[1] TRUE dim(m) <- 4:3 #No copy This _may_ be related to references created in the process of protecting the return value from evaluation. If so, addressing the debug issue raised by Duncan may resolve this. If not, someone will have to take a closer look. Best, luke I am using R version 4.0.3. Kind regards, Georg __ 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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Re: help with web scraping
Maybe try something like this: url <- "https://s1.sos.mo.gov/CandidatesOnWeb/DisplayCandidatesPlacement.aspx?ElectionCode=750004975; h <- xml2::read_html(url) tbl <- rvest::html_table(h) Best, luke On Fri, 24 Jul 2020, Spencer Graves wrote: Hi Bill et al.: That broke the dam: It gave me a character vector of length 1 consisting of 218 KB. I fed that to XML::readHTMLTable and purrr::map_chr, both of which returned lists of 337 data.frames. The former retained names for all the tables, absent from the latter. The columns of the former are all character; that's not true for the latter. Sadly, it's not quite what I want: It's one table for each office-party combination, but it's lost the office designation. However, I'm confident I can figure out how to hack that. Thanks, Spencer Graves On 2020-07-23 17:46, William Michels wrote: Hi Spencer, I tried the code below on an older R-installation, and it works fine. Not a full solution, but it's a start: library(RCurl) Loading required package: bitops url <- "https://s1.sos.mo.gov/CandidatesOnWeb/DisplayCandidatesPlacement.aspx?ElectionCode=750004975; M_sos <- getURL(url) print(M_sos) [1] "\r\n\r\n\r\n\r\n\r\n\tSOS, Missouri - Elections: Offices Filed in Candidate Filing\r\n wrote: Hello, All: I've failed with multiple attempts to scrape the table of candidates from the website of the Missouri Secretary of State: https://s1.sos.mo.gov/CandidatesOnWeb/DisplayCandidatesPlacement.aspx?ElectionCode=750004975 I've tried base::url, base::readLines, xml2::read_html, and XML::readHTMLTable; see summary below. Suggestions? Thanks, Spencer Graves sosURL <- "https://s1.sos.mo.gov/CandidatesOnWeb/DisplayCandidatesPlacement.aspx?ElectionCode=750004975; str(baseURL <- base::url(sosURL)) # this might give me something, but I don't know what sosRead <- base::readLines(sosURL) # 404 Not Found sosRb <- base::readLines(baseURL) # 404 Not Found sosXml2 <- xml2::read_html(sosURL) # HTTP error 404. sosXML <- XML::readHTMLTable(sosURL) # List of 0; does not seem to be XML sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Catalina 10.15.5 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets [6] methods base loaded via a namespace (and not attached): [1] compiler_4.0.2 tools_4.0.2curl_4.3 [4] xml2_1.3.2 XML_3.99-0.3 __ 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-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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Re: read.csv fails in R console in Ubuntu terminal but works in RStudio after R 3.6.3 upgrade to R 4.0.2?
TXG 10x Genomics, Inc. 87.4400 $8.6B20192 YI 111, Inc. 6.4800 $533.69M20183 PIH 1347 Property Insurance Holdings, Inc. 4.5350 $27.52M2014 sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.4 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages:[1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached):[1] compiler_4.0.2 tools_4.0.2 *Fails in R console in terminal* > read.csv("https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0=1=download;, header=TRUE, as.is=TRUE, na="n/a") Error in file(file, "rt") : cannot open the connection to 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0=1=download' In addition: Warning message: In file(file, "rt") : URL 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0=1=download': status was 'Failure when receiving data from the peer'> traceback()3: file(file, "rt")2: read.table(file = file, header = header, sep = sep, quote = quote, dec = dec, fill = fill, comment.char = comment.char, ...)1: read.csv("https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0=1=download;, header = TRUE, as.is = TRUE, na = "n/a")> sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.4 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages:[1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached):[1] compiler_4.0.2> I also asked this question here https://stackoverflow.com/questions/62898008/why-read-csv-fails-in-r-console-in-ubuntu-terminal-but-works-in-rstudio-after-r . Since there was no answer on stackoverflow I sent this question also to this list. Best regards, Sam [[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-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-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-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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Re: Strange behavior when sampling rows of a data frame
d 4 have disappeared, for instance, and > there are duplicates for 6 and 9, one assigned to treatment and the other > to control. Why would this happen? > > Thanks, > Sebastien > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org <mailto: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. -- Este e-mail foi verificado em termos de vírus pelo software antivírus Avast. https://www.avast.com/antivirus __ R-help@r-project.org <mailto: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. -- Este e-mail foi verificado em termos de vírus pelo software antivírus Avast. https://www.avast.com/antivirus [[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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] [External] Re: A stopifnot() nastiness, even if not a bug
t;>> maech...@stat.math.ethz.ch> wrote: >>> > >> >>> > >>>>>>> Bert Gunter >>> > >>>>>>> on Sun, 12 Apr 2020 16:30:09 -0700 writes: >>> > >> >>> > >>> Don't know if this has come up before, but ... >>> > >>>> x <- c(0,0) >>> > >>>> length(x) >>> > >>> [1] 2 >>> > >>> ## but >>> > >>>> stopifnot(length(x)) >>> > >>> Error: length(x) is not TRUE >>> > >>> Called from: top level >>> > >>> ## but >>> > >>>> stopifnot(length(x) > 0) ## not an error; nor is >>> > >>>> stopifnot(as.logical(length(x))) >>> > >>> ## Ouch! >>> > >> >>> > >>> Maybe the man page should say something about not assuming >>> automatic >>> > >>> coercion to logical, which is the usual expectation. Or fix >>> this. >>> > >> >>> > >>> Bert Gunter >>> > >> >>> > >> Well, what about the top most paragraph of the help page is not >>> clear here ? >>> > >> >>> > >>> Description: >>> > >> >>> > >>> If any of the expressions (in '...' or 'exprs') are not 'all' >>> > >>> 'TRUE', 'stop' is called, producing an error message indicating >>> > >>> the _first_ expression which was not ('all') true. >>> > >> >>> > >>> > > This, however, is somewhat less clear: >>> > >>> > > ..., exprs: any number of (typically but not necessarily >>> ‘logical’) R >>> > > expressions, which should each evaluate to (a logical vector >>> > > of all) ‘TRUE’. Use _either_ ‘...’ _or_ ‘exprs’, the latter >>> > >>> > > What does it mean, "typically but not necessarily ‘logical’"? >>> > >>> > That's a good question: The '()' must have been put there a while >>> ago. >>> > I agree that it's not at all helpful. Strictly, we are really >>> > dealing with unevaluated expressions anyway ("promises"), but >>> > definitely all of them must evaluate to logical (vector or >>> > array..) of all TRUE values. In the very beginning of >>> > stopifnot(), I had thought that it should also work in other >>> > cases, e.g., forMatrix(TRUE, 4,5) {from the Matrix package} etc, >>> > but several use cases had convinced us / me that stopifnot >>> > should be stricter... >>> > >>> > > The code actually tests explicitly with is.logical, as far as I >>> can tell. >>> > >>> > > This creates a discrepancy between if(!...)stop(...) and >>> stopifnot(), >>> > >>> > yes indeed, on purpose now, for a very long time ... >>> > >>> > There's another discrepancy, more dangerous I think, >>> > as shown in the following >>> > {Note this discrepancy has been noted for a long time .. also on >>> > this R-devel list} : >>> > >>> >m <- matrix(1:12, 3,4) >>> >i <- (1:4) %% 2 == 1 & (0:3) %% 5 == 0 >>> > >>> >stopifnot(dim(m[,i]) == c(3,1)) # seems fine >>> > >>> >if(dim(m[,i]) != c(3,1)) stop("wrong dim") # gives an error (but not >>> ..) >>> >>> mmh... that is not good. I was under the impression that we could at >>> least expect 'stopifnot(x)' to be equivalent to 'if (!isTRUE(x)) >>> stop(...)'. I'll have to revisit my use of stopifnot() in many many >>> places... again :-/ Or may be just stop using it and use 'if >>> (!isTRUE(...))' instead. >>> >>> H. >>> >>> > >>> > >>> > Martin >>> > >>> > >> as in >>> > >> f <- function (x) if (!x) stop(paste(deparse(substitut
Re: [R] [External] Re: Error in colouring by group in core plot R
Or using matplot: matplot(cbind(g1, g2, g3), type = "l", col = c("red", "black", "blue"), lty = 1, lwd = 2) Best, luke On Fri, 24 Apr 2020, Jim Lemon wrote: Hi Luigi, This is pretty easy using "plot" and "lines": # assume your example data plot(g1,col ="red",type = "l", lwd = 2, xlab = "Days since start", ylab = "Count of infections", main = "Daily cases of COVID-19") lines(g2,col="black", lwd = 2) lines(g3,col="blue", lwd = 2) text(c(15,80,53),rep(6000,3), c("China","Germany","Italy"),col=c("red","black","blue")) Jim On Fri, Apr 24, 2020 at 5:25 PM Luigi Marongiu wrote: Hello, I am trying to make an epidemic plot of the COVID pandemic using the core plot function. I am looking at three countries and the countries are as factors. The idea is to colour the entry by country, following this scheme: ``` df = data.frame(index = 1:10, value = c(rnorm(10), rnorm(10), rnorm(10)), set = c(rep("Group 1", 3), rep("Group 2", 3), rep("Group 3", 4))) plot(df$index ~ df$value, col=c("blue", "orange", "purple")[df$set]) ``` But in the actual graph there is only one colour: ``` Index = c(1:101) g1 = c(0,259,457,688,769,1771,1459,1737,1981,2099,2589,2825,3235,3884,3694, 3143,3385,2652,2973,2467,2015,14108,5090,2641,2008,2048,1888,1749,391, 889,823,648,214,508,406,433,327,427,573,202,125,119,139,143,99,44,40, 0,0,0,0,0,0,0,0,0,0,0,0,46,39,78,47,67,55,54,45,0,79,36,35,0,0,0,39,0, 0,63,42,46,99,108,89,46,46,0,325,0,0,0,0,0,0,0,0,0,0,0,0,0,0) g2 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,59,283,125,130,240,184,341,401,779,930,924,1214,1459, 2095,2960,2993,4528,2516,2509,4183,3935,4332,6615,6933,6824,4740, 4450,4923,6173,6813,6365,4933,4031,3252,4288,5633,4939,3936,3281, 2402,2218,2138,2543,2945,3699,2327,2018,1323,1388,2195,2481,0,0, 0,0,0,0,0,0) g3= c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58, 78,72,94,147,185,234,239,573,335,466,587,769,778,1247,1492,1797,977, 2313,2651,2547,3497,3590,3233,3526,4207,5322,5986,6557,5560,4789, 5249,5210,6203,5909,5974,5217,4050,4053,4782,4668,4585,4805,4316, 3599,3039,3836,4204,3951,4694,4092,3153,3961,2667,3786,3493,3491, 3047,2256,2729,3370,2646,0,0,0,0,0,0,0,0) Incidence = c(g1, g2, g3) Country = c(rep("China", length(Index)), rep("Germany", length(Index)), rep("Italy", length(Index))) df = data.frame(Index, Incidence, Country) plot(df$Incidence ~ df$Index, col = c("red", "black", "blue")[df$Country], type = "l", lwd = 2, xaxt = "n", xlab = expression(bold("Date")), ylab = expression(bold("Incidence")), main = "Raw values") ``` What am I missing? Thank you -- Best regards, Luigi [[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-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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] R 3.5.0, vector memory exhausted error on readBin
oject, and after upgrading to R 3.5.0, the code returns an error indicating that the 'vector memory is exhausted???. I???m happy to provide a sample binary file; even ones that are quite small (12 MB) generate this error. (I wasn???t sure whether a binary file attached to this email would trigger a spam filter.) bin.read = file(files[i], "rb???) datavals = readBin(bin.read, integer(), size = 2, n = 8*hertz*60*6, endian = "little???) Error: vector memory exhausted (limit reached?) sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Sierra 10.12.6 This does not happen in R 3.4 (R version 3.4.4 (2018-03-15) -- "Someone to Lean On???) - the vector is created and populated by the binary file values without issue, even at a 1GB binary file size. Other files that are read in as csv files, even at 1GB, load correctly to 3.5, so I assume that this is a function of a vector being explicitly defined/changed in some way from 3.4 to 3.5. Any help, suggestions or workarounds are greatly appreciated! Val [[alternative HTML version deleted]] -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] R 3.5.0, vector memory exhausted error on readBin
explicitly defined/changed in some way from 3.4 to 3.5. Any help, suggestions or workarounds are greatly appreciated! Val [[alternative HTML version deleted]] -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] R 3.5.0, vector memory exhausted error on readBin
This item in NEWS explains the change: • The environment variable R_MAX_VSIZE can now be used to specify the maximal vector heap size. On macOS, unless specified by this environment variable, the maximal vector heap size is set to the maximum of 16GB and the available physical memory. This is to avoid having the R process killed when macOS over-commits memory. You can set R_MAX_VSIZE to a larger value but you should do some experimenting to decide on a safe value for your system. Mac OS is quite good at using virtual memory up to a point but then gets very bad. For my 4 GB mac numeric(8e9) works but numeric(9e9) causes R to be killed, so a setting of around 60GB _might_ be safe. File size probably doesn't matter in your example since you are setting a large value for n - I can't tell how large since you didn't provide your value of 'hertz'. Best, luke On Mon, 11 Jun 2018, Valerie Cavett wrote: I???ve been reading in binary data collected via LabView for a project, and after upgrading to R 3.5.0, the code returns an error indicating that the 'vector memory is exhausted???. I???m happy to provide a sample binary file; even ones that are quite small (12 MB) generate this error. (I wasn???t sure whether a binary file attached to this email would trigger a spam filter.) bin.read = file(files[i], "rb???) datavals = readBin(bin.read, integer(), size = 2, n = 8*hertz*60*6, endian = "little???) Error: vector memory exhausted (limit reached?) sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Sierra 10.12.6 This does not happen in R 3.4 (R version 3.4.4 (2018-03-15) -- "Someone to Lean On???) - the vector is created and populated by the binary file values without issue, even at a 1GB binary file size. Other files that are read in as csv files, even at 1GB, load correctly to 3.5, so I assume that this is a function of a vector being explicitly defined/changed in some way from 3.4 to 3.5. Any help, suggestions or workarounds are greatly appreciated! Val [[alternative HTML version deleted]] -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Problem with geterrmessage()
Only the default error handler puts the error message in a buffer where it can be retrieved with geterrmessage. try() replaces the default error handler. Either look at the value returned by try() or use tryCatch with conditionMessage. Best, luke On Thu, 22 Feb 2018, Dennis Fisher wrote: R 3.4.3 OS X Colleagues I have a 20K line script in which I encounter an unexpected problem. If the script detects presence of a particular file USERCODE.txt, it executes: source(“USERCODE.txt”) If that file is not present, the script executes without a problem. There might be syntax errors in USERCODE.txt; therefore, the code above is embedded in a try command: try(source(“USERCODE.txt", local=T), silent=T) followed by: ERRORMESSAGE <- geterrmessage() For unclear reasons, an earlier command is yielding an error message: unused argument (\"\\n\") Despite identifying the exact source of that error, I can’t fix it (and it is of no consequence). Ideally, I would like to clear out the pre-existing error message immediately before the “try” command (or perhaps at that particular location where it is being created) — but I can’t figure out how to do so. Any suggestions would be welcome. Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com __ 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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Memory not release when an environment is created
On Thu, 22 Sep 2016, luke-tier...@uiowa.edu wrote: My preference is to use a top level function in the package or global env that takes as arguments just the variables I want in the parent frame. That avoids the explicit environment manipulations. Here that would be makeFunc0 <- function(xmin, xmax) function(y) (y - xmin) / (xmax - xmin) But I do keep forgetting the need to force the parameters if you don't want a big value to stick around until the returned function is used the first time, so a better definition of makeFUnc0 is makeFunc0 <- function(xmin, xmax) { force(xmin) force(xmax) function(y) (y - xmin) / (xmax - xmin) } Best, luke makeFunc1 <- function(x) makeFunc0(min(x), max(x)) f <- makeFunc1(1:1e8) ls.str(all=TRUE, environment(f)) xmax : int 1 xmin : int 1 parent.env(environment(f)) f(c(1234567, 2345678)) [1] 0.01234566 0.02345677 Best, luke On Thu, 22 Sep 2016, William Dunlap via R-help wrote: I like to have my function-returning functions use new.env(parent=XXX) to make an environment for the returned function and put into it only the objects needed by the function. The 'XXX' should be a an environment which will hang around anyway. It could be globalenv(), but if your function is in a package, as.environment(paste0("package:", .packageName)) would work well. The later ensures the your returned function has access to all the other functions in that package. E.g., makeFunc1 <- function(x) { envir <- new.env(parent = environment(sys.function())) envir$xmax <- max(x) envir$xmin <- min(x) with(envir, function(y) (y - xmin) / (xmax - xmin)) } f <- makeFunc1(1:1e8) ls.str(all=TRUE, environment(f)) xmax : int 1 xmin : int 1 parent.env(environment(f)) f(c(1234567, 2345678)) [1] 0.01234566 0.02345677 Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Sep 22, 2016 at 8:41 AM, Olivier Merle <oliviermerl...@gmail.com> wrote: Dear, When I use big data for a temporary use it seems that the memory is not released when a function/environement is created nearby. Here the reproducible exemple: test<-function(){ x=matrix(0,5,1) y=function(nb) nb^2 return(y) } xx=test() # 3 Go of Ram is used gc() # Memory is not released !! even if x has been destroyed [look into software mem used] format(object.size(xx),units="auto") # 1.4 KiB => R is worng on the size of the object rm(xx) gc() # Memory is released ## Classic test2<-function(){ x=matrix(0,5,1) y=1 return(y) } xx=test2() # Memory is used gc() # => Memory is released How can I release the data in test without destroying the xx object ? As x which is big object is destroyed, I though I could get my memory back but it seems that the function y is keeping the x object. Best [[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. [[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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Memory not release when an environment is created
My preference is to use a top level function in the package or global env that takes as arguments just the variables I want in the parent frame. That avoids the explicit environment manipulations. Here that would be makeFunc0 <- function(xmin, xmax) function(y) (y - xmin) / (xmax - xmin) makeFunc1 <- function(x) makeFunc0(min(x), max(x)) f <- makeFunc1(1:1e8) ls.str(all=TRUE, environment(f)) xmax : int 1 xmin : int 1 parent.env(environment(f)) f(c(1234567, 2345678)) [1] 0.01234566 0.02345677 Best, luke On Thu, 22 Sep 2016, William Dunlap via R-help wrote: I like to have my function-returning functions use new.env(parent=XXX) to make an environment for the returned function and put into it only the objects needed by the function. The 'XXX' should be a an environment which will hang around anyway. It could be globalenv(), but if your function is in a package, as.environment(paste0("package:", .packageName)) would work well. The later ensures the your returned function has access to all the other functions in that package. E.g., makeFunc1 <- function(x) { envir <- new.env(parent = environment(sys.function())) envir$xmax <- max(x) envir$xmin <- min(x) with(envir, function(y) (y - xmin) / (xmax - xmin)) } f <- makeFunc1(1:1e8) ls.str(all=TRUE, environment(f)) xmax : int 1 xmin : int 1 parent.env(environment(f)) f(c(1234567, 2345678)) [1] 0.01234566 0.02345677 Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Sep 22, 2016 at 8:41 AM, Olivier Merle <oliviermerl...@gmail.com> wrote: Dear, When I use big data for a temporary use it seems that the memory is not released when a function/environement is created nearby. Here the reproducible exemple: test<-function(){ x=matrix(0,5,1) y=function(nb) nb^2 return(y) } xx=test() # 3 Go of Ram is used gc() # Memory is not released !! even if x has been destroyed [look into software mem used] format(object.size(xx),units="auto") # 1.4 KiB => R is worng on the size of the object rm(xx) gc() # Memory is released ## Classic test2<-function(){ x=matrix(0,5,1) y=1 return(y) } xx=test2() # Memory is used gc() # => Memory is released How can I release the data in test without destroying the xx object ? As x which is big object is destroyed, I though I could get my memory back but it seems that the function y is keeping the x object. Best [[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. [[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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] interaction between clusterMap(), read.csv() and try() - try does not catch error
try is working fine. The problem is that your remote function is returning the try-error result, which the parallel infrastructure is interpreting as an error on the remote node, since the remote calling infrastructure is using try as well. This could be implemented more robustly, but it would probably be better in any case your code to use can use tryCatch and have the error. function return something easier to work with, like NULL. Best, luke On Mon, 8 Aug 2016, Strunk, Jacob (DNR) wrote: Hello I am attempting to process a list of csv files in parallel, some of which may be empty and fail with read.csv. I tend to use clusterMap as my go-to parallel function but have run into an interesting behavior. The behavior is that try(read.csv(x)) does not catch read errors resulting from having an empty csv file inside of clusterMap. I have not tested this with other functions (e.g. read.table, mean, etc.). The parLapply function does, it appears, correctly catch the errors. Any suggestions on how I should code with clusterMap such that try is guaranteed to catch the error? I am working on windows server 2012 I have the latest version of R and parallel I am executing the code from within the rstudio ide Version 0.99.896 Here is a demonstration of the failure R code used in demonstration: #prepare csv files - an empty file and a file with data close(file("c:/temp/badcsv.csv",open="w")) write.table(data.frame(x=2),"c:/temp/goodcsv.csv") #prepare a parallel cluster clus0=makeCluster(1, rscript_args = "--no-site-file") #read good / bad files in parallel with parLapply - which succeeds: try Does catch err x1=parLapply(clus0,c("c:/temp/badcsv.csv","c:/temp/goodcsv.csv"),function(...)try(read.csv(...))) print(x1) #read good / bad files in parallel with clusterMap - which fails: try does Not catch error x0=clusterMap(clus0,function(...)try(read.csv(...)),c("c:/temp/badcsv.csv","c:/temp/goodcsv.csv"),SIMPLIFY=F) print(x0) R output: #prepare csv files - an empty file and a file with data close(file("c:/temp/badcsv.csv",open="w")) write.table(data.frame(x=2),"c:/temp/goodcsv.csv") #prepare a parallel cluster clus0=makeCluster(1, rscript_args = "--no-site-file") #read good / bad files in parallel with parLapply - which succeeds: try Does catch err x1=parLapply(clus0,c("c:/temp/badcsv.csv","c:/temp/goodcsv.csv"),function(...)try(read.csv(...))) print(x1) [[1]] [1] "Error in read.table(file = file, header = header, sep = sep, quote = quote, : \n no lines available in input\n" attr(,"class") [1] "try-error" attr(,"condition") [[2]] x 1 1 2 #read good / bad files in parallel with clusterMap - which fails: try does Not catch error x0=clusterMap(clus0,function(...)try(read.csv(...)),c("c:/temp/badcsv.csv","c:/temp/goodcsv.csv"),SIMPLIFY=F) Error in checkForRemoteErrors(val) : one node produced an error: Error in read.table(file = file, header = header, sep = sep, quote = quote, : no lines available in input print(x0) Error in print(x0) : object 'x0' not found Thanks for any help, Jacob [[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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Fwd: Help: malloc/free deadlock in unsafe signal handler 'Rf_onsigusr1'
The handlers for SIGUSR1 and SIGUSR2 are really intended as an emergency break, not for ordinary programming. These could be rewritten to be safer but that would make them less immediate. Followups would be more appropriate on R-devel. Best, luke On Mon, 1 Aug 2016, Ming Li wrote: Hi all, I am working on a bug, which running PLR on HAWQ. The process hung and can't be terminated. From my investigation, it seems signal handler 'Rf_onsigusr1' trigger a malloc/free deadlock. The calling stack is below. Thread 1 (Thread 0x7f4c93af48e0 (LWP 431263)): #0 0x7f4c9015805e in __lll_lock_wait_private () from /lib64/libc.so.6 #1 0x7f4c900dd16b in _L_lock_9503 () from /lib64/libc.so.6 #2 0x7f4c900da6a6 in malloc () from /lib64/libc.so.6 #3 0x7f4c9008fb39 in _nl_make_l10nflist () from /lib64/libc.so.6 #4 0x7f4c9008ddf5 in _nl_find_domain () from /lib64/libc.so.6 #5 0x7f4c9008d6e0 in __dcigettext () from /lib64/libc.so.6 #6 0x7f4c6fabcfe3 in Rf_onsigusr1 () from /usr/local/lib64/R/lib/libR.so #7 #8 0x7f4c9014079a in brk () from /lib64/libc.so.6 #9 0x7f4c90140845 in sbrk () from /lib64/libc.so.6 #10 0x7f4c900dd769 in __default_morecore () from /lib64/libc.so.6 #11 0x7f4c900d87a2 in _int_free () from /lib64/libc.so.6 #12 0x00b3ff24 in gp_free2 () #13 0x00b356fc in AllocSetDelete () #14 0x00b38391 in MemoryContextDeleteImpl () #15 0x0077c851 in ExecEndAgg () #16 0x007592ad in ExecEndNode () #17 0x0075186c in ExecEndPlan () #18 0x0079dffa in ExecEndSubqueryScan () #19 0x0075921d in ExecEndNode () #20 0x0075186c in ExecEndPlan () #21 0x00752565 in ExecutorEnd () #22 0x006dd9bd in PortalCleanup () #23 0x00b3f077 in AtCommit_Portals () #24 0x0051abe5 in CommitTransaction () #25 0x0051f1d5 in CommitTransactionCommand () #26 0x0099809e in PostgresMain () #27 0x008f1031 in BackendStartup () #28 0x008f70e0 in PostmasterMain () #29 0x007f63da in main () I googled and found below info maybe useful to fix it: The best way to avoid this kind of deadlock is to Call only asynchronous-safe functions within signal handlers. https://www.securecoding.cert.org/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers Thanks a lot. [[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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] C stack error in as.vector() starting in R 3.3.0
sion... # *** Restart R for this to work *** rm(list = ls()) load("fixed.method.rdata") as.vector(problem.method@defined, "character") [1] "gtypes" *Eric Archer, Ph.D.* Southwest Fisheries Science Center NMFS, NOAA 8901 La Jolla Shores Drive La Jolla, CA 92037 USA 858-546-7121 (work) 858-546-7003 (FAX) Marine Mammal Genetics Group: swfsc.noaa.gov/mmtd-mmgenetics ETP Cetacean Assessment Program: swfsc.noaa.gov/mmtd-etp https://github/ericarcher " *The universe doesn't care what you believe. The wonderful thing about science is that it doesn't ask for your faith, it just asks for your eyes.*" - Randall Munroe "*Lighthouses are more helpful than churches.*" - Benjamin Franklin "*...but I'll take a GPS over either one.*" - John C. "Craig" George [[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. -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] snow/Rmpi without MPI.spawn?
on the guy providing the code (grep for for loops, and look for that copy-and-append pattern) might save you from having to use parallel evaluation at all. Martin Thanks, Jim __ 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-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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] lapply returns NULL ?
Another option is Filter(function(x) x[1] == 1, foo) Best, luke On Sat, 12 Jul 2014, ce wrote: Thanks Jeff et. all, This is exactly what I needed. -Original Message- From: Jeff Newmiller [jdnew...@dcn.davis.ca.us] Date: 07/12/2014 10:38 AM To: Uwe Ligges lig...@statistik.tu-dortmund.de, ce zadi...@excite.com, r-help@r-project.org Subject: Re: [R] lapply returns NULL ? I think that removing them is something the OP doesn't understand how to do. The lapply function ALWAYS produces an output element for every input element. If this is not what you want then you need to choose a looping structure that is not so tightly linked to the input, such as a for loop (untested): result - list() for (nm in names(foo)) { if ( 1 == foo[[nm]][1] ) { result[[ nm ]] - foo[[ nm ]] } } result or use vector indexing (lists are a special kind of vector) with the loop result: foo[ sapply(foo,function(v){1==v[1]}) ] --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On July 12, 2014 6:37:44 AM PDT, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 12.07.2014 15:25, ce wrote: Dear all, I have a list of arrays : foo-list(A = c(1,3), B =c(1, 2), C = c(3, 1)) foo $A [1] 1 3 $B [1] 1 2 $C [1] 3 1 if( foo$C[1] == 1 ) foo$C[1] lapply(foo, function(x) if(x[1] == 1 ) x ) $A [1] 1 3 $B [1] 1 2 $C NULL I don't want to list $C NULL in the output. How I can do that ? Either use your own print function or, if you do not want NULL elements in the object, remove them. Best, Uwe Ligges __ 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-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-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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Performance issue with attributes
You can also upgrade to R-devel or to R 3.1.0 due out in a month or so -- those will run this code much more efficiently. Using setattr is OK if you really know what you are doing, but if you are not careful using it can modify objects you do not intend to modify. Best, luke On Tue, 11 Mar 2014, Smart Guy wrote: Apologies for the late reply. I was out on vacation. I tried setattr() from data.table package and it worked like a magic. Thanks a lot for the help. setattr() is really faster than attributes. Regards, SG On 22 February 2014 12:29, Philippe Grosjean phgrosj...@sciviews.orgwrote: You can use setattr() in the data.table package. It can be used too on data.frames or other objects. Best, Philippe Grosjean On 22 Feb 2014, at 03:13, Smart Guy smartgu...@gmail.com wrote: Hi All I am having problem running the 'attributes' command to set a attribute on each column of a large dataset. Dataset has 80 columns and 312407 rows. Its taking more than 60 seconds to set simple attributes like split=TRUE, usermissing=FALSE. Here is the source code, assuming Dataset1 is the one that is large :- myfunction - function() { cat(Before for loop:) print(Sys.time()) for( colIndex in 1 : 80) { cat(Before Attr, colIndex) print(Sys.time()) attributes(Dataset1[1]) - c(attributes(Dataset1[, colIndex]), list(coldesc = c(), usermissing = c(FALSE), missingvalues = NULL, split = c(FALSE), levelLabels = c())) cat(After Attr:) print(Sys.time()) } cat(After for loop:) print(Sys.time()) } Its my feeling that R is passing all 312407 rows to set 'attributes' on a cloumn. Is there a more efficent way to do this? Thanks, SG [[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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] save/load doubles memory [oops]
At this point R's serialization format only preserves sharing of environments; any other sharing is lost. Changing this will require an extensive rewrite of serialization. It would be useful to have this, especially as we are trying to increase sharing/decrease copying, but it isn't likely any time soon. Best, luke On Tue, 17 Sep 2013, Ross Boylan wrote: On Tue, 2013-09-17 at 12:06 -0700, Ross Boylan wrote: Saving and loading data is roughly doubling memory use. I'm trying to understand and correct the problem. Apparently I had the process memories mixed up: R1 below was the one with 4G and R2 with 2G. So there's less of a mystery. However... R1 was an R process using just over 2G of memory. I did save(r3b, r4, sflist, file=r4.rdata) and then, in a new process R2, load(file=r4.rdata) R2 used just under 4G of memory, i.e., almost double the original process. The r4.rdata file was just under 2G, which seemed like very little compression. r4 was created by r4 - sflist2stanfit(sflist) I presume that r4 and sflist shared most of their memory. The save() apparently lost the information that the memory was shared, doubling memory use. Still wondering if this is going on. R 2.15.1, 64 bit on linux. First, does my diagnosis sound right? The reports of memory use in R2 are quite a bit lower than the process footprint; is that normal? gc() # after loading data used (Mb) gc trigger (Mb) max used (Mb) Ncells 1988691 106.33094291 165.3 2432643 130.0 Vcells 266976864 2036.9 282174979 2152.9 268661172 2049.8 rm(r4) gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 1949626 104.23094291 165.3 2432643 130.0 Vcells 190689777 1454.9 282174979 2152.9 268661172 2049.8 r4 - sflist2stanfit(sflist) gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 1970497 105.33094291 165.3 2432643 130.0 Vcells 228827252 1745.9 296363727 2261.1 268661172 2049.8 It seems the recreated r4 used about 300M less memory than the one read in from disk. This suggests that some of the sharing was lost in the save/load process. Even weirder, R1 reports memory use well beyond the memory I show the process using (2.2G) Not a mystery after getting the right processes. Actually, I'm a little surprised the process memory is less than the max used memory; I thought giving back memory was not possible on Linux. gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 3640941 194.55543382 296.1 5543382 296.1 Vcells 418720281 3194.6 553125025 4220.1 526708090 4018.5 Second, what can I do to avoid the problem? Now a more modest problem, though still a problem. I guess in this case I could not save r4 and recreate it, but is there a more general solution? If I did myboth - list(r4, sflist) and save(myboth, file=myfile) would that be enough to keep the objects together? Judging from the size of the file, it seems not. Even if the myboth trick worked it seems like a kludge. Ross Boylan __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Issue with Imports in NAMESPACE
On Tue, 25 Jun 2013, Duncan Murdoch wrote: On 13-06-25 7:14 AM, Søren Højsgaard wrote: Dear Duncan, Excellent, thanks! Maybe this is worth a remark in a future version of Writing R Extensions (including that those local copies are not exported again with exportPattern(^[[:alpha:]]+)). It is mentioned that they can be exported. The fact that exportPattern doesn't see them might be a bug. I don't think it's a bug -- including all imports would usually bring in way too much. In general re-exporting is probably not such a great idea since the help system isn't aware of the import/export chain. I don't know if R CMD check complains if you don't provide your own help page; if it doesn't it probably should. I also don't recall if we have a mechanism for such a help page on an import/export to just link to the real page. Best, luke Duncan Thanks! Søren -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: 25. juni 2013 13:02 To: Søren Højsgaard Cc: R hELP (r-h...@stat.math.ethz.ch) Subject: Re: [R] Issue with Imports in NAMESPACE On 13-06-25 6:50 AM, Søren Højsgaard wrote: Dear all, In my gRbase package I have up until now Depend-ed on RBGL (from Bioconductor), but good people have convinced me that I should use Import-it instead because I only use few functions from RBGL. In DESCRIPTION I therefore now have Imports: Matrix,RBGL In NAMESPACE I now have importFrom(RBGL, maxClique, is.triangulated, separates) The package compiles without complaints, but I have noticed that if I start a fresh R-session, then maxClique etc. from RBGL is NOT available for interactive use in my session: library(gRbase) maxClique Error: object 'maxClique' not found 1) Is this as it should be? 2) If yes, is there any other way in which maxClique can be imported for interactive use without Depend-ing the whole RBGL package? The importFrom directive effectively makes local copies of those functions in your package (with the usual caveats that copies aren't as inefficient as you might think). If you want to export them, you need to add them to the exports list. Duncan Murdoch __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] attr vs attributes
Hope this helps, Rui Barradas Em 09-05-2013 18:35, Murat Tasan escreveu: hi all -- i looked through the R Language Definition document, but couldn't find any particular warning or example that would clarify the best use of attribute setting for R objects. let x be some R object, and i'd like to add attribute foo with value bar. case 1: attr(x, foo) - bar case 2: attributes(x)$foo - bar in both cases, attributes(x) reveals the appropriate setting has taken place. i'm assuming that attr(...) is 'safer' in the sense that perhaps consistency checks are made? (almost like a generic accessor/setter method?) but i also haven't seen any examples where case 2 (above) would bad... is there are trivial such example out there? BTW -- the cause for interest here is when dealing with dendrogram objects, for which much of the useful data are stored as attributes, and where running dendrapply means having to explicitly set attribute values to retain the tree structure in the resulting object. cheers, -m [[alternative HTML version deleted]] __** R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r- helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __** R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r- helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.orgmailto: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. [[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-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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Unexpected behavior looping through sequence of dates
R's for loop is only designed to iterato over primitive types. The help file says of the seq argument: seq: An expression evaluating to a vector (including a list and an expression) or to a pairlist or ‘NULL’. A factor value will be coerced to a character vector. [This could be more emphatic by stating that any class attributes are igonred or something of that nature.] Having for() do anything else would require designing an iteration protocol -- probably would be nice in principle but not easy to do. Best, luke On Sat, 9 Mar 2013, Peter Ehlers wrote: On 2013-03-09 11:14, R. Michael Weylandt wrote: On Sat, Mar 9, 2013 at 6:50 PM, David Winsemius dwinsem...@comcast.net wrote: I was unable to find the reason for the original coercion in the help(for) page or the R Language Definition entry regarding for-loops. On the hunch that coercion via as.vector might be occurring, Behaviorally, it seems to, but the code for do_for in eval.c has factors special-cased to call asCharacterFactor so that might not be a robust detail to rely on. The relevant behavior seems instead to be that there's a switch on val_type which creates the loop index but doesn't copy all attributes (like class) Note that this means a user's as.vector wouldn't be called here: as.vector.flub - function(x, ...) letters[x] foo - 1:5 class(foo) - flub as.vector(foo) for(j in foo) {print(j); print(class(j))} as.vector.grub - function(x, ...) match(x, letters) bar - letters[1:5] class(bar) - grub as.vector(bar) for(j in bar) {print(j); print(class(j))} Cheers, Michael I think that Michael is right - the problem is with val_type in the do_for code. Here's a simplified version of Alexandre's example: d - as.Date(2013-03-10) for(i in seq_along(d)) print(i) #[1] 1 for(i in d) print(i) #[1] 15774 where we might have expected to see 2013-03-10. The essential line in the do_for code seems to me to be: val_type = TYPEOF(val); ?typeof tells us that R does not have a 'date' type, so: typeof(d) #[1] double And the for-loop results follow. Peter Ehlers __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] Unexpected behavior looping through sequence of dates
On Sat, 9 Mar 2013, Alexandre Sieira wrote: Thanks for the clarification, Luke. That is really counter-intuitive behavior. I 100% agree with you that the for documentation should state that assumption explicitly. I would also like to suggest changing the for implementation to issue a warning if the seq argument is a vector of a non-primitive type. That would have saved me a few hours of debugging in the last few days, so I imagine it must be relevant for more people as well. Issuing a warning unconditioally would result in far to many spurious warnings. for() works perfecly fine now for most objects with a class attribute. I don't see a reasonable way to detect the subset of cases where this is not true (other than registering a list of classes for() should warn about, which might be feasible, though might refult in a significant performance hit.) Best, luke -- Alexandre Sieira CISA, CISSP, ISO 27001 Lead Auditor The truth is rarely pure and never simple. Oscar Wilde, The Importance of Being Earnest, 1895, Act I Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Saturday, 9 de March de 2013 at 13:10, luke-tier...@uiowa.edu wrote: R's for loop is only designed to iterato over primitive types. The help file says of the seq argument: seq: An expression evaluating to a vector (including a list and an expression) or to a pairlist or ¡NULL¢. A factor value will be coerced to a character vector. [This could be more emphatic by stating that any class attributes are igonred or something of that nature.] Having for() do anything else would require designing an iteration protocol -- probably would be nice in principle but not easy to do. Best, luke On Sat, 9 Mar 2013, Peter Ehlers wrote: On 2013-03-09 11:14, R. Michael Weylandt wrote: On Sat, Mar 9, 2013 at 6:50 PM, David Winsemius dwinsem...@comcast.net (mailto:dwinsem...@comcast.net) wrote: I was unable to find the reason for the original coercion in the help(for) page or the R Language Definition entry regarding for-loops. On the hunch that coercion via as.vector might be occurring, Behaviorally, it seems to, but the code for do_for in eval.c has factors special-cased to call asCharacterFactor so that might not be a robust detail to rely on. The relevant behavior seems instead to be that there's a switch on val_type which creates the loop index but doesn't copy all attributes (like class) Note that this means a user's as.vector wouldn't be called here: as.vector.flub - function(x, ...) letters[x] foo - 1:5 class(foo) - flub as.vector(foo) for(j in foo) {print(j); print(class(j))} as.vector.grub - function(x, ...) match(x, letters) bar - letters[1:5] class(bar) - grub as.vector(bar) for(j in bar) {print(j); print(class(j))} Cheers, Michael I think that Michael is right - the problem is with val_type in the do_for code. Here's a simplified version of Alexandre's example: d - as.Date(2013-03-10) for(i in seq_along(d)) print(i) #[1] 1 for(i in d) print(i) #[1] 15774 where we might have expected to see 2013-03-10. The essential line in the do_for code seems to me to be: val_type = TYPEOF(val); ?typeof tells us that R does not have a 'date' type, so: typeof(d) #[1] double And the for-loop results follow. Peter Ehlers __ R-help@r-project.org (mailto: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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu (mailto:luke-tier...@uiowa.edu) Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] Hard Stop?
There are 4 ways, other than generating a core dump :-), that could fit your vague desctiption: Call q(no); this is the only way to avoid 'finally' expressions in tryCatch if that is really what you want. You can invoke an abort restart; there will be one established by the intepreter, but there may be others. You can choose the one you want programmatically. If you use the outer-most one from the interpreter then what happens depends on whether R is running interactively or not. You can call stop() with a condition argument that is not an error or a warning to avoid any handlers established by tryCatch or withCallingHandlers to intercept warnings or errors. This will drop down to stop's default handling of errors (i.e. print a message and invoke the nearest abort restart). You can capture an unevaluated return() call and evaluate it at the point from which you want to escape. This is what callCC does, and using callCC would be the recommended way to do this if this is what you want. [R's condition handling is based on Common Lisp's; a good reference for that is http://www.nhplace.com/kent/Papers/Condition-Handling-2001.html. Some day there will be an R version of this document.] What choice is appropriate depends on exactly what you want to have happen after you execute your Hard Stop and whether you own, or need to own, the code that receives the transfer of control initiated by your 'Hard Stop. Best, luke On Thu, 7 Feb 2013, Duncan Murdoch wrote: On 06/02/2013 8:33 PM, ivo welch wrote: is it possible to throw a stop() that is so hard that it will escape even tryCatch? You can signal a condition that is not an error, and if tryCatch hasn't been written to catch it, it will stop. For example, g - function() { tryCatch(f(), error=function(e) NULL cat(Still running\n) } f - function() stop(Regular error) # This won't stop g() g() f - function() stop(simpleCondition(I mean it!)) # This will g() Of course, you can catch simpleConditions too if you try. Duncan Murdoch __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Codetools Query (repost)
You really don't want to use internals like isBaseVar as there is no guarantee they will continue to exist. Even collectUsage and otehr things mentioned on the same page may need to change if this is reimplemented. The most robust approach is to use findGlobals and omit what you don't want, e.g. omit - ls(package:base, all.names=TRUE) setdiff(findGlobals(moo),omit) [1] y If you do want to use chollectUsage you could use something like funs - new.env() omit - ls(package:base, all.names=TRUE) enter - function(type, v, e, w){ if (! v %in% omit) assign(v, TRUE, funs) } collectUsage(moo, enterGlobal = enter) If %in% is too slow create a hashed envorinment and use exists(). Best, luke On Tue, 15 Jan 2013, Saptarshi Guha wrote: Sorry for reposting, i keep forgetting this should be plain text. Will not make this mistake again Hello, The following code moo - function(a=1){ x=1; x=x+y} funs - new.env() enter - function(type, v, e, w){ assign(v, TRUE, funs) } library(codetools) collectUsage(moo, enterGlobal = enter) adds + to the environment funs i.e. funs: = { + y How can i ignore variables which are present in base, utils, stat environments from being added (equivalently(?) symbols present in R when R is started) I tried funs - new.env() enter - function(type, v, e, w){ if(codetools:::isBaseVar(v, w$env) || codetools:::isStatsVar(v, w$env) || codetools:::isUtilsVar(v, w$env) || v == Quote) return() assign(v, TRUE, funs) } library(codetools) collectUsage(moo, enterGlobal = enter) but this threw Error in exists(v, envir = e, inherits = FALSE, mode = function) : invalid 'envir' argument Cheers __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] try()-function does not catch error in BATCH-job if Matrix is loaded
The work-around was actually put in plae prior to the release of R 2.15.2, so updating your R to the current released version will resolve this. Best, luke On Mon, 7 Jan 2013, luke-tier...@uiowa.edu wrote: This is due to long-staning issue in methods internals, which are involved because loading Matrix shadows base::mean with Matrix::mean. A work-around has been in place in R_devel for some time; a proper fix may come at some point in the future. So if your real code doesn't need the moficied mean from Matrix you can use base::mean; otherwise you will have to use an R-devel snapshot. Best, luke On Mon, 7 Jan 2013, Sarah Brockhaus wrote: Hello, In my simulation I use the try()-function to catch possible errors when fitting models. I run the simulationon a Linux-server using the command R CMD BATCH nameOfFile.R . When executing the code as batch-job I get the problem that the execution is halted without giving an error message. But when I run the code interactivly the error is catched by try() as it would be expected. The problem is somewhat strange as it only occurs when the code is executed as a batch-job and when the package Matrix is loaded. I wrote a small example reproducing the error. (In my code the error occurs in mgcv:::fixDependence, which looks like the code I'm using below in order to get a small reproducible example. I realized that the code makes no sense...) ## library(Matrix) R - matrix(abs(rnorm(25)), 5, 5) r0 - r - nrow(R) # while-loop produces error that should be catched by the function try() try( while (mean(R[r0:r, r0:r]) 0) r0 - r0 - 1 ) # so Hello should be printed print(Hello) ## I use R version 2.15.1 (2012-06-22) on a x86_64-pc-linux-gnu (64-bit) platform. I would be grateful for help. Best regards, Sarah Brockhaus PHD-student Department of Statistics University of Munich __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] try()-function does not catch error in BATCH-job if Matrix is loaded
This is due to long-staning issue in methods internals, which are involved because loading Matrix shadows base::mean with Matrix::mean. A work-around has been in place in R_devel for some time; a proper fix may come at some point in the future. So if your real code doesn't need the moficied mean from Matrix you can use base::mean; otherwise you will have to use an R-devel snapshot. Best, luke On Mon, 7 Jan 2013, Sarah Brockhaus wrote: Hello, In my simulation I use the try()-function to catch possible errors when fitting models. I run the simulationon a Linux-server using the command R CMD BATCH nameOfFile.R . When executing the code as batch-job I get the problem that the execution is halted without giving an error message. But when I run the code interactivly the error is catched by try() as it would be expected. The problem is somewhat strange as it only occurs when the code is executed as a batch-job and when the package Matrix is loaded. I wrote a small example reproducing the error. (In my code the error occurs in mgcv:::fixDependence, which looks like the code I'm using below in order to get a small reproducible example. I realized that the code makes no sense...) ## library(Matrix) R - matrix(abs(rnorm(25)), 5, 5) r0 - r - nrow(R) # while-loop produces error that should be catched by the function try() try( while (mean(R[r0:r, r0:r]) 0) r0 - r0 - 1 ) # so Hello should be printed print(Hello) ## I use R version 2.15.1 (2012-06-22) on a x86_64-pc-linux-gnu (64-bit) platform. I would be grateful for help. Best regards, Sarah Brockhaus PHD-student Department of Statistics University of Munich __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] easy way to fit saturated model in sem package?
They look fine to me. luke On Fri, 13 Jul 2012, Joshua Wiley wrote: Dear John, Thanks very much for the reply. Looking at the optimizers, I had thought that the objectiveML did what I wanted. I appreciate the clarification. I think that multiple imputation is more flexible in some ways because you can easy create different models for every variable. At the same time, if the assumptions hold, FIML is equivalent to multiple imputation, and considerably more convenient. Further, I suspect that in many circumstances, either option is equal to or better than listwise deletion. In my case, I am working on some tools primarily for data exploration, in a SEM context (some characteristics of individual variables and then covariance/correlation matrices, clustering, etc.) and hoped to include listwise/pairwise/FIML as options. I will check out the lavaan package. Thanks again for your time, Josh On Thu, Jul 12, 2012 at 8:20 AM, John Fox j...@mcmaster.ca wrote: Dear Joshua, If I understand correctly what you want to do, the sem package won't do it. That is, the sem() function won't do what often is called FIML estimation for models with missing data. I've been thinking about implementing this feature, and don't think that it would be too difficult, but I can't promise when and if I'll get to it. You might also take a look at the lavaan package. As well, I must admit to some skepticism about the FIML estimator, as opposed to approaches such as multiple imputation of missing data. I suspect that the former is more sensitive than the latter to the assumption of multinormality. Best, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Joshua Wiley Sent: July-12-12 2:53 AM To: r-help@r-project.org Cc: John Fox Subject: [R] easy way to fit saturated model in sem package? Hi, I am wondering if anyone knows of an easy way to fit a saturated model using the sem package on raw data? Say the data were: mtcars[, c(mpg, hp, wt)] The model would estimate the three means (intercepts) of c(mpg, hp, wt). The variances of c(mpg, hp, wt). The covariance of mpg with hp and wt and the covariance of hp with wt. I am interested in this because I want to obtain the MLE mean vector and covariance matrix when there is missing data (i.e., the sum of the case wise likelihoods or so-called full information maximum likelihood). Here is exemplary missing data: dat - as.matrix(mtcars[, c(mpg, hp, wt)]) dat[sample(length(dat), length(dat) * .25)] - NA dat - as.data.frame(dat) It is not too difficult to write a wrapper that does this in the OpenMx package because you can easily define paths using vectors and get all pairwise combinations using: combn(c(mpg, hp, wt), 2) but I would prefer to use the sem package, because OpenMx does not work on 64 bit versions of R for Windows x64 and is not available from CRAN presently. Obviously it is not difficult to write out the model, but I am hoping to bundle this in a function that for some arbitrary data, will return the FIML estimated covariance (and correlation matrix). Alternately, if there are any functions/packages that just return FIML estimates of a covariance matrix from raw data, that would be great (but googling and using findFn() from the sos package did not turn up good results). Thanks! Josh -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] easy way to fit saturated model in sem package?
Apologies -- replied to the wrong message. luke On Fri, 13 Jul 2012, luke-tier...@uiowa.edu wrote: They look fine to me. luke On Fri, 13 Jul 2012, Joshua Wiley wrote: Dear John, Thanks very much for the reply. Looking at the optimizers, I had thought that the objectiveML did what I wanted. I appreciate the clarification. I think that multiple imputation is more flexible in some ways because you can easy create different models for every variable. At the same time, if the assumptions hold, FIML is equivalent to multiple imputation, and considerably more convenient. Further, I suspect that in many circumstances, either option is equal to or better than listwise deletion. In my case, I am working on some tools primarily for data exploration, in a SEM context (some characteristics of individual variables and then covariance/correlation matrices, clustering, etc.) and hoped to include listwise/pairwise/FIML as options. I will check out the lavaan package. Thanks again for your time, Josh On Thu, Jul 12, 2012 at 8:20 AM, John Fox j...@mcmaster.ca wrote: Dear Joshua, If I understand correctly what you want to do, the sem package won't do it. That is, the sem() function won't do what often is called FIML estimation for models with missing data. I've been thinking about implementing this feature, and don't think that it would be too difficult, but I can't promise when and if I'll get to it. You might also take a look at the lavaan package. As well, I must admit to some skepticism about the FIML estimator, as opposed to approaches such as multiple imputation of missing data. I suspect that the former is more sensitive than the latter to the assumption of multinormality. Best, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Joshua Wiley Sent: July-12-12 2:53 AM To: r-help@r-project.org Cc: John Fox Subject: [R] easy way to fit saturated model in sem package? Hi, I am wondering if anyone knows of an easy way to fit a saturated model using the sem package on raw data? Say the data were: mtcars[, c(mpg, hp, wt)] The model would estimate the three means (intercepts) of c(mpg, hp, wt). The variances of c(mpg, hp, wt). The covariance of mpg with hp and wt and the covariance of hp with wt. I am interested in this because I want to obtain the MLE mean vector and covariance matrix when there is missing data (i.e., the sum of the case wise likelihoods or so-called full information maximum likelihood). Here is exemplary missing data: dat - as.matrix(mtcars[, c(mpg, hp, wt)]) dat[sample(length(dat), length(dat) * .25)] - NA dat - as.data.frame(dat) It is not too difficult to write a wrapper that does this in the OpenMx package because you can easily define paths using vectors and get all pairwise combinations using: combn(c(mpg, hp, wt), 2) but I would prefer to use the sem package, because OpenMx does not work on 64 bit versions of R for Windows x64 and is not available from CRAN presently. Obviously it is not difficult to write out the model, but I am hoping to bundle this in a function that for some arbitrary data, will return the FIML estimated covariance (and correlation matrix). Alternately, if there are any functions/packages that just return FIML estimates of a covariance matrix from raw data, that would be great (but googling and using findFn() from the sos package did not turn up good results). Thanks! Josh -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Efficient distance calculation on big matrix
It so happens I have been looking at very similar changes, as well as adding multi-threading support for dist(); these should make it into R-devel later this summer. Best, luke On Sun, 17 Jun 2012, Stefan Evert wrote: I'm working on analyzing a large data set, lets asume that dim(Data)=c(1000,8700). I want to calculate the canberra distance between the columns of this matrix, and using a toy example ('test' is a matrix filled with random numbers 0-1): system.time(d-as.matrix(dist(t(test), method = canberra, diag = FALSE, upper = FALSE, p = 2))) user system elapsed 1417.7133.219 1421.144 The system.time results also confuse me a bit, since 99% of the time is not system time but user time. What does that mean? User time is the time that R spends working on your problem; system time refers to tasks done by the operating system, e.g. disk access, managing locks and, most importantly, swapping when you run out of RAM. With multi-threading, system time can be much larger than the time that has actually elapsed. Is there any way to calculate the distance which would take less time? Well, one thing you can do is to get a faster computer. :-) The command above takes only 670 seconds on my MacBook Pro (without multi-threading). Calculating a distance matrix is an expensive computation. In your example, R has to carry out (8700 * 8700 * 1000) / 2 = 37.8 billion floating point divisions. With approx. 27 clock cycles per division (according to tables I've found on the Web), this takes at least 340 seconds even on a 3GHz CPU (and ignoring memory access, addition/subtraction, loops, etc.). You can shave off some of the time if you implement the distance calculation in C, inline the code to avoid callback functions in loops, operate on columns of the matrix directly (which should be more cache-friendly than rows) and don't check for NA's, NaN's and other degenerate cases. I've done just that in my experimental R package wordspace, which isn't on CRAN yet: library(wordspace) A - matrix(runif(8.7e6), 1000, 8700) system.time(d1 - as.matrix(dist(t(A), method=canberra))) user system elapsed 669.207 2.724 669.305 system.time(d2 - dist.matrix(A, method=canberra, byrow=FALSE)) user system elapsed 250.534 0.784 250.301 all(d1 == d2) [1] TRUE If you aren't tied to Canberra distance, you can use a less expensive metric such as the Manhattan distance for an additional, more substantial speed boost: system.time(d3 - dist.matrix(A, method=manhattan, byrow=FALSE)) user system elapsed 42.488 0.999 43.569 This is still single-threaded, so you can run multiple of these calculations in parallel depending on how many cores your server has. Hope this helps, Stefan PS: In case you'd like to give it a try yourself and aren't daunted by a complete lack of documentation: svn checkout svn://scm.r-forge.r-project.org/svnroot/wordspace/pkg [ ev...@linglit.tu-darmstadt.de | http://purl.org/stefan.evert ] __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Double-buffering problem, this time with an example.
FOR what it's worth this dev.hold/dev/flush combination does not seem to prevent flickering on the quartz device on Macs. Best, luke On Sat, 2 Jun 2012, Duncan Murdoch wrote: On 12-06-02 4:02 PM, Daniel Carr wrote: Most of my animations that used to work on windows() version 2.11.1 and earlier now flash as if the double buffering is turned off or buffer swapping is triggered by other events than in the past. The simplified example below using symbols should illustrate the problem in a windows environment. windows() radius- 8 n- 6 ang- seq(0,2*pi,length=n+1)[-(n+1)] ca- cos(ang) sa- sin(ang) size- c(.1, .3, .5, .7, .9, 1) colors- rainbow(length(size)) for (i in 1:1000){ radius- radius*.998 bnd- (radius+1)* c(-1, 1) cenX- radius*ca cenY- radius*sa symbols(cenX, cenY, circles = size, xlim=bnd, ylim=bnd, bg=colors) } I have not isolated the version when the flashing started but it somewhere between 2.11.1 and 2.14.1. I did some searching on double-buffering problems in R but didn't find indications of this particular problem. Slowing the animation down did not help. I don't think there was ever a guarantee that double buffering would be sufficient for what you were doing: you just got lucky. What you need to do (and this should work, at least on the windows() device and some others), is use dev.hold() to stop redrawing, and dev.flush() when you are ready to display the new stuff. Your loop becomes something like this: for (i in 1:1000){ dev.hold() radius - radius*.998 bnd - (radius+1)* c(-1, 1) cenX - radius*ca cenY - radius*sa symbols(cenX, cenY, circles = size, xlim=bnd, ylim=bnd, bg=colors) dev.flush() } The dev.hold() function was introduced in 2.14.0. I think dev.flush() existed earlier, but not for all systems. Duncan Murdoch __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] how to remove the 'promise' attribute of an R object (.Random.seed)?
On Tue, 22 May 2012, Yihui Xie wrote: Hi, The problem arises when I lazyLoad() the .Random.seed from a previously saved database. To simplify the process of reproducing the problem, see the example below: ## this assignment may not really make sense, but illustrates the problem delayedAssign('.Random.seed', 1L) typeof(.Random.seed) # [1] integer rnorm(1) # Error in rnorm(1) : # .Random.seed is not an integer vector but of type 'promise' typeof(.Random.seed) # [1] integer So there must be an attribute promise somewhere attached to .Random.seed, and I cannot find it. The R function typeof() does not reveal it, but the TYPEOF() function in src/main/RNG.c says it is a 'promise'. My question is, how to make R use the real value of .Random.seed instead of complaining about the promise? Thanks! Siple answer: Don't creat the promise in the first place, i.e. don't use delayedAssign. What is the real context where this arises? Knowing that may help us decide whether the internals should address this possibility. Best, luke Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] how to remove the 'promise' attribute of an R object (.Random.seed)?
I believe it would be better if the internal code forced the promise at this point. I'll have a look; there may be a few other similar instances worth looking at. luke On Tue, 22 May 2012, Yihui Xie wrote: Thanks! That is exactly what I did (https://github.com/yihui/knitr/blob/master/R/cache.R#L44) but I was wondering if .Random.seed could be better recognized when it is lazy loaded. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Tue, May 22, 2012 at 8:08 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: You can remove it by a simple assignment: .Random.seed - .Random.seed will do it. (The reason is that it doesn't copy the object blindly, it evaluates the RHS to get 1L, and it's a regular assignment, so that gets put into the LHS.) Duncan Murdoch __ 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-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.
Re: [R] enableJIT(2) causes major slow-up in rpart
The level 2 is a heuristic meant to help with certain kinds of programming idioms. It isn't always going to work. In this case trace(cmpfun) will show three functions being compiled each time through. Not sure why -- I'll try to find out and see if it can be avoided. luke On Thu, 12 Apr 2012, Tal Galili wrote: Hello, Due to exploration of the JIT capabilities offered through the {compiler} package, I came by the fact that using enableJIT(2) can *slow* the rpart function (from the {rpart} package) by a magnitude of about 10 times. Here is an example code to run: library(rpart) require(compiler) enableJIT(0) # just making sure that JIT is off # We could also use enableJIT(1) and it would be fine fo - function() {rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)} system.time(fo()) # user system elapsed # 0 0 0 # this can also be 0.01 sometimes. enableJIT(2) # also happens for enableJIT(3) system.time(fo()) # user system elapsed # 0.120.000.12 Which brings me to my *questions*: 1) Is this a bug or a feature? 2) If this is a feature, what is causing it? (or put another way, can one predict ahead of time the implications of using enableJIT(2) or enableJIT(3) on his code?) *Links*: A post I recently wrote about my exploration of JIT - www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/ The question asked on SO regarding the limitations of JIT: http://stackoverflow.com/questions/10106736/possible-shortcomings-for-using-jit-with-r Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] recover lost global function
The compiler doesn't currently look beyond the first definition found (the generated code does the right thing, but the compiler won't optimize calls to functions masked by non-functions). I'll look into whether thechecking can be made to take this into account; it may be more trouble than it is worth though. luke On Thu, 5 Apr 2012, Sam Steingold wrote: * Duncan Murdoch zheqbpu.qha...@tznvy.pbz [2012-04-04 21:46:57 -0400]: On 12-04-04 5:15 PM, Sam Steingold wrote: * Duncan Murdochzheqbpu.qha...@tznvy.pbz [2012-04-04 17:00:32 -0400]: There's no warning when you mask a function with a non-function at top level, and little need for one, because R does the right search based on the fact that you're making a function call: c [1] 1 c(1,2) [1] 1 2 why then am I getting these warnings from cmpfile? You would have to tell me what you did before I could attempt to answer that. all - 1 cmpfile(foo.R) where foo.R contains functions which call all() Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' Note: no visible global function definition for 'all' I did overwrite all to a data frame, but it only appears in a funtion position all(...) in the file being compiled. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] memory management
On Wed, 29 Feb 2012, Sam Steingold wrote: * Milan Bouchet-Valat anyvzv...@pyho.se [2012-02-29 18:18:50 +0100]: I think you're simply hitting a (terrible) OS limitation. Linux is very often not able to reclaim the memory R has used because it's fragmented. The OS can only get the pages back if nothing is above them, and most of the time there is data after the object you remove. I'm not able to give you a more precise explanation, but that's apparently a known problem and that's hard to fix. compacting garbage collector is our best friend! Which R does not use because of the problems it would create for external C/Fortran code on which R heavily relies. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Weird R's behaviour with a quoted name
On Mon, 21 Nov 2011, William Dunlap wrote: This is a bug in R: it either should prohibit the attaching of attributes to things of class name or should make it so that attachment of an attribute doesn't have such a global effect. A more direct example of the problem is: attributes(quote(some.name)) NULL bar - structure(quote(some.name), someAttribute=someAttribute's value) attributes(quote(some.name)) $someAttribute [1] someAttribute's value I reported a similar problem to R-devel in March of 2010 under the subject line symbol name caching bug: attributes get tied to symbol names. The consensus then seemed to be that prohibiting attributes on things of class name was the way to go. Yes -- just hasn't risen high enough on anyone's todo list to get done. Best, luke Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Kamil Barton Sent: Monday, November 21, 2011 8:31 AM To: r-help@r-project.org Subject: [R] Weird R's behaviour with a quoted name Can someone explain why the following happens? --- : quote(some.name) some.name : bar - structure(quote(some.name), class = foo) : quote(some.name) Error in print(some.name) : object 'some.name' not found : bar - quote(some.name) : quote(some.name) Error in print(some.name) : object 'some.name' not found : bar - as.name(some.name) : quote(some.name) some.name --- __ 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-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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Snow/Snowfall hangs on windows 7
Thanks to Thomas, Steve, Uwe, and others for reporting the problem and suggesting fixes. A new version of snow is on its way to CRAN that hopefully fixes the problem on Windows without breaking tings elsewhere. I don't have access to Windows at the moment so if things don't work and you are willing to help debug then please let me know. I was hoping to be able to make snow robust to spaces in paths on other platforms as well but that seems to be complicated, so for now I signal an error on non-Windows platforms with spaces in path names snow uses. Also, I have not tested mpi or nws back ends on Linux. Again, if this version creates problems for you and you are willing to help sort things out please let me know. This release also includes some experimental performance monitoring tools described in ?snow.time. Best, luke On Mon, 16 May 2011, Uwe Ligges wrote: Folks, I guess I know what is going on (and why I haven't seen this so far): All of you have installed R in a directory with blanks in it, right? Please source() the attached sock.R and afterwards try again. Does it work with SOCK clusters now? Then it was just the lack of quotes. CCing Luke the diffs (against snow 0.3-3 on CRAN): @@ -29,8 +29,8 @@ env - paste(MASTER=, master, PORT=, port, OUT=, outfile, - SNOWLIB=, snowlib, sep=) -cmd - paste(rscript, script, env) + SNOWLIB=, shQuote(snowlib), sep=) +cmd - paste(shQuote(rscript), shQuote(script), env) } else { script - RunSnowWorker RSOCKnode.R @@ -43,13 +43,13 @@ else { if (homogeneous) { scriptdir - getClusterOption(scriptdir, options) -script - file.path(scriptdir, RSOCKnode.sh) +script - shQuote(file.path(scriptdir, RSOCKnode.sh)) rlibs - paste(getClusterOption(rlibs, options), collapse = :) rprog - getClusterOption(rprog, options) env - paste(MASTER=, master, PORT=, port, OUT=, outfile, - RPROG=, rprog, + RPROG=, shQuote(rprog), R_LIBS=, rlibs, sep=) } else { (same problem in mpi.R, nws.R etc. as well, I think) Best wishes, Uwe On 16.05.2011 00:01, David Anisman wrote: Same problem as Anna here. Windows 7 64-bit. Running R 2.13.0. snow + snowfall installed. Testing: library(snow) library(snowfall) sfInit(parallel=TRUE, cpus=2, type=SOCK) Then R spins forever (yes, I disabled the Windows firewall). On the same box, tried the same on Ubuntu under Virtualbox. No problem. Runs well. Any suggestions/ideas appreciated. David -- View this message in context: http://r.789695.n4.nabble.com/Snow-Snowfall-hangs-on-windows-7-tp3436724p3524990.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] setting options only inside functions
On Fri, 29 Apr 2011, William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of luke-tier...@uiowa.edu Sent: Friday, April 29, 2011 9:35 AM To: Jonathan Daily Cc: r-help@r-project.org; Hadley Wickham; Barry Rowlingson Subject: Re: [R] setting options only inside functions The Python solution does not extend, at least not cleanly, to things like dev on/ dev off or to Hadley's locale example. In any case if I am reading the Python source correctly on how they handle user interrupts this solution has the same non-robusness to user interrupts issue that Bill's initial solution had. As a basis I believe what we need is a mechanism that handles a setup, an action, and a cleanup, with setup and cleanup occurring with interrupts disablednand the action with interrupts enabled. Scheme's dynamic wind is similar, though I don't believe the scheme standard addresses interrupts and we don't need to worry about continuations, but some of the issues are similar. Probably we would want two flavors, one in which the action has to be a function that takes as a single argument the result produced by the setup code, and one in which the action can be an argument expression that is then evaluated at the appropriate place by laze evaluation. This can be done at the R level except for the controlling of interrupts (and possibly other asynchronous stuff)-- that would need a new pair of primitives (suspendInterrupts/enableInterupts or something like that). There is something in the Haskell literature on this that I have looked at a while back -- probably time to have another look. Luke, A similar problem is that if optionsList contains an illegal option then setting options(optionList) will commit changes to .Options as it works it way down the optionList until it hits the illegal option, when it throws an error. Then the following on.exit is never called (it wouldn't have the output of options(optionList) to work on if it were called) and the initial settings in optionList stick around forever. E.g., withOptions - function(optionList, expr) { + oldOpt - options(optionList) + on.exit(options(oldOpt)) + expr + } getOption(height) NULL getOption(width) [1] 80 withOptions(list(height=10, width=-2), 666) Error in options(optionList) : invalid 'width' parameter, allowed 10...1 getOption(height) [1] 10 getOption(width) [1] 80 I haven't checked to see if par() works in the same way - it does in S+. An ignoreInterrupts(expr) function would not help in that case. It would be solving an orthogonal problem. Making options() (and par()) atomic operations would help, but that may be a lot of work. But it would be the right thing to do for this purpose, either by creating an atomic version just for use in this context or by having a withOptions construct recursively work thougheach option. options() might also warn but no change .Options if there were an attempt to set an illegal option. Seems more or less the same as making options() atomic. Best, luke Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com On Thu, 28 Apr 2011, Jonathan Daily wrote: I would also love to see this implemented in R, as my current solution to the issue of doing tons of open/close, dev/dev.off, etc. is to use snippets in my IDE, and in the end I feel like it is a hack job. A pythonic with function would also solve most of the situations where I have had to use awkward try or tryCatch calls. I would be willing to help with this project, even if it is just testing. On Wed, Apr 27, 2011 at 5:43 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: but it's a little clumsy, because with_connection(file(myfile.txt), {do stuff...}) isn't very useful because you have no way to reference the connection that you're using. Ruby's blocks have arguments which would require big changes to R's syntax. One option would to use pronouns: Looking very much like python 'with' statements: http://effbot.org/zone/python-with-statement.htm Implemented via the 'with' statement which can operate on anything that has a __enter__ and an __exit__ method. Very neat. Barry __ 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. -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor
Re: [R] setting options only inside functions
The Python solution does not extend, at least not cleanly, to things like dev on/ dev off or to Hadley's locale example. In any case if I am reading the Python source correctly on how they handle user interrupts this solution has the same non-robusness to user interrupts issue that Bill's initial solution had. As a basis I believe what we need is a mechanism that handles a setup, an action, and a cleanup, with setup and cleanup occurring with interrupts disablednand the action with interrupts enabled. Scheme's dynamic wind is similar, though I don't believe the scheme standard addresses interrupts and we don't need to worry about continuations, but some of the issues are similar. Probably we would want two flavors, one in which the action has to be a function that takes as a single argument the result produced by the setup code, and one in which the action can be an argument expression that is then evaluated at the appropriate place by laze evaluation. This can be done at the R level except for the controlling of interrupts (and possibly other asynchronous stuff)-- that would need a new pair of primitives (suspendInterrupts/enableInterupts or something like that). There is something in the Haskell literature on this that I have looked at a while back -- probably time to have another look. On Thu, 28 Apr 2011, Jonathan Daily wrote: I would also love to see this implemented in R, as my current solution to the issue of doing tons of open/close, dev/dev.off, etc. is to use snippets in my IDE, and in the end I feel like it is a hack job. A pythonic with function would also solve most of the situations where I have had to use awkward try or tryCatch calls. I would be willing to help with this project, even if it is just testing. On Wed, Apr 27, 2011 at 5:43 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: but it's a little clumsy, because with_connection(file(myfile.txt), {do stuff...}) isn't very useful because you have no way to reference the connection that you're using. Ruby's blocks have arguments which would require big changes to R's syntax. One option would to use pronouns: Looking very much like python 'with' statements: http://effbot.org/zone/python-with-statement.htm Implemented via the 'with' statement which can operate on anything that has a __enter__ and an __exit__ method. Very neat. Barry __ 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. -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] setting options only inside functions
Put together a list and we can see what might make sense. If we did take this on it would be good to think about providing a reasonable mechanism for addressing the small flaw in this function as it is defined here. Best, luke On Wed, 27 Apr 2011, Hadley Wickham wrote: This has the side effect of ignoring errors and even hiding the error messages. If you are concerned about multiple calls to on.exit() in one function you could define a new function like withOptions - function(optionList, expr) { oldOpts - options(optionList) on.exit(options(oldOpts)) expr # lazily evaluate } I wish R had more functions like this. This sort of behaviour is also useful when you open connections or change locales. Ruby's blocks provide nice syntactic sugar for this idea. Hadley -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] Does R have a const object?
Just as a heads-up: it is likely that unlocking the bindings in base for pi, T, F, probably all BULTIN and SPECIAL functions, and possibly more, will start signaling warnings in the near future. Doing this may be useful at times for debugging but it can mess up assumptions others make about how things in base work and so reduce code reliability. Best, luke On Wed, 16 Mar 2011, Allan Engelhardt wrote: On 16/03/11 15:04, Gabor Grothendieck wrote: On Wed, Mar 16, 2011 at 10:54 AM, Allan Engelhardtall...@cybaea.com wrote: [...] Yes, but you can still print(base::pi) and rm(pi) to get back to our flat world, and you can't assign(pi, 4, pos = package:base) Error in assign(pi, 4, pos = package:base) : cannot change value of locked binding for 'pi' Just a feature of the search path. Morale: if you want base::pi, write base::pi. Try this: old.pi- pi assignInNamespace(pi, 2.3, ns = base) pi [1] 2.3 base::pi [1] 2.3 Ah! assignInNamespace does an unlockBinding under the covers which obviously is Evil(tm). The answer clearly is to do assignInNamespace(unlockBinding, function (...) {warning(be safe);}, ns=base) in your .Rprofile! Let's Keep R Safe, Folks! Allan __ 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. -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Does R have a const object?
On Wed, 16 Mar 2011, Gabor Grothendieck wrote: On Wed, Mar 16, 2011 at 11:49 AM, luke-tier...@uiowa.edu wrote: Just as a heads-up: it is likely that unlocking the bindings in base for pi, T, F, probably all BULTIN and SPECIAL functions, and possibly more, will start signaling warnings in the near future. Doing this may be useful at times for debugging but it can mess up assumptions others make about how things in base work and so reduce code reliability. That seems ok for pi, T and F but if its extended to everything in base then I would hope there is a nowarn= argument or other easy way to avoid the warning message. That would defeat the purpose. Unlocking things in base may be useful for experimenting or debugging but it is not a good idea otherwise. [? assignInNamespace could be more explicit on htis and will be soon.] There is a reason we lock bindings in the first place, and that is so one can assume that these bindings have certain values and certain properties and one can write reliable programs against these assumptions. Best, luke -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] Does R have a const object?
On Wed, 16 Mar 2011, Barry Rowlingson wrote: On Wed, Mar 16, 2011 at 4:16 PM, luke-tier...@uiowa.edu wrote: That would defeat the purpose. Unlocking things in base may be useful for experimenting or debugging but it is not a good idea otherwise. You are making experimenting in R more awkward? Then I'm throwing That would defeat the purpose straight back at you. I remember when R was all about the experimenting. Of course it was called Splus back then and was only available in grainy black-and-white... And how does seeing a warning reminding you that you are dong something experimental that might break things make experimenting more awkward? Since you wouldn't like to see such warnings in production code this does make doing something in production code that can break other people's code more awkward. As I do actually care bout whether my code works or not I'm fine with that. luke Oh well, I guess its one small step towards becoming a proper grown-up language. Barry -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] Does R have a const object?
On Wed, 16 Mar 2011, Gabor Grothendieck wrote: On Wed, Mar 16, 2011 at 12:16 PM, luke-tier...@uiowa.edu wrote: On Wed, 16 Mar 2011, Gabor Grothendieck wrote: On Wed, Mar 16, 2011 at 11:49 AM, luke-tier...@uiowa.edu wrote: Just as a heads-up: it is likely that unlocking the bindings in base for pi, T, F, probably all BULTIN and SPECIAL functions, and possibly more, will start signaling warnings in the near future. Doing this may be useful at times for debugging but it can mess up assumptions others make about how things in base work and so reduce code reliability. That seems ok for pi, T and F but if its extended to everything in base then I would hope there is a nowarn= argument or other easy way to avoid the warning message. That would defeat the purpose. Unlocking things in base may be useful for experimenting or debugging but it is not a good idea otherwise. [? assignInNamespace could be more explicit on htis and will be soon.] There is a reason we lock bindings in the first place, and that is so one can assume that these bindings have certain values and certain properties and one can write reliable programs against these assumptions. Its useful for being able to set defaults for arguments that do not have defaults. That cannot break existing programs. Until the next program decides do co change those defaults and either can't or does and you end up with incompatible assumptions. It also make the code with the added defaults inconsistent with the documentation though, which is not a good idea. It may seem convenient but it isn't a good idea in production code that is intended to play well with other production code. Note that if this feature is implemented in a heavy handed manner it could cause havoc as at least one package that is depended upon by literally dozens of other packages (and possibly hundreds if one takes into account dependencies of dependencies) cannot function. The reason I sent my initial message is so those who do this sort of thing can start thinking about other approaches. I do not expect to need this change for closures any time soon, but will need it for constants and primitives. It may be useful for some closures as well, so that change may come farther down the line. luke -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] get caller's name
The options showWarnCalls and showErrorCalls may also help -- they can be use do enable automatic printing of a call stack summary. From ?options: ‘showWarnCalls’, ‘showErrorCalls’: a logical. Should warning and error messages show a summary of the call stack? By default error calls are shown in non-interactive sessions. Best, luke On 02/04/2011 10:09 AM, William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch Sent: Friday, February 04, 2011 6:03 AM To: Ernest Adrogué Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] get caller's name On 03/02/2011 10:27 AM, Ernest Adrogué wrote: Hi, Suppose a function that checks an object: stop.if.dims- function(x) { if (! is.null(dim(x))) { stop(cannot handle dimensional data) } } This would be used by other functions that can only work with dimensionless objects. The problem is the error message would need to include the name of the function that called stop.if.dims, so that the user knows which function got an argument that was incorrect. How do I do this? Or maybe there is another way... I see you have the answer you wanted, but I'd suggest you don't need this: the user should just use traceback() after the error to see the full call stack. Perhaps it's not the caller that's the problem, but the caller of the caller... Duncan Murdoch stopifnot() deals with the problem by arranging for the error reporting mechanism not to say what function the error comes from. If you are in the know, not seeing Error in someFunction(arg): in the error might motivate you to call traceback(). If you are not in the know, it just frustrates you. R myFunc- function(x) stopifnot(all(x0)) R myFunc(-pi) Error: all(x 0) is not TRUE R traceback() 3: stop(paste(ch, is not , if (length(r) 1L) all , TRUE, sep = ), call. = FALSE) 2: stopifnot(all(x 0)) 1: myFunc(-pi) In S+ stopifnot() uses eval(call(stop, message), sys.parent()) to make the error message appear to come from the caller of stopifnot(). The initial message is clearer but the traceback more confusing: myFunc- function(x) stopifnot(all(x0)) myFunc(-pi) Problem in myFunc( - pi): all(x 0) is not TRUE Use traceback() to see the call stack traceback() 8: eval(action, sys.parent()) 7: doErrorAction(Problem in myFunc( - pi): all(x 0) is not TRUE, 1000) 6: stop(all(x 0) is not TRUE) 5: eval(call, sys.parent()) 4: stopifnot(all(x 0)) 3: myFunc( - pi) 2: eval(expression(myFunc( - pi))) 1: Message: Problem in myFunc( - pi): all(x 0) is not TRUE If I try the eval(call(stop,message), sys.parent()) trick in R the error is reported as being from eval(): myFunc(-pi) Error in eval(expr, envir, enclos) : all(x 0) is not TRUE S+'s error handler has some logic so that a stop() called from eval() is reported as being from the frame that eval is evaluating in. It might be nice to be able to tell stop(), warning(), and message() to pretend they were called from somewhere other than where they were actually called from. Falling back on traceback() doesn't help with warnings and messages. Being able to put standard messages like 'x not a matrix' into utility functions is handy, but it makes it hard to track down the problem. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com __ 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-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. -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] packagename:::functionname vs. importFrom
On Tue, 4 Jan 2011, Frank Harrell wrote: Thanks Luke. By the namespace from which you import is loaded when your package is I take it that you are saying that all such referenced packages are loaded up front, which is not what I hoped. That is what happens. You can use conditional imports in the NAMESPACE but that isn't appropriate for all setting. Using :: is reasonable if you want to use a fuction only if its package is available. Using ::: is code is a really bad idea for reasons already explained inthis thread. And it's too bad you can't import unexported objects, as that rather defeats the purpose of importFrom. The purpose of importFrom is to avoid a full import. So in no sense does this defeat the purpose of importFrom. Best, luke Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] packagename:::functionname vs. importFrom
On Mon, 3 Jan 2011, Frank Harrell wrote: Correct. I'm doing this because of non-exported functions in other packages, so I need ::: I'd still appreciate any insight about whether importFrom in NAMESPACE defers package loading so that if the package is not actually used (and is not installed) there will be no problem. It does not -- the namespace from which you import is loaded when your package is. (Also you can't import unexported variables.) Best, luke Thanks Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- Luke Tierney Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] R and Scheme
On Tue, 9 Dec 2008, Wacek Kusnierczyk wrote: Stavros Macrakis wrote: I've read in many places that R semantics are based on Scheme semantics. As a long-time Lisp user and implementor, I've tried to make this more precise, and this is what I've found so far. I've excluded trivial things that aren't basic semantic issues: support for arbitrary-precision integers; subscripting; general style; etc. I would appreciate corrections or additions from more experienced users of R -- I'm sure that some of the points below simply reflect my ignorance. ==Similarities to Scheme== R has first-class function closures. (i.e. correctly supports upward and downward funarg). R has a single namespace for functions and variables (Lisp-1). ==Important dissimilarities to Scheme (as opposed to other Lisps)== R is not properly tail-recursive. R does not have continuations or call-with-current-continuation or other mechanisms for implementing coroutines, general iterators, and the like. there is callCC, for example, which however seems kind of obsolete. There is nothing obsolete about it. It supports only downward or dynamic extent continuations and so is not useful (nor intended) for the things Stavros mentions. It is useful for escaping from deeply nested function calls, for example recursive examination of tree structures -- that is why it exists. At some point upward (at least one-shot) contitnuations may be added as well, but probably not soon. luke R supports keyword arguments. ==Similarities to Lisp and other dynamic languages, including Scheme== R is runtime-typed and garbage-collected. R supports nested read-eval-print loops for debugging etc. R expressions are represented as user-manipulable data structures. ==Dissimilarities to all (modern) Lisps, including Scheme== R has call-by-need, not call-by-object-value. R does not have macros. R objects are values, not pointers, so a-1:10; b-a; b[1]-999; a[1] = 999. Similarly, functions cannot modify the contents of their arguments. have you actually tried this code? even if the objects are values not pointers, assignment causes, in cases such as the above, copying the value with modifications applied as needed. thus, a[1] - 1, not 999, even though after b-a b and a are the same value object. try the following: system.time(x-1:(10^8)) system.time(y-x) system.time(y[1]-0) system.time(y[2]-0) head(x) head(y) with some trickery, functions can modify the contents of their arguments, using deparse/substitute and assign: a - 1 f - function(x) assign(deparse(substitute(x)), 0, parent.frame()) f(a) a the 'cannot modify the contents' does not apply to arguments that are environments: e - new.env(parent=emptyenv()) l - list() f - function(e) e$a = 0 f(e) e$a f(l) l$a There is no equivalent to set-car!/rplaca (not even pairlists and expressions). For example, r-pairlist(1,2); r[[1]]-r does not create a circular list. And in general there doesn't seem to be substructure sharing at the semantic level (though there may be in the implementation). computations on environment objects seem not to be subject to the copy-value-on-assignment semantics: e - new.env(parent=emptyenv()) ee - e e$a - 0 ee$a R does not have multiple value return in the Lisp sense. R assignment creates a new local variable on first assignment, dynamically. So static analysis is not enough to determine variable reference (R is not referentially transparent). Example: ff - function(a){if (a) x-1; x} ; x-99; ff(T) - 1; ff(F) - 99. In R, most data types (including numeric vectors) do not have a standard external representation which can be read back in without evaluation. R coerces logicals to numbers and numbers to strings. Lisps are stricter about automatic type conversion -- except that false a.k.a. NIL == () in Lisps other than Scheme. types are not treated coherently. in some situations, r coerces doubles to complex (according to the hierarchy of types specified here and there in the man pages), in others it won't: x - as.double(-1) y - as.complex(-1) x == y sqrt(x) sqrt(y) in certain cases, r will also do implicit inverse (downward) coercion: is(y:y) vQ __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
Re: [R] R and Scheme
On Mon, 8 Dec 2008, Stavros Macrakis wrote: I've read in many places that R semantics are based on Scheme semantics. As a long-time Lisp user and implementor, I've tried to make this more precise, and this is what I've found so far. I've excluded trivial things that aren't basic semantic issues: support for arbitrary-precision integers; subscripting; general style; etc. I would appreciate corrections or additions from more experienced users of R -- I'm sure that some of the points below simply reflect my ignorance. ==Similarities to Scheme== R has first-class function closures. (i.e. correctly supports upward and downward funarg). R has a single namespace for functions and variables (Lisp-1). ==Important dissimilarities to Scheme (as opposed to other Lisps)== R is not properly tail-recursive. True at present. May be unavoidable since the language provides access to the stack via things like sys.parent, but as it is rare to look at anything other than the immediate calling environment and call (outside of a debugging context) it may be possible to change that. R does not have continuations or call-with-current-continuation or other mechanisms for implementing coroutines, general iterators, and the like. R supports keyword arguments. ==Similarities to Lisp and other dynamic languages, including Scheme== R is runtime-typed and garbage-collected. R supports nested read-eval-print loops for debugging etc. R expressions are represented as user-manipulable data structures. ==Dissimilarities to all (modern) Lisps, including Scheme== R has call-by-need, not call-by-object-value. R does not have macros. Those are related -- because of lazy evaluation one does macros are not needed to achive semantic goals (see for example tryCatch). Being able to define friendlier syntax would sometimes be nice though (see tryCatch again). R objects are values, not pointers, so a-1:10; b-a; b[1]-999; a[1] = 999. Similarly, functions cannot modify the contents of their arguments. There is no equivalent to set-car!/rplaca (not even pairlists and expressions). For example, r-pairlist(1,2); r[[1]]-r does not create a circular list. And in general there doesn't seem to be substructure sharing at the semantic level (though there may be in the implementation). R does not have multiple value return in the Lisp sense. R assignment creates a new local variable on first assignment, dynamically. So static analysis is not enough to determine variable reference (R is not referentially transparent). Example: ff - function(a){if (a) x-1; x} ; x-99; ff(T) - 1; ff(F) - 99. Correct, and a fair nuisance for code analysis and compilation work. I'm not sure how much would break if R adopted the conventions in Python (or with Scheme's define as I recall) that referencing a not yet initialized local variable is an error. I'm not sure I would label this as meaning R is not referentially transparent thoug -- that goes out the window with mutable bindings as also available in Scheme. In R, most data types (including numeric vectors) do not have a standard external representation which can be read back in without evaluation. The default print form is not readable in this sense but dput is available for this purpose. R coerces logicals to numbers and numbers to strings. Lisps are stricter about automatic type conversion -- except that false a.k.a. NIL == () in Lisps other than Scheme. A more important difference may be that logicals can have three values -- TRUE, FALSE and NA. luke [[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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] More than doubling performance with snow
Hi Markus, I'm happy to participate in this, as I think I said previously. I won't have time to look carefully at the draft until sometime next week, but I remain puzzled about the high time listed for case 3 with snow/Rmpi. It would be good to understand what is going on there -- the discrepancy between show/Rmpi and the other snow variants seems odd. I'm not sure how meaningful the timing comparisons are overall. The differences are mainly overhead due to additional feature and communication difference. The feature-related overhead is not likely to be important in any real examples. In my experience, if communication is an issue in a substantial (i.e. realistic) computaiton, then a more sophisticated approach than simple scatter-compute-gather is needed, and then the ability to express such an approach becomes more important than the performance per se. Best, luke On Mon, 24 Nov 2008, Markus Schmidberger wrote: Hi, there is a new mailing list for R and HPC: [EMAIL PROTECTED] This is probably a better list for this question. Do not forget, first of all you have to register: https://stat.ethz.ch/mailman/listinfo/r-sig-hpc In this case the communication overhead is the problem. The data / matrix is to big! Have a look to the function snow.time to visualize your communication and calculation time. It is a new function in snow_0.3-4. ( http://www.cs.uiowa.edu/~luke/R/cluster/ ) Best Markus Stefan Evert wrote: I'm sorry but I don't quite understand what not running solve() in this process means. I updated the code and it do show that the result from clusterApply() are identical with the result from lapply(). Could you please explain more about this? The point is that a parallel processing framework like Snow and PVM does not execute the operation in your (interactive) R session, but rather starts separate computing processes that carry out the actual calculation (while your R session is just waiting for the results to become available). These separate processes can either run on different computers in a network, or on your local machine (in order to make use of multiple CPU cores). user system elapsed 0.584 0.144 4.355 user system elapsed 4.777 0.100 4.901 If you take a close look at your timing results, you can see that the total processing time (elapsed) is only slightly shorter with parallelisation (4.35 s) than without (4.9 s). You've probably been looking at user time, i.e. the amount of CPU time your interactive R session consumed. Since with parallel processing, the R session itself doesn't perform the actual calculation (as explained above), it is mostly waiting for results to become available and user time is therefore reduced drastically. In short, when measuring performance improvements from parallelisation, always look at the total elapsed time. So why isn't parallel processing twice as fast as performing the caculation in a single thread? Perhaps the advantage of using both CPU cores was eaten up by the communication overhead. You should also take into account that a lot of other processes (terminals, GUI, daemons, etc.) are running on your computer at the same time, so even with parallel processing you will not have both cores fully available to R. In my experience, there is little benefit in parallelisation as long as you just have two CPU cores on your computer (rather than, say, 8 cores). Hope this clarifies things a bit (and is reasonably accurate, since I don't have much experience with parallelisation), Stefan [ [EMAIL PROTECTED] | http://purl.org/stefan.evert ] __ 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. -- Dipl.-Tech. Math. Markus Schmidberger Ludwig-Maximilians-Universität München IBE - Institut für medizinische Informationsverarbeitung, Biometrie und Epidemiologie Marchioninistr. 15, D-81377 Muenchen URL: http://www.ibe.med.uni-muenchen.de Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de Tel: +49 (089) 7095 - 4599 __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE
Re: [R] Portected? Variable assignment? Was RE: The use of F for False and T for True
Have a look at ?lockBinding Best, luke On Mon, 17 Nov 2008, Lucke, Joseph F wrote: The TRUE/FALSE vs. T/F issue brings up a related one. Can one assign a variable a value during an R session that cannot be re-assigned any new value during the session? That is, the variable is `protected' from change during the session. `Session' here is not precisely defined, so that will induce some problems. A reference to this problem would be sufficient. __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] torque/psb snow library
You may or may not see speed substantial improvements using Rmpi with (or without) snow but you might -- depends on how the cluster is configured, what version of MPI, etc. In my experience using snow with sockets, pvm, or LAM/MPI for typical computations running an a multi-core machine vs remote machines doesn't make much difference. IF it does then you may have too much communicationrelative to computation and that mey need to be resolved no matter who you do things if you are to see good speedups. The development version of snow on my website http://www.stat.uiowa.edu/~luke/R/cluster/snow_0.3-4.tar.gz includes some experimental visualization tools that may help see what is going on. Do v - snow.time(... your computation ...) plot(v) and you get a Gantt chart of the computation. Best, luke On Wed, 22 Oct 2008, [EMAIL PROTECTED] wrote: Thanks you! I'll look at this new list! Well, I'm not the system administrator, and my installation of Rmpi and/or pvm libraries for R crashes. As this is the first time I parallelize some jobs, snow appealed as a first approach because 1) it compiled correctly and 2) the use of the library is very easy. As you tell me MPI is faster, I'll retry Rmpi installation. B. Regards, Javier .. Hi Javier, there is a new mailing list for R and HPC: [EMAIL PROTECTED] This is probably a better list for your question. I never tried torque with socket. We use torque and mpi or pvm (and R) and it is working very well. Why do you use socket as communication layer? MPI was especially developed for communication between nodes in a computer cluster. And there you can specify which nodes and the number of processors per node you want use. Therfore I would strongly recommend to use MPI. This will be faster in every condition! Best Markus [EMAIL PROTECTED] wrote: Hello all; I'm trying to execute parallel jobs trough library snow on a cluster built through torque/PSB. I'm succesfully obtaining the cluster with: system(cat $PBS_NODEFILE cluster.txt) mycluster - scan(file=cluster.txt,what=character) cl - makeSOCKcluster(mycluster) The only problem, at the moment, is that if I use processors in nodes other that the one in which I'm running R, the communication is extremely slow. If all processor are in the master computer there not seems ti be any problem. Has anyone got any experience with this and any advice? Perhaps snow() s not adequate for this kind of clusters? Thanks and best regards, Javier __ 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. -- Dipl.-Tech. Math. Markus Schmidberger Ludwig-Maximilians-Universität München IBE - Institut für medizinische Informationsverarbeitung, Biometrie und Epidemiologie Marchioninistr. 15, D-81377 Muenchen URL: http://www.ibe.med.uni-muenchen.de Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de Tel: +49 (089) 7095 - 4599 __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] Fatal error: unable to restore saved data in .RData
If you are able to create a .Rdata file for which this fails can you record the last few commands before you create the .Rdata file? luke On Fri, 10 Oct 2008, Thompson, David (MNR) wrote: Hello, I am unable to start an R session by double-clicking on an existing .RData file from the Windoze file explorer. A dialogue appears with the message Fatal error: unable to restore saved data in .RData, and I notice in the R Console the last few lines are: Loading required package: R2HTML NULL error in function () : unused argument(s) (1:43) I tried starting a fresh R session, changing the working directory, saving a new empty workspace, closing R, and restarting with the new (empty) .RData file to the same effect. I tried with the --vanilla option, changing the working directory and loading the existing workspace, and get the error message: Error in function () : unused argument(s) (1:43) And again with the --no-restore-data option, same effect. Suggestions? Thanx, DaveT. ### # system info: sessionInfo() ; cat(\n) ; Sys.info()[c(1:3,5)] R version 2.7.2 (2008-08-25) i386-pc-mingw32 locale: LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY= English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods base other attached packages: [1] debug_1.1.0 mvbutils_1.1.1 lattice_0.17-14 plotrix_2.4-7 svSocket_0.9-5 TinnR_1.0.2 R2HTML_1.59 Hmisc_3.4-3 loaded via a namespace (and not attached): [1] cluster_1.11.11 grid_2.7.2 svMisc_0.9-5tools_2.7.2 sysname release version machine Windows XP build 2600, Service Pack 2 x86 # system info: ### * Silviculture Data Analyst Ontario Forest Research Institute Ontario Ministry of Natural Resources [EMAIL PROTECTED] http://ontario.ca/ofri __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Fatal error: unable to restore saved data in .RData
On Fri, 10 Oct 2008, Thompson, David (MNR) wrote: Hello, I may have found the problem, although I don't understand it. When I commented out the following line in my Rprofile.site file the problem _seemed_ to disappear. # ans as shorthand for .Last.value # makeActiveBinding(ans, function() .Last.value, .GlobalEnv) What I believe is happening is that your profile sets this up as an active binding that cannot be assigned to before the .RDate is loaded and loading the .RData is trying to assign to it. If you want to avoid the error you can use ## the argument 'v' means assignment to 'ans' will be ignored instead of ## generating an error message. makeActiveBinding(ans, function(v) .Last.value, .GlobalEnv) I decided to do this after reading the help for bindenv {base} and the phrase . . . experimental interface . . . JUMPED right out at me. Again, I don't know if this was _actually_ the cause of my problem but, I am underway again. It would probably be best to recommend that the functins used in active bindings always take one argument and, if assignment is not supposed to happen, either ignore that argument it it is supplied or signal an explicit error. I'll look at the help page and think about appropriate changes. Best, luke Thanx, DaveT. -Original Message- From: Thompson, David (MNR) Sent: October 10, 2008 10:26 AM To: 'r-help@r-project.org' Subject: Fatal error: unable to restore saved data in .RData Hello, I am unable to start an R session by double-clicking on an existing .RData file from the Windoze file explorer. A dialogue appears with the message Fatal error: unable to restore saved data in .RData, and I notice in the R Console the last few lines are: Loading required package: R2HTML NULL error in function () : unused argument(s) (1:43) I tried starting a fresh R session, changing the working directory, saving a new empty workspace, closing R, and restarting with the new (empty) .RData file to the same effect. I tried with the --vanilla option, changing the working directory and loading the existing workspace, and get the error message: Error in function () : unused argument(s) (1:43) And again with the --no-restore-data option, same effect. Suggestions? Thanx, DaveT. ### # system info: sessionInfo() ; cat(\n) ; Sys.info()[c(1:3,5)] R version 2.7.2 (2008-08-25) i386-pc-mingw32 locale: LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_ MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods base other attached packages: [1] debug_1.1.0 mvbutils_1.1.1 lattice_0.17-14 plotrix_2.4-7 svSocket_0.9-5 TinnR_1.0.2 R2HTML_1.59 Hmisc_3.4-3 loaded via a namespace (and not attached): [1] cluster_1.11.11 grid_2.7.2 svMisc_0.9-5tools_2.7.2 sysname release version machine Windows XP build 2600, Service Pack 2x86 # system info: ### * Silviculture Data Analyst Ontario Forest Research Institute Ontario Ministry of Natural Resources [EMAIL PROTECTED] http://ontario.ca/ofri * __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Load a program at the front end
Something like env R_PROFILE=prog.R R may work for you. You may need to call .First.sys at the beginning of prog.R to get default packages loaded. luke On Tue, 7 Oct 2008, Gang Chen wrote: Thanks a lot for the suggestion! Unfortunately R --no-save prog.R does not work well with my situation because prog.R contain lines such as readline() and () that require user response in the middle of the execution. I also tried other options such as R -f prog.R and R --interactive prog.R, and they all failed. Any other suggestions? Thanks, Gang On Mon, Oct 6, 2008 at 10:12 PM, Bernardo Rangel Tura [EMAIL PROTECTED] wrote: Em Qui, 2008-10-02 às 14:36 -0400, Gang Chen escreveu: I want to run a R program, prog.R, interactively. My question is, is there a way I can start prog.R on the shell terminal when invoking R, instead of using source() inside R? TIA, Gang Hi Gang I my system just only type: R --no-save prog.R platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status Patched major 2 minor 7.2 year 2008 month 09 day11 svn rev46532 language R version.string R version 2.7.2 Patched (2008-09-11 r46532) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] Problem with R on dual core under Linux - can not execute mpi.spawn.Rslaves()
with snow directly. Martin I followed the pdf Developing parallel programs using snowfall by Jochen Knaus,. installed the relevant libraries and programs, but it does not work. I am stuck. Any help appreciated, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa __ 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. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793 -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] cluster/snow question
information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities. [[alternative HTML version deleted]] -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] cluster/snow question
, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities. [[alternative HTML version deleted]] -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Information on the number of CPU's
The wmic command line utility can also be used to query this; on a dual-core Vista laptop I get C:\Users\lukewmic cpu get NumberOfCores,NumberOfLogicalProcessors NumberOfCores NumberOfLogicalProcessors 2 2 luke -- Luke Tierney University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu On Tue, 9 Sep 2008, [EMAIL PROTECTED] wrote: Many thanks, that's very helpful. Regards, Tolga - Original Message - From: Prof Brian Ripley [EMAIL PROTECTED] Sent: 09/09/2008 20:57 CET To: Tolga Uzuner Cc: r-help@r-project.org Subject: Re: [R] Information on the number of CPU's On Tue, 9 Sep 2008, [EMAIL PROTECTED] wrote: Dear R Users, I am on Windows XP SP2 platform, using R version 2.7.2 . I was wondering if there is a way to find out, within R, the number of CPU's on my machine ? I would use this information to set the number of nodes in a cluster, depending on the machine. Sys.info() and .Platform do not carry this information. Correct, since a) R does not make use of more than 1. b) It is really not portable, and not even well-defined. (How many CPUs has a hyperthreaded dual Xeon? Some say 2, some say 4. Do you want CPUs or cores? If this is a virtualized OS, is the physical number or the logical number?) In the case of Windows, how depends on the Windows version. The w32api (XP or later) call GetNativeSystemInfo will tell you the number of CPUs, for some (unstated) definition of 'CPU'. Later versions have GetLogicalProcessorInformation, which can give the number of cores. Thanks in advance, Tolga Uzuner -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities. __ 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-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.
Re: [R] pnmath compilation failure; dylib issue?
qtukey.o qunif.o qweibull.o sign.o stirlerr.o toms708.o workers1.o -lpthread -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning, duplicate dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libgcc_s.1.dylib ld: in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libstdc++.6.dylib, file is not of required architecture collect2: ld returned 1 exit status make: *** [pnmath0.so] Error 1 ** Removing '/Library/Frameworks/R.framework/Resources/library/pnmath0' chmod: /Library/Frameworks/R.framework/Resources/library/pnmath0/libs/ppc/*: No such file or directory ERROR: compilation failed for package 'pnmath0' -- Eric Rupley University of Michigan, Museum of Anthropology 1109 Geddes Ave, Rm. 4013 Ann Arbor, MI 48109-1079 [EMAIL PROTECTED] +1.734.276.8572 __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] pnmath compilation failure; dylib issue?
On Thu, 21 Aug 2008, Luke Tierney wrote: On Wed, 20 Aug 2008, Eric Rupley wrote: (1) ...need to speed up a monte-carlo sampling...any suggestions about how I can get R to use all 8 cores of a mac pro would be most useful and very appreciated... Using something like the snow package for explicitly parallelizing your computations may give you the greatest improvement. (2) spent the last few hours trying to get pnmath to compile under os-x 10.5.4... Looking at the error messages it seems you have a ppc version of the libgomp dylib but are trying to build for i386. How this came about or how to fix your setup I do not know -- you might get more help on the R-SIG-Mac list. You could also try pnmath0, which doesn't use OpenMP and so doesn't need libgomp. luke luke using gcc version 4.2.1 (Apple Inc. build 5553) as downloaded from CRAN, xcode 3.0... ...xcode 3.1 installed over top of above after compilation failure...adverse effect, produced error on -arch any suggestion about how to get pnmath to compile would be most useful...I'm not sure it will even speed things up but thought I would try... pnmath failed: ... gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o pnmath.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchisq.o pnf.o pnmath.o pnorm.o pnt.o polygamma.o ppois.o pt.o ptukey.o punif.o pweibull.o qbeta.o qbinom.o qcauchy.o qchisq.o qexp.o qf.o qgamma.o qgeom.o qhyper.o qlnorm.o qlogis.o qnbeta.o qnbinom.o qnchisq.o qnf.o qnorm.o qnt.o qpois.o qt.o qtukey.o qunif.o qweibull.o sign.o stirlerr.o toms708.o -lgomp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning, duplicate dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libgcc_s.1.dylib ** arch - ppc ... gcc -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o pnmath.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchisq.o pnf.o pnmath.o pnorm.o pnt.o polygamma.o ppois.o pt.o ptukey.o punif.o pweibull.o qbeta.o qbinom.o qcauchy.o qchisq.o qexp.o qf.o qgamma.o qgeom.o qhyper.o qlnorm.o qlogis.o qnbeta.o qnbinom.o qnchisq.o qnf.o qnorm.o qnt.o qpois.o qt.o qtukey.o qunif.o qweibull.o sign.o stirlerr.o toms708.o -lgomp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libgomp.dylib, file is not of required architecture ld: warning, duplicate dylib /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libgcc_s.1.dylib ld: in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libstdc++.6.dylib, file is not of required architecture collect2: ld returned 1 exit status make: *** [pnmath.so] Error 1 chmod: /Library/Frameworks/R.framework/Resources/library/pnmath/libs/ppc/*: No such file or directory ** Removing '/Library/Frameworks/R.framework/Resources/library/pnmath' ERROR: compilation failed for package 'pnmath' pnmath0 failed with the same first error; the second error was: ... gcc -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o pnmath0.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchisq.o pnf.o pnmath1.o pnorm.o pnt.o polygamma.o ppois.o pt.o ptukey.o punif.o pweibull.o qbeta.o qbinom.o
Re: [R] R-Embedding and error messages
On Wed, 20 Aug 2008, Martin Morgan wrote: Hi Jorge -- I hesitate to suggest this unsupported solution (as these public suggestions tend to mean that the solution disappears!), but in C Don't use this -- it is subject to change/removal with no notice. I do not believe there is a C level methanism for catching the R error conditon at this point. Thinking about this is on the list but it hasn't happened yet. One thing you can do is use the geterrmessage R function to retrieve the most recent message (so if R_tryEval indicates an error occurred then build and execute a call to geterrmessage and extranct the message from the returned STRSXP). luke extern void R_SetErrorHook(void (*)(SEXP, char *)); void my_ErrorHook(SEXP call, char *message) { /* etc; e.g., cache message, perhaps reset error hook (hook is removed after error; nested R-level try() may mean multiple errors per R_tryEval? */ } and then ... R_SetErrorHook( my_ErrorHook ); PROTECT(value = R_tryEval( expr, env, errorOccurred )); if( *errorOccurred ) { /* etc, e.g., retrieve error message(s) from cache */ } /* hmm, maybe R_SetErrorHook needs to be cleared here, or at least replaced with a no-op? */ ... This is an R-devel question, not R-help. Martin Jorge W. Cardoso [EMAIL PROTECTED] writes: I'm writing a C++ application using R-embedding to do some forecast process. I also use R_tryEval instead of R_Eval to run my R-script, so that in case of error I know exactly in which line number was the last error. In particular, from time in time y get some error messages refering an exceptional condition in the arima model. I want to catch these error messages from de C code (or at least the code error number) to take some corrective actions. Is there any way to do that ? Regards, Jorge W. Cardoso __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Saving environment object
On Fri, 15 Aug 2008, Benjamin Otto wrote: Hi, When I create an environment object with new.env() and populate it with values then how can I save it into an .RData file properly, so it can be loaded later on in a new session? Saving an environment object with save() or save.image() results in an error message when loading again: Error: protect(): protection stack overflow save/load works fine (and is used in many places): e-new.env() assign(e, e, envir = e) assign(x, 2, envir = e) save(e, file = test.Rda) rm(e) load(test.Rda) e environment: 0x1c2c748 There may be something about the values you are using that is causing problems, but there is no way to tell without a reproducible example. luke Regards, benjamin == Benjamin Otto University Hospital Hamburg-Eppendorf Institute For Clinical Chemistry Martinistr. 52 D-20246 Hamburg Tel.: +49 40 42803 1908 Fax.: +49 40 42803 4971 == -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Saving environment object
On Fri, 15 Aug 2008, Prof Brian Ripley wrote: Having been told that this was a particular very large environment, Luke's comments in serialize.c wouild seem to apply: The output format for dotted pairs writes the ATTRIB value first rather than last. This allows CDR's to be processed by iterative tail calls to avoid recursion stack overflows when processing long lists. The writing code does take advantage of this, but the reading code does not. It hasn't been a big issue so far--the only case where it has come up is in saving a large unhashed environment where saving succeeds but loading fails because the PROTECT stack overflows. With the ability to create hashed environments at the user level this is likely to be even less of an issue now. But if we do need to deal with it we can do so without a change in the serialization format--just rewrite ReadItem to pass the place to store the CDR it reads. (It's a bit of a pain to do, that is why it is being deferred until it is clearly needed.) Thanks -- I had forgotten about that (and would still prefer to defer rewriting ReadItem :-)) luke So I think the moral is to hash large environments, and increasing --max-ppsize should enable this one to be read in. On Fri, 15 Aug 2008, Luke Tierney wrote: On Fri, 15 Aug 2008, Benjamin Otto wrote: Hi, When I create an environment object with new.env() and populate it with values then how can I save it into an .RData file properly, so it can be loaded later on in a new session? Saving an environment object with save() or save.image() results in an error message when loading again: Error: protect(): protection stack overflow save/load works fine (and is used in many places): e-new.env() assign(e, e, envir = e) assign(x, 2, envir = e) save(e, file = test.Rda) rm(e) load(test.Rda) e environment: 0x1c2c748 There may be something about the values you are using that is causing problems, but there is no way to tell without a reproducible example. luke Regards, benjamin == Benjamin Otto University Hospital Hamburg-Eppendorf Institute For Clinical Chemistry Martinistr. 52 D-20246 Hamburg Tel.: +49 40 42803 1908 Fax.: +49 40 42803 4971 == -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] tryCatch question
Read the argment descriptions and Look at the examples in ?tryCatch. The `expr' argument (i.e. the code to try) and the `finally' argument are expressions that are evaluated (via standard lazy evaluation of arguments). The error condition handlers, provided as the `...' argument in errorClass = handler form(s), are functions of one argument, the error condition. As in the examples I usualy use fuctions writen in-line. There is no non-standard evaluation involved, so standard scoping rules apply. luke On Thu, 14 Aug 2008, [EMAIL PROTECTED] wrote: I would like to use the 'tryCatch' function but am having a hard time getting my head around it. In 'C' like languages try/catch/finally means try a block of statements and if any throw an error then do the statements in the catch block and then error or not always do the staements in the finally block. In 'R' as best as I can tell the block of staements in the try block is a single function. Does this mean I need to construct a temporary function that contains what I would have put in the try blck? Also in 'R' it seems the 'finally' function (of 'tryCatch' most closely mimics the catch block of 'C'. Right? A similar comment on the finally function. Do I need to create a temporary function that contains the staements that I normally would put in a 'C' like catch clause? If I do need to create functions for the try and error conditions what is the scope or enviironment that the functions are called under? The 'try' function is relatively straightforward but when an error occurs what variable will I have access to? Thank you. Kevin __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] aligned memory allocation in C
On Wed, 13 Aug 2008, Christophe Dutang1 wrote: Hi, I'm currently R porting SF Mersenne Twister algorithm of Matsumoto and Saito. To get the full power of their code, I want to use their fonction fill_array32 which need aligned memory. That is to say I need to use the C function memalign on windows, posix_memalign on linux and classic malloc on Mac OS. In 'writing R extenstion', they recommand to use R_alloc function to allocate memory in C. Does R_alloc return a pointer to aligned memory? if not how can I do this? probably no, because R crashes when I succesively R_alloc and fill_array32 (cf below) on my macbook with R 2.7.1. R_alloc's alignment will be appropriate for holding any data type. It will be offset from a value returned by malloc by a multiple of 8 bytes. My recollection, which may be wrong, is that on both Intel and PPC unaligned access to all basic data types is permitted but may be inefficient (in particular on Intel), so the reason for your crash is probably elsewhere. Best, luke Thanks in advance Kind regards Christophe PS : http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/howto-compile.html provides an example of memalign. PPS : mac os report Thread 0 Crashed: 0 libSystem.B.dylib 0x9341bb9e __kill + 10 1 libSystem.B.dylib 0x93492ec2 raise + 26 2 libSystem.B.dylib 0x934a247f abort + 73 3 randtoolbox.so 0x15e65f1d 0x15e5d000 + 36637 4 randtoolbox.so 0x15e614ef fill_array32 + 4038 5 randtoolbox.so 0x15e6513d SFmersennetwister + 335 6 randtoolbox.so 0x15e652c6 doSFMersenneTwister + 255 7 libR.dylib 0x00367a52 do_dotcall + 1394 8 libR.dylib 0x0038b5a2 Rf_eval + 1754 9 libR.dylib 0x0038f9a2 do_set + 592 10 libR.dylib 0x0038b366 Rf_eval + 1182 11 libR.dylib 0x0038b366 Rf_eval + 1182 12 libR.dylib 0x0038c140 do_begin + 58 13 libR.dylib 0x0038b366 Rf_eval + 1182 14 libR.dylib 0x0038b366 Rf_eval + 1182 15 libR.dylib 0x0038c140 do_begin + 58 16 libR.dylib 0x0038b366 Rf_eval + 1182 17 libR.dylib 0x0038d9a6 Rf_applyClosure + 663 18 libR.dylib 0x0038b25d Rf_eval + 917 19 org.R-project.R 0x000189c3 run_REngineRmainloop + 569 (Rinit.m:442) 20 org.R-project.R 0x0001142a -[REngine runREPL] + 260 (REngine.m:181) 21 org.R-project.R 0x2e91 main + 795 (main.m:126) 22 org.R-project.R 0x2b5a _start + 216 23 org.R-project.R 0x2a81 start + 41 __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Parallel R
pnmath currently uses up to 8 threads (i.e. 1, 2, 4, or 8). getNumPnmathThreads() should tell you the maximum number used on your system, which should be 8 if the number of processors is being identified correctly. With the size of m this calculation should be using 8 threads, but the exp calculation is fairly fast, so the overhead is noticable. On a Linux box with 4 dual-core AMD processors I get m - matrix(0, 1, 1000) mean(replicate(10, system.time(exp(m), gcFirst=TRUE))[elapsed,]) [1] 0.3859 library(pnmath) mean(replicate(10, system.time(exp(m), gcFirst=TRUE))[elapsed,]) [1] 0.0775 A similar example using qbeta, a slower function, gives p - matrix(0.5,1000,1000) setNumPnmathThreads(1) [1] 1 mean(replicate(10, system.time(qbeta(p,2,3), gcFirst=TRUE))[elapsed,]) [1] 7.334 setNumPnmathThreads(8) [1] 8 mean(replicate(10, system.time(qbeta(p,2,3), gcFirst=TRUE))[elapsed,]) [1] 0.9576 On an 8-core Intel/OS X box the improvement for exp is much less, but is similar for qbeta. luke On Thu, 10 Jul 2008, Martin Morgan wrote: Juan Pablo Romero Méndez [EMAIL PROTECTED] writes: Just out of curiosity, what system do you have? These are the results in my machine: system.time(exp(m), gcFirst=TRUE) user system elapsed 0.520.040.56 library(pnmath) system.time(exp(m), gcFirst=TRUE) user system elapsed 0.660 0.016 0.175 from cat /proc/cpuinfo, the original results were from a 32 bit dual-core system model name : Intel(R) Core(TM)2 CPU T7600 @ 2.33GHz Here's a second set of results on a 64-bit system with 16 core (4 core on 4 physical processors, I think) mean(replicate(10, system.time(exp(m), gcFirst=TRUE))[elapsed,]) [1] 0.165 mean(replicate(10, system.time(exp(m), gcFirst=TRUE))[elapsed,]) [1] 0.0397 model name : Intel(R) Xeon(R) CPU X7350 @ 2.93GHz One thing is that for me in single-thread mode the faster processor actually evaluates slower. This could be because of 64-bit issues, other hardware design aspects, the way I've compiled R on the two platforms, or other system activities on the larger machine. A second thing is that it appears that the larger machine only accelerates 4-fold, rather than a naive 16-fold; I think this is from decisions in the pnmath code about the number of processors to use, although I'm not sure. A final thing is that running intensive tests on my laptop generates enough extra heat to increase the fan speed and laptop temperature. I sort of wonder whether consumer laptops / desktops are engineered for sustained use of their multiple core (although I guess the gaming community makes heavy use of multiple cores). Martin Juan Pablo system.time(exp(m), gcFirst=TRUE) user system elapsed 0.108 0.000 0.106 library(pnmath) system.time(exp(m), gcFirst=TRUE) user system elapsed 0.096 0.004 0.052 (elapsed time about 2x faster). Both BLAS and pnmath make much better use of resources, since they do not require multiple R instances. __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] compiling pnmath on an intel processor running mac OS 10.5
You need a gcc version that supports OpenMP; I believe that means gcc 4.2 or later. pnmath0 should work with older gcc versions. luke On Thu, 10 Jul 2008, Mike Lawrence wrote: Has anyone successfully compiled pnmath (http://www.stat.uiowa.edu/~luke/R/experimental) for an intel processor running mac OS 10.5? When I attempt to do so via the R package installer (choosing Local Source Package and pointing to the pnmath_0.0-2.tar.gz file), I get the following errors: * Installing *source* package 'pnmath' ... ** libs ** arch - i386 gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -msse3 -fopenmp -fPIC -g -O2 -march=nocona -c bd0.c -o bd0.o cc1: error: unrecognized command line option -fopenmp make: *** [bd0.o] Error 1 ** arch - ppc chmod: /Library/Frameworks/R.framework/Resources/library/pnmath/libs/i386/*: No such file or directory gcc -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/ppc -I/usr/local/include -fopenmp -fPIC -g -O2 -c bd0.c -o bd0.o cc1: error: unrecognized command line option -fopenmp make: *** [bd0.o] Error 1 chmod: /Library/Frameworks/R.framework/Resources/library/pnmath/libs/ppc/*: No such file or directory ERROR: compilation failed for package 'pnmath' ** Removing '/Library/Frameworks/R.framework/Resources/library/pnmath' -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University www.memetic.ca The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less. - Piet Hein __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] passing a variable at the command line
commandArgs may do what you want. Best, luke On Tue, 1 Jul 2008, Erin Hodgess wrote: Dear R People: I have used ./R --no-save -q -f e.in stuff.out with great success on SUSE10.1 with R-2.7.1. My question is, please: is there a way to pass in a variable to the e.in file? I'm fairly sure that the answer is no, but thought I'd double check. Thanks in advance, Sincerely, Erin -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Speedups with Ra and jit
speed-ups like that or better just using vectorised code intelligently: conv3 - local({ conv - function(a, b, na, nb) { r - numeric(na + nb -1) ij - 1:nb for(e in a) { r[ij] - r[ij] + e*b ij - ij + 1 } r } function(a, b) { na - length(a) nb - length(b) if(na nb) conv(a, b, na, nb) else conv(b, a, nb, na) } }) system.time(tst3 - conv3(x, y)) user system elapsed 0.110.000.11 all.equal(tst1, tst3) [1] TRUE 0.55/0.11 [1] 5 9.56/0.11 [1] 86.90909 ie. a further 5-fold increase in speed, or about 87 times faster than the unassisted naïve code. I think the lesson here is if you really want to write R code as you might C code, then jit can help make it practical in terms of time. On the other hand, if you want to write R code using as much of the inbuilt operators as you have, then you can possibly still do things better. Of course sometimes you don't have the right inbuilt operators. In that case you have a three-way choice: slow R code and wait, faster R code speeded up with Ra and jit, or, (the way it probably should be done), with dynamically loaded C or Fortran code. Portability decreases as you go, of course. Bill Venables __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] findGlobals on apply
On Tue, 8 Apr 2008, Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. You are missing some points about R and findGlobals. In R, functions are first class values: they can be assigned to variables, passed as arguments, and returned as results, just like vectors. In contrast to many other languages there is not special mechanism for defining functions and associating them with a name -- the way you define a function is foo - function(...) ... which creates a function value and assigns it to a variable. findGlobals just looks at the function body and arguments and determines which of the variables used would have their definitions looked up in the global environment if this code is run. It does not try to detect which of these have values or not, never mind what the types of those falues are. The result returned by findGlobals with merge=FALSE separates into variables that are explicitly used as funcitons, i.e foo in foo(x) and ones that are not. One could argue that findGlobals should know enough about apply() to realize that the FUN argument is implicitly used as a function; if this change were made then apply(x, 2, pi) pi would be listed as a function because it is _used_ that way. Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You need to do some extra work to get this -- checking which globals have values, and maybe whether those that are used as functions have values that are functions. checkUsage does this, among other things. For this example checkUsage produces checkUsage(f) anonymous: no visible binding for global variable âmObjectâ luke Christophe __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] findGlobals on apply
On Wed, 9 Apr 2008, Christophe Genolini wrote: Hi Luke Thanks for all these explanation, things are clearer. Let me go back on my initial problem, that was, as a programmer, I would like to have a tool to detect typo by detecting globals variables: I get that findGlobals is not design for that. I did not realy understand the use of checkUsage (sorry for that, I am not a high level programmer). But I find an example on which checkUsage does not detect the typo either: mObjBis - 3 f - function(myOb){ myObBis - myOb^2 plot(myObBis) return(mObjBis) } checkUsage(f,all=TRUE) I don't see how a general tool can detect a problem here. If you know the only global variables you will ever use are functions then you can write your own tool to reflect that style, but for common styles there is no clear reason I can see to detect a problem here. A C compiler could not detect a problem here unless the function was declared to have a different return type than the global variable. So, my question is a more general question : is there a function that can detect global variable with exclusion of the function and the reserved word? For example: g - function(x)return(x+pi) we don't want pi to be considere as a global variable since it is a constant... But in R pi is a global variable. checkUsage doesn't warn about its use because it has a binding. Is there a function that can deal with that ? If you know what you want you can write one, something like myGlobals - function(f, exclude = c(pi, T, F)) { isGlobFun - function(s) ! (exists(s, .GlobalEnv) is.function(get(s,.GlobalEnv))) g - findGlobals(f) setdiff(g[sapply(g, isGlobFun)], exclude) } I would suggest you use this sort of thing in conjunction with checkUsage since that checks for other kinds of errors; for example look at what it does with the variant f - function(myOb){ myObBis - myOb^2 plot(mObjBis) return(mObjBis) } Best, luke Christophe On Tue, 8 Apr 2008, Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. You are missing some points about R and findGlobals. In R, functions are first class values: they can be assigned to variables, passed as arguments, and returned as results, just like vectors. In contrast to many other languages there is not special mechanism for defining functions and associating them with a name -- the way you define a function is foo - function(...) ... which creates a function value and assigns it to a variable. findGlobals just looks at the function body and arguments and determines which of the variables used would have their definitions looked up in the global environment if this code is run. It does not try to detect which of these have values or not, never mind what the types of those falues are. The result returned by findGlobals with merge=FALSE separates into variables that are explicitly used as funcitons, i.e foo in foo(x) and ones that are not. One could argue that findGlobals should know enough about apply() to realize that the FUN argument is implicitly used as a function; if this change were made then apply(x, 2, pi) pi would be listed as a function because it is _used_ that way. Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You need to do some extra work to get this -- checking which globals have values, and maybe whether those that are used as functions have values that are functions. checkUsage does this, among other things. For this example checkUsage produces checkUsage(f) anonymous: no visible binding for global variable ???mObject??? luke Christophe __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ R-help@r-project.org mailing list https://stat.ethz.ch
Re: [R] snow, stopping cluster
Not at present. The next release should include something along these lines. luke On Thu, 27 Mar 2008, Markus Schmidberger wrote: Hello, is there any function in the package snow to check for a really running cluster? The function checkCluster only checks the variable cl. And the variable is still available after stopping the cluster! ( a simple solution would be deleting the cluster variable cl in the function stopCluster) library(snow) cl - makeCluster(5) 5 slaves are spawned successfully. 0 failed. clusterApply(cl, 1:2, get(+), 3) [[1]] [1] 4 [[2]] [1] 5 stopCluster(c1) [1] 1 clusterApply(cl, 1:2, get(+), 3) Fehler in mpi.probe(source, tag, comm, status) : MPI_Error_string: invalid communicator sessionInfo() R version 2.6.0 (2007-10-03) x86_64-unknown-linux-gnu locale: LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-8;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] affyPara_0.99.2 affy_1.16.0 preprocessCore_1.0.0 [4] affyio_1.6.1 Biobase_1.16.1 Rmpi_0.5-5 [7] snow_0.2-9 loaded via a namespace (and not attached): [1] rcompgen_0.1-15 Best Markus -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] help with oop in R - class structure and syntex
On Tue, 5 Feb 2008, Barry Rowlingson wrote: Duncan Murdoch wrote: Another problem is that there are two different class systems in R: sometimes calls S3 and S4 (because of the versions of S where they were introduced). You were reading about S3. There's three different class systems if you also include the R.oo add-on package[1]. Even perl, the language seemingly founded on the concept of TMTOWTDI[2], only has the one OOP system. You need to be a bit careful here. R has two object systems, S3, and S4, that are supported in the R internals to allow methods for things like `+` to be written. In addition, R is rich enough as a language to allow users to develop their own object systems if they choose. The fact that there are two internally supported systems is not ideal. On the other, the fact that users can write their own and have done so is a feature. luke Barry [1] http://www1.maths.lth.se/help/R/R.oo/ [2] There's More Than One Way To Do It __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Is R on Windows multi-threaded
I hope to get a new version of snow released in a couple of weeks that will work on Windows using a Windows Rmpi version or, at least on a local machine, a socket interface. luke On Sat, 12 Jan 2008, Prof Brian Ripley wrote: On Fri, 11 Jan 2008, Greg Snow wrote: Someone else suggested the snow package, but I don't think it is available for windows. It is. From http://cran.r-project.org/bin/windows/contrib/2.6/ReadMe Although the packages ROracle, and snow pass make check, it seems to be dangerous to distribute them: I do not have the software available these packages depend on. It compiles from the sources, and using snow alone you can run socket clusters on Windows (by default it expects ssh to be running, and Windows machines rarely run an ssh daemon so as to accept incoming ssh). The caution is that the packages runs no tests so needs manual intervention to test it, and in particular most people will want to run snow over Rmpi which does not compile on Windows without more software (and some effort). It might be worth modifying snow to more easily run multiple processes on a single machine. I have been able to get the nws package to work on a duel core machine using windows and it did speed up my tests (and was fairly straight forward to use). Dueling cores can be apt From: [EMAIL PROTECTED] on behalf of Rees, David Sent: Fri 1/11/2008 7:28 AM To: r-help@r-project.org Subject: [R] Is R on Windows multi-threaded Hi, A previous thread suggests that R on Windows is multi-threaded http://tolstoy.newcastle.edu.au/R/help/03b/6946.html When I'm running R 2.5.1 on a dual core pc I get Rgui.exe uses up to 50% of the available cpu and the rest is not used. i.e. it only uses one cpu. I'm soon going to get a nice shiny new 8 cpu machine which it would be very nice to fully utilize. Is there any way to get R to use all the cpus - should this happen automatically? Many thanks, Regards, David [[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. [[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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] R on a multi core unix box
You can use the socket implementation of snow, with library(snow) cl - makeCluster(rep(localhost, 2), type=SOCK) to start up a cluster of 2 R processes. luke On Thu, 6 Dec 2007, Saeed Abu Nimeh wrote: Hi, I installed the snow package on a unix box that has multiple cores. To be able to exploit the multiple cores (on one pc) do I still need to install the rmpi package (or rpvm). Another question, if i run a bayesian simulation on the multiple core after setting them up correctly (using snow), would you think there will be a noticeable speedup gain. Thanks, Saeed --- linux centos 4 dual core processors 32 gb ram R (2.6.0) snow 0.29 [[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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.
Re: [R] Use and misuse of update function for non-models. Any views/recommendations??
On Tue, 20 Nov 2007, Prof Brian Ripley wrote: update() is generic, so the recommended approach would be to write a method for your objects. Creating your own function update() in a package would probably not break too much, as namespaces would protect most functions using the generic in stats. But it could be very confusing to users. Maybe. update is generic with a netral set of argument names; on the other hand, the _documentation_ of update is not generic -- it is specific to updating models. So there is opportunity for confusion from that direction. Best, luke On Tue, 20 Nov 2007, Søren Højsgaard wrote: Dear all, I wonder if it is bad style (or something worse) to create an update function which does not work on model objects of the lm, glm etc. type. Specifically, I have some graph objects (graphs as mathematical objects, not as displays) which I want to alter and for that purpose I thought of writing an update function. Would doing so violate a deeper philosophy in the R system or have other unfortunate consequences. If so, I'm happy to hear other suggestions... Regards Søren __ 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. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ 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.
Re: [R] snow and Rmpi, delayed starting-times at nodes
On Fri, 2 Nov 2007, Markus Schmidberger wrote: Hello, we use R version 2.6.0, Rmpi_0.5-5 and snow_0.2-9 and have a parallel call like this: clusterApply(cluster, input.list, function(input, data1, type) { }, data1, type ) Most likely the problem is the direct use of function(...) ... here. This captures the local environment in ist closure, which is probably very large. Try defining the function you want to call at top level, or define a top level function to create your function if you do want a closure with specific tada captured. luke We now have the problem, that the processes at the nodes start delayed. This means for example, node 4 starts its calculation when node 1 is finished.(see the attached figure) Therefore we have a lot of loss in our computation time. Our messages are not very big: input.list = list of vectors. Each vector has 10 strings data1 = one integer type = one string What can we do to improve the speed? Thanks Markus -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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] examples of use of snow package
We have been asked to write a paper on the snow package for parallel computing in R for a parallel computing journal and would like to include some references to examples of the use of snow in practice beyond our own use. If you think you have a good example we would like to hear from you. Please let us know the appropriate citation to use. Best, luke -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ 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.