Re: [Rd] Is an R sub-session somehow possible?
Hello, Di you already look at svSocket (try the version on R-forge that corrects a couple of bugs recently -will be soon on CRAN, but only after further testing-)? It uses Tcl that already benefits from the modified even loop you mention, and it is well-tested since a long time since the tcltk package is a recommended R package and is widely used. With svSocket, you can easily do something like calltip, or completion list calculation while R is processing other commands, say at the command line, or through other calls to svSocket: it manages multiple clients simultaneously (or multiple connections from the same client, say, one for evaluation of R code, and another one to get calltip or completion list calculation, no matter if R is doing other calculations or not). If you want to get inspiration, you can inspect how SciViews-K is implemented (http://www.sciviews.org/SciViews-K). Best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 08/09/10 00:27, ghostwheel wrote: Simon Urbanek wrote: It doesn't really matter where the R is as long as you have some way of getting at the results. You are still leaving us in the dark as of what exactly you do (technically) so there is not much detail we can provide... Sorry, I'll try to provide more detail: I am trying to provide a good connection between the TeXmacs editor and R. (A really nice overview of such connections can be found in http://www.r-project.org/conferences/useR-2004/abstracts/supplements/Urbanek.pdf ;) What I do is fake a terminal, and interact with the command line interface to R (something like what the program 'expect' does). To detect that R is waiting for input I have to check various properties of the terminal. Not really pretty. What happens is that: 1. TeXmacs sends me a string to execute. 2. I pass it to R, and wait for a prompt. 3. I pass all of R's return, somewhat processed back to TeXmacs. Thus, when I want to put a graphics inside TeXmacs' buffer, I have to print something like 'start postscipt graphics', then the postscript file, then 'end postscript'. When the user asks for tab completion, TeXmacs sends me a special message saying that this string needs to be completed. I call a function in R, and return the result. My program is able to interact with a remote R session, i.e. the session will start on a different machine than the one TeXmacs runs on. Luckily, it is also possible to detect when R waits for a prompt in a remote session by doing these ugly terminal hacks. In some cases the R prompt won't be a prompt for another command, but instead, R is just waiting for user input, or for completion of the previous input. Now, my remaining question is this: When I run R remotely, by emulating a terminal, and interacting with R in command line mode, AND when at the same time R is not waiting for a command, but instead for some other kind of user interaction, my interface can't send to R a request to execute the code to complete a certain string. (I.e. call the function t.tab.complete that I attached below). If I understand correctly, one solution is to write a replacement input loop, so that R will call my ReadConsole() from time to time, and while I'm inside that function, I could call R functions to provide tab completion. In that case, for remote sessions, I would have to compile on the remote computer this alternative R input loop, and I would have to have one for every version of R that a user might want to run on the remote machine (the machine I am currently working with remotely has 11 versions of R installed...). I was wondering if there is still a way to avoid that, and interact with the regular input loop, or maybe it is possible to load an alternative input loop from a package/library inside an already running regular R interface? I would like the user to have to do as little as possible in terms of installing additional programs on a remote machine. Thanks, I'm not sure if this was the type of additional information you meant... Michael Here is my tab completion routine, ("\2" and "\5" are the codes for TeXmacs for a start and a stop of blocks. (basically like brackets) ). - t.tab.comp<-function(s,curs) { rc.settings(help=F) #This is because of a bug in matchAvailableTopics in package utils rc.settings(file=T) utils:::.assignLinebuffer(substr(s,1,curs)) utils:::.assignEnd(nchar(s)) utils:::.guessTokenFromLine() utils:::.completeToken() l=utils:::.retrieveCompletions() l=sapply(l,function(x) { substr(x, nchar(utils:::.CompletionEnv[["token"]])+1,nchar(x) ) } ) i=grep("=$",l) if( (length(l[-i])> 10)& (length(i)>0 ) ) l=c(l[i]) s3=utils:::.CompletionEnv[["token"]] s
Re: [Rd] readline operate-and-get-next
Dear Prof Ripley, * Rafael Laboissiere [2010-08-14 20:55]: > * Rafael Laboissiere [2010-08-12 20:24]: > > I did not hear from you but I went ahead and prepared a patch according > to your recommendations, attached below. I hope that the copyright and > licensing issues are correctly sorted out now. > > [snip] Have you had a chance to review the operate-and-get-next patch that I posted to r-devel last month? Best regards, Rafael Laboissière __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] winbuilder warnings and errors
Hello, I have been developing a package for phylogenetic analysis which I plan to submit to CRAN soon. It passes R CMD check with no warnings on my linux and Mac OS X machines. I don't have much experience with Windows and have been using the win-builder service to see how the package compiles on Windows. (Thank you for this service, Uwe, it is a huge time saver for me!) I have tried win-builder's R-release 32-bit and R-release 64-bit versions, and both return with different warnings/errors which I don't understand. However both do produce binaries which seem to work. For the 64-bit, the check goes fine until it gets to the vignettes, and then I get the message: * checking package vignettes in 'inst/doc' ... WARNING *** Weave Errors *** File d:/RCompile/CRANguest/R64-release/rphast.Rcheck/inst/doc/vignette2.Rnw : unable to start device PostScript * checking PDF version of manual ... OK I'm not sure if I should be concerned about this or not. I'm more troubled by the results of the 32-bit check, which produces an error. The log ends like this: * checking examples ... OK * checking tests ... ERROR Check process probably crashed or hung up for 20 minutes ... killed Most likely this happened in the example checks (?), if not, ignore the following last lines of example output: << here I snipped a bunch of example output that looks fine>> > > ### * > ### > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n") Time elapsed: 13.23 0.2 13.46 NA NA > grDevices::dev.off() null device 1 > ### > ### Local variables: *** > ### mode: outline-minor *** > ### outline-regexp: "\\(> \\)?### [*]+" *** > ### End: *** > quit('no') End of example output (where/before crash/hang up occured ?) So here are my questions: Does anyone have an idea what could cause the error above, or how I can troubleshoot it? I do have remote access to a windows machine and have installed the 32-bit binary, and all the testing code runs smoothly. Do I need to resolve these issues in order to submit my package to CRAN? I definitely want Windows binaries of my package to be available. Thanks for any advice, Melissa Melissa Hubisz Siepel Lab Department of Biological Statistics and Computational Biology Cornell University __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] How to add a slot to S4 class of an existing package?
On Tue, 7 Sep 2010 20:41:14 -0400, Kasper Daniel Hansen wrote: > Seb That thread and the resources in Biobase assumes that you have a > class that extends "Versioned". Doing so will help you in the long > run by providing you with updateObject (at the cost of some > complexity). However, it does not really help you if the existing > class does not extend Versioned. Thanks Kasper, indeed the class I'm working with doesn't have anything to do with Biobase, and having it extend "Versioned" along with the package dependencies only for this purpose seems overkill in my case. But perhaps one can implement a similar approach internally in the package without having to add a new dependency. > In general, adding a new slot should not break any existing code, but > you may find users who have old objects lying around that they cannot > use with the new functionality (I assume you are adding slots to > provide new functionality). Yes, the new slot adds new functionality and I also thought that adding a slot should not affect existing code. However, an error message during 'R CMD check' came up to the effect that an object did not have the new slot. Unfortunately, I didn't save more details nor investigated this error any further, but it got me doubting whether adding the slot would break existing code and access to objects of the older class. The object is under data/, although now I'm considering removing it and creating it in an example, which might be cleaner. -- Seb __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Development environment for R extentions on Windows
Hi all, I'm setting up a development environment on Windows as the subject implies. I've downloaded and installed Rtools211.exe (will upgrade later when necessary) and I've also downloaded and installed mingw with the help of mingw-get.exe. I come from a UNIX development background, so I'm at the bash shell prompt for just about every step in R extenstion development. Question is what is an appropriate environment for Windows development. What shell do you use? Do you use cmd.exe with the PATH variable set up by Rtools? Do you use the sh.exe that comes with Rtools? I've found the bash shell from MinGW to be a pretty close equivalent to bash on UNIX. Do you use something else? Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Development environment for R extentions on Windows
On 08/09/2010 1:21 PM, Jeffrey Horner wrote: Hi all, I'm setting up a development environment on Windows as the subject implies. I've downloaded and installed Rtools211.exe (will upgrade later when necessary) and I've also downloaded and installed mingw with the help of mingw-get.exe. I come from a UNIX development background, so I'm at the bash shell prompt for just about every step in R extenstion development. Question is what is an appropriate environment for Windows development. What shell do you use? Do you use cmd.exe with the PATH variable set up by Rtools? Do you use the sh.exe that comes with Rtools? I've found the bash shell from MinGW to be a pretty close equivalent to bash on UNIX. Do you use something else? I've used the bash shell in Cygwin for quite a few years, but I've been planning a switch to MSYS sometime. Cygwin seems to have made some bad decisions lately that make it harder and harder to work with. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Development environment for R extentions on Windows
On Wed, Sep 8, 2010 at 12:37 PM, Duncan Murdoch wrote: > On 08/09/2010 1:21 PM, Jeffrey Horner wrote: >> >> Hi all, >> >> I'm setting up a development environment on Windows as the subject >> implies. I've downloaded and installed Rtools211.exe (will upgrade >> later when necessary) and I've also downloaded and installed mingw >> with the help of mingw-get.exe. >> >> I come from a UNIX development background, so I'm at the bash shell >> prompt for just about every step in R extenstion development. Question >> is what is an appropriate environment for Windows development. What >> shell do you use? Do you use cmd.exe with the PATH variable set up by >> Rtools? Do you use the sh.exe that comes with Rtools? I've found the >> bash shell from MinGW to be a pretty close equivalent to bash on UNIX. >> Do you use something else? >> > > I've used the bash shell in Cygwin for quite a few years, but I've been > planning a switch to MSYS sometime. Cygwin seems to have made some bad > decisions lately that make it harder and harder to work with. This is great news! I don't know how I could survive without bash's vi style editing and command completion... Here's my PATH variable which sets the Rtools paths first, then MinGW: horn...@hornerj-win ~ $ echo $PATH /c/Rtools/bin:/c/Rtools/perl/bin:/c/Rtools/MinGW/bin:/c/localbin:/mingw/bin:/bin:/usr/bin:/usr/lo cal/bin:/c/Program Files (x86)/R/R-2.11.1/bin:/c/Program Files (x86)/CollabNet/Subversion Client: /c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1. 0/:/c/Program Files (x86)/MiKTeX 2.8/miktex/bin I'm going to follow the "R Installation ..." manual to compile R on Windows and learn a bit about the build process. From there, I intend to "port" some open source libraries that have support for being compiled with MS VC++ over to MinGW. Aside from my PATH variable, are there other things about my development environment I should be aware of? Jeff __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Development environment for R extentions on Windows
On 8 September 2010 at 13:01, Jeffrey Horner wrote: | This is great news! I don't know how I could survive without bash's vi | style editing and command completion... | | Here's my PATH variable which sets the Rtools paths first, then MinGW: | | horn...@hornerj-win ~ | $ echo $PATH | /c/Rtools/bin:/c/Rtools/perl/bin:/c/Rtools/MinGW/bin:/c/localbin:/mingw/bin:/bin:/usr/bin:/usr/lo | cal/bin:/c/Program Files (x86)/R/R-2.11.1/bin:/c/Program Files | (x86)/CollabNet/Subversion Client: | /c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1. | 0/:/c/Program Files (x86)/MiKTeX 2.8/miktex/bin | | I'm going to follow the "R Installation ..." manual to compile R on | Windows and learn a bit about the build process. From there, I intend | to "port" some open source libraries that have support for being | compiled with MS VC++ over to MinGW. | | Aside from my PATH variable, are there other things about my | development environment I should be aware of? FWIW I always add rxvt (taken from Cygwin's repos) so that I can launch an 'xterm' alike from the usual shortcut by having this as the command in Cygwin.bat: rxvt -sr -sl 2500 -sb -geometry 90x30 -fg wheat -bg gray10 -tn rxvt \ -fn 'Lucida Console-14' -e /usr/bin/bash --login -i The last time I set that up I left myself a note that I got hints from http://blasphemousbits.wordpress.com/2007/02/12/rxvt-solves-many-cygwin-woes/ and also see http://www.saltycrane.com/blog/tag/cygwin/ Those links may by now be stale. Hth, Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Drop single-dimensional array
Hi Simon, thank you for the concise reply. Do you mean the reported behavior of drop() is not a bug? It looks like a borderline bug to me (see below), but I'm not the judge of that. If this is the intended behavior and serves an actual purpose, then that could be explicitly documented in a \note{} on the help page. Such a note would slightly reduce the surprise of users running into this behavior. This is related to the oddity that one-dimensional arrays are: array(month.abb, dim=c(1,1,12)) # array array(month.abb, dim=c(1,12))# matrix array(month.abb, dim=12) # array Firstly, one would expect the pattern to be array-matrix-vector. Secondly, it's easy to drop() the three-dimensional and two-dimensional objects, but drop() does nothing to the one-dimensional array. Instead, it takes an unintuitive combination of methods to convert a single-dimensional to a vector, while retaining its names. Or I may well be missing something obvious. Best regards, Arni On Wed, 8 Sep 2010, Simon Urbanek wrote: wrong address - did you mean R-devel? Simon On Sep 6, 2010, at 8:35 AM, Arni Magnusson wrote: Bug or not, I was surprised by this behavior: x <- tapply(chickwts$weight, chickwts$feed, median) x # array ... I'd like to convert to vector with named elements drop(x) # what, still an array? drop(as.matrix(x)) # this works drop(t(x)) # this works I was expecting drop(x) to return a vector, and I suspect many R users would too. The title in help(drop), "Drop Redundant Extent Information", suggests that such a simple array would be converted to a vector. Reading through the help page, I note that this is perhaps not a clear bug, but somewhat unclear behavior. The most compact way to break the vector out of its eggshell seems to be t(x)[,] but drop(x) would be much easier to read and write. There's nothing particularly matrix about x, so it's not obvious that the conversion should involve as.matrix(x). Thanks, Arni __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] winbuilder warnings and errors
Possibly you are using x11() or postscript() to open a graphics device? You need to use something generic like dev.new() or nothing (a device will open automatically). I would check that first, though it does not really explain the second problem. Paul >-Original Message- >From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r- >project.org] On Behalf Of Melissa Jane Hubisz >Sent: September 8, 2010 10:11 AM >To: r-devel@r-project.org >Subject: [Rd] winbuilder warnings and errors > >Hello, >I have been developing a package for phylogenetic analysis which I >plan to submit to CRAN soon. It passes R CMD check with no warnings >on my linux and Mac OS X machines. I don't have much experience with >Windows and have been using the win-builder service to see how the >package compiles on Windows. (Thank you for this service, Uwe, it is >a huge time saver for me!) > >I have tried win-builder's R-release 32-bit and R-release 64-bit >versions, and both return with different warnings/errors which I don't >understand. However both do produce binaries which seem to work. For >the 64-bit, the check goes fine until it gets to the vignettes, and >then I get the message: > >* checking package vignettes in 'inst/doc' ... WARNING >*** Weave Errors *** >File d:/RCompile/CRANguest/R64- >release/rphast.Rcheck/inst/doc/vignette2.Rnw : >unable to start device PostScript >* checking PDF version of manual ... OK > > >I'm not sure if I should be concerned about this or not. I'm more >troubled by the results of the 32-bit check, which produces an error. >The log ends like this: > >* checking examples ... OK >* checking tests ... ERROR >Check process probably crashed or hung up for 20 minutes ... killed >Most likely this happened in the example checks (?), >if not, ignore the following last lines of example output: ><< here I snipped a bunch of example output that looks fine>> >> >> ### * >> ### >> cat("Time elapsed: ", proc.time() - get("ptime", pos = >'CheckExEnv'),"\n") >Time elapsed: 13.23 0.2 13.46 NA NA >> grDevices::dev.off() >null device > 1 >> ### >> ### Local variables: *** >> ### mode: outline-minor *** >> ### outline-regexp: "\\(> \\)?### [*]+" *** >> ### End: *** >> quit('no') > End of example output (where/before crash/hang up occured ?) > > >So here are my questions: >Does anyone have an idea what could cause the error above, or how I >can troubleshoot it? I do have remote access to a windows machine and >have installed the 32-bit binary, and all the testing code runs >smoothly. Do I need to resolve these issues in order to submit my >package to CRAN? I definitely want Windows binaries of my package to >be available. > >Thanks for any advice, >Melissa > > >Melissa Hubisz >Siepel Lab >Department of Biological Statistics and Computational Biology >Cornell University > >__ >R-devel@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-devel La version française suit le texte anglais. This email may contain privileged and/or confidential information, and the Bank of Canada does not waive any related rights. Any distribution, use, or copying of this email or the information it contains by other than the intended recipient is unauthorized. If you received this email in error please delete it immediately from your system and notify the sender promptly by email that you have done so. Le présent courriel peut contenir de l'information privilégiée ou confidentielle. La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute diffusion, utilisation ou copie de ce courriel ou des renseignements qu'il contient par une personne autre que le ou les destinataires désignés est interdite. Si vous recevez ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans délai à l'expéditeur un message électronique pour l'aviser que vous avez éliminé de votre ordinateur toute copie du courriel reçu. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] CMD check: checking data for non-ASCII characters is very time consuming
On 02/09/2010 6:27 AM, Vincent Carey wrote: Checking data for non-ASCII characters takes a very long time for packages with substantial data components. Could the check be done manually by the developer, and a switch introduced to optionally skip this during check? I'll add an environment variable to skip this check. For the full list of check configuration variables, see the Tools section of the R Internals manual. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] large files produced from image plots?
Hi [shifted this to r-devel] I can't reproduce this yet on my systems, but I have heard of at least one other example of a raster-related crash (on a 64-bit system I think). Baptiste: I would love to see that broken PDF if you still have it. Paul On 9/09/2010 8:00 a.m., baptiste auguie wrote: Hi, I get the same crash with x11() with sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base However it works fine with quartz(). Have you tried other devices? pdf() doesn't crash R for me, but the output is incorrect. png() is OK but defeats the purpose here. rasterImage is quite a recent addition, it would probably be appreciated to report any such odd behavior to R-devel. Interestingly (or not), the x11() test does not crash for me using grid.raster instead of rasterImage. Best, baptiste On 8 September 2010 21:47, Stephen T. wrote: Hi Baptiste, Thanks for your suggestion. I have to look into this further, but anything I try with rasterImage() gives me this type of error (below is from running the example in the help file). This is with R 2.11.1 on OS X 10.5 - *** caught bus error *** address 0x24, cause 'non-existent physical address' Traceback: 1: rasterImage(image, 100, 300, 150, 350, interpolate = FALSE) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace This is not an obvious error, is it? Thanks, Stephen Subject: Re: [R] large files produced from image plots? From: baptiste.aug...@googlemail.com Date: Wed, 8 Sep 2010 19:41:46 +0200 CC: r-h...@r-project.org To: obsessiv...@hotmail.com Hi, Have you tried the recent rasterImage() function? HTH, baptiste On Sep 8, 2010, at 7:30 PM, Stephen T. wrote: Hi list, I wonder if anyone has thoughts on making image plots in R [using image() or image.plot(), or filled.contour()]- I've made quite a bit now, but they seem quite large in size when exported to pdf file format (even after compressing with pdftk or ghostscript, which I regularly do). I know that for "images", raster graphics output (png, tiff) may be the way to go, but often the ones I make are multi-panel plots with other graphics on them, and are usually included in a LaTeX document (PDFLaTeX does accept png) and require stretching/shrinking (and/or possibly editing with Adobe Illustrator). I have had some luck exporting image plots from Matlab (to postscript or pdf) before in the sense that the files seem smaller and less pixelated. Is this a difference in the way image() plots are produced, or with the way the image is written to the pdf() device (if anyone is familiar with other image-exporting programs...)? The other day I had a 13MB dataset, and probably plotted 3/4 of it! using image() and the compressed pdf output was about 8 MB (it contained other stuff but was an addition of a few KB). I tried filled.contour(), as I understand that it colors polygons to fill contours instead of coloring rectangles at each pixel - and it has saved me before - but this time the contours may have been too sharp as as its compressed pdf came out to be 62 MB... (ouch!). I have not tested this data set with other software programs so it may just have been a difficult data set. Is there a good solution to this (or is it simply not to use a vector-graphics format in these instances), and just for my curiosity, are you aware of any things that other software (data analysis) programs do uder the hood to make their exported images smaller/smoother? Thanks much! Stephen [[alternative HTML version deleted]] __ r-h...@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-h...@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. -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Drop single-dimensional array
On 09/08/2010 08:54 PM, Arni Magnusson wrote: > Hi Simon, thank you for the concise reply. > > Do you mean the reported behavior of drop() is not a bug? > > It looks like a borderline bug to me (see below), but I'm not the judge of > that. If this is the intended behavior and serves an actual purpose, then > that could be explicitly documented in a \note{} on the help page. > > Such a note would slightly reduce the surprise of users running into this > behavior. > > This is related to the oddity that one-dimensional arrays are: > >array(month.abb, dim=c(1,1,12)) # array >array(month.abb, dim=c(1,12))# matrix >array(month.abb, dim=12) # array > > Firstly, one would expect the pattern to be array-matrix-vector. Secondly, > it's easy to drop() the three-dimensional and two-dimensional objects, but > drop() does nothing to the one-dimensional array. Instead, it takes an > unintuitive combination of methods to convert a single-dimensional to a > vector, while retaining its names. Or I may well be missing something > obvious. Well, you're missing c(x), but you may still have a point... 1d arrays was something of an afterthought, introduced for the ability to have named dimnames. Had this been thought of when S was designed, then maybe vectors and 1d arrays had been the same, but when it happened, it was not an option to modify the basic vector structures. drop() is documented to drop extents of length one, of which there are none in the 1d-array case, and so it is taken as a no-op. A slightly different design would be to drop in a strict array sense, i.e. dim=c(1,1,12) would drop to dim=12, not to a vector of length 12, and THEN if the result is 1d, convert to vector (this could even be made optional, with some reason). I don't think it's at the top of anyone's agenda, though. Meanwhile, c(x) should get you there soon enough. -pd > > Best regards, > > Arni > > > > On Wed, 8 Sep 2010, Simon Urbanek wrote: > >> wrong address - did you mean R-devel? >> Simon >> >> >> >> On Sep 6, 2010, at 8:35 AM, Arni Magnusson wrote: >> >>> Bug or not, I was surprised by this behavior: >>> >>> x <- tapply(chickwts$weight, chickwts$feed, median) >>> x # array ... I'd like to convert to vector with named elements >>> drop(x) # what, still an array? >>> drop(as.matrix(x)) # this works >>> drop(t(x)) # this works >>> >>> I was expecting drop(x) to return a vector, and I suspect many R users >>> would too. The title in help(drop), "Drop Redundant Extent >>> Information", suggests that such a simple array would be converted to a >>> vector. >>> >>> Reading through the help page, I note that this is perhaps not a clear >>> bug, but somewhat unclear behavior. >>> >>> The most compact way to break the vector out of its eggshell seems to >>> be >>> >>> t(x)[,] >>> >>> but drop(x) would be much easier to read and write. There's nothing >>> particularly matrix about x, so it's not obvious that the conversion >>> should involve as.matrix(x). >>> >>> Thanks, >>> >>> Arni >> > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Peter Dalgaard Center for Statistics, Copenhagen Business School Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Development environment for R extentions on Windows
On Wed, Sep 8, 2010 at 1:01 PM, Jeffrey Horner wrote: > On Wed, Sep 8, 2010 at 12:37 PM, Duncan Murdoch > wrote: >> On 08/09/2010 1:21 PM, Jeffrey Horner wrote: >>> >>> Hi all, >>> >>> I'm setting up a development environment on Windows as the subject >>> implies. I've downloaded and installed Rtools211.exe (will upgrade >>> later when necessary) and I've also downloaded and installed mingw >>> with the help of mingw-get.exe. >>> >>> I come from a UNIX development background, so I'm at the bash shell >>> prompt for just about every step in R extenstion development. Question >>> is what is an appropriate environment for Windows development. What >>> shell do you use? Do you use cmd.exe with the PATH variable set up by >>> Rtools? Do you use the sh.exe that comes with Rtools? I've found the >>> bash shell from MinGW to be a pretty close equivalent to bash on UNIX. >>> Do you use something else? >>> >> >> I've used the bash shell in Cygwin for quite a few years, but I've been >> planning a switch to MSYS sometime. Cygwin seems to have made some bad >> decisions lately that make it harder and harder to work with. > > This is great news! I don't know how I could survive without bash's vi > style editing and command completion... > > Here's my PATH variable which sets the Rtools paths first, then MinGW: > > horn...@hornerj-win ~ > $ echo $PATH > /c/Rtools/bin:/c/Rtools/perl/bin:/c/Rtools/MinGW/bin:/c/localbin:/mingw/bin:/bin:/usr/bin:/usr/lo > cal/bin:/c/Program Files (x86)/R/R-2.11.1/bin:/c/Program Files > (x86)/CollabNet/Subversion Client: > /c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1. > 0/:/c/Program Files (x86)/MiKTeX 2.8/miktex/bin > > I'm going to follow the "R Installation ..." manual to compile R on > Windows and learn a bit about the build process. From there, I intend > to "port" some open source libraries that have support for being > compiled with MS VC++ over to MinGW. >From the MinGW bash shell, the R build went quite smoothly. However, I did run into trouble with temporary files. I got around it by specifying TMPDIR like so: $ cd R_HOME/src/gnuwin32 $ TMPDIR=. /c/Rtools/bin/make all If I didn't set TMPDIR, it would default to /tmp and the failure would occur within the mkR target of R_HOME/share/make/basepkg.mk. For reasons beyond me, the shell environment that's entered within the mkR target has no notion of a root directory. Anyone else seen this? Jeff > > Aside from my PATH variable, are there other things about my > development environment I should be aware of? > > Jeff > -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] what is the best way for an external interface to interact with graphics, libraries
On Tue, Sep 7, 2010 at 11:34 AM, Simon Urbanek wrote: > > On Sep 7, 2010, at 2:21 PM, ghostwheel wrote: > > > > > Another message about the R to TeXmacs interface. > > > > 1. Graphics > > The TeXmacs interface allows the user to directly insert graphics into > the > > session. > > > > Since I am not very familiar with programming for R, I implemented the > > interaction with graphics in a very primitive way. It was two modes of > > working: with X11, and without (for example when working remotely through > > ssh without forwarding X11). > > > > In both cases the user has to invoke a command, v(), in order to insert > the > > current graph into the buffer at the current place. > > > > With X11, the way it works is that when v() is invoked I call > recordPlot(), > > then open a postscript file, then replayPlot(), and then close the > > postscript file and insert it into the session. > > > > Without X11, I open a postscript file ahead of time, then when v() is > > called, I close it, and insert it into the session, and then open a new > > postscript file. > > > > Obviously quite primitive.I think ideally would be if everything was > > transparent to the user - the user does a plot, and the plot is inserted > > into the buffer right away, and later, updates to the same plot update > the > > original plot where it is. But to be able to do that I need to be able to > > generate the postscript file of the current plot, and be notified somehow > > whenever the plot changes. > > > > Is all that possible? Is there a better way to implement this all? > > > > I don't know the mechanics of the actual "inserting" in TeXmac but it would > be trivial to simply create a copy of the plot as EPS (or whatever is > needed) at the time of insertion. See dev.copy2eps() for a function that > does exactly that. > > > > > 2. Libraries > > > > A remotely related question is this: the interface with TeXmacs generates > > menus that depend on the currently loaded libraries. > > Libraries are not "loaded" (see .libPath() for handling libraries) - but > chances are that you meant packages... > > > > I'd like to be able to > > update the menus whenever a new library is loaded. Is there a possibility > to > > have a function called whenever this happens? Or would it be advisable to > > change the global 'library' function? > > > > I would strongly advise against the latter. A reasonably simple way would > be to check the search path - if it changed a package has been loaded. A > natural place to do such check would be in a top-level task handler for > example. > > Another possibility would be the setHook() function. Michael Cheers, > Simon > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Development environment for R extentions on Windows
On 08/09/2010 5:37 PM, Jeffrey Horner wrote: On Wed, Sep 8, 2010 at 1:01 PM, Jeffrey Horner wrote: On Wed, Sep 8, 2010 at 12:37 PM, Duncan Murdoch wrote: On 08/09/2010 1:21 PM, Jeffrey Horner wrote: Hi all, I'm setting up a development environment on Windows as the subject implies. I've downloaded and installed Rtools211.exe (will upgrade later when necessary) and I've also downloaded and installed mingw with the help of mingw-get.exe. I come from a UNIX development background, so I'm at the bash shell prompt for just about every step in R extenstion development. Question is what is an appropriate environment for Windows development. What shell do you use? Do you use cmd.exe with the PATH variable set up by Rtools? Do you use the sh.exe that comes with Rtools? I've found the bash shell from MinGW to be a pretty close equivalent to bash on UNIX. Do you use something else? I've used the bash shell in Cygwin for quite a few years, but I've been planning a switch to MSYS sometime. Cygwin seems to have made some bad decisions lately that make it harder and harder to work with. This is great news! I don't know how I could survive without bash's vi style editing and command completion... Here's my PATH variable which sets the Rtools paths first, then MinGW: horn...@hornerj-win ~ $ echo $PATH /c/Rtools/bin:/c/Rtools/perl/bin:/c/Rtools/MinGW/bin:/c/localbin:/mingw/bin:/bin:/usr/bin:/usr/lo cal/bin:/c/Program Files (x86)/R/R-2.11.1/bin:/c/Program Files (x86)/CollabNet/Subversion Client: /c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1. 0/:/c/Program Files (x86)/MiKTeX 2.8/miktex/bin I'm going to follow the "R Installation ..." manual to compile R on Windows and learn a bit about the build process. From there, I intend to "port" some open source libraries that have support for being compiled with MS VC++ over to MinGW. From the MinGW bash shell, the R build went quite smoothly. However, I did run into trouble with temporary files. I got around it by specifying TMPDIR like so: $ cd R_HOME/src/gnuwin32 $ TMPDIR=. /c/Rtools/bin/make all I don't know if anything would go wrong, but I'd avoid putting your temp dir into the source tree. On my home machine I normally set R_USER to a Windows-style path (with backslashes), and that seems to work. On my work machine I think I set TMPDIR explicitly, but I forget what value I used. If I didn't set TMPDIR, it would default to /tmp and the failure would occur within the mkR target of R_HOME/share/make/basepkg.mk. For reasons beyond me, the shell environment that's entered within the mkR target has no notion of a root directory. Anyone else seen this? I'm not sure you're using the write make procedure. Are you running make from within src/gnuwin32, so you get the Makefile there? It shouldn't try to use /tmp (but things might have changed recently). Duncan Murdoch Jeff Aside from my PATH variable, are there other things about my development environment I should be aware of? Jeff __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wiki entries on "package development process" and "software repository"
I hereby invite anyone to make or suggest improvements to the Wikipedia entries on "package development process" and "software repository". Parts of these entries were created by Sundar Dorai-Raj and me: We believe that the procedures of the R community in these areas provide positive examples that could be profitably considered for people writing and sharing work in other languages. I'm scheduled to speak about this next Tuesday to the San Francisco Bay Area chapter of the Association for Computing Machinery (ACM; http://www.sfbayacm.org/?p=1962), but my interest in this extend beyond next Tuesday. I may later send a note to the "Communications of the ACM" referencing these entries and inviting further input. Your help with this would be greatly appreciated, because I don't know enough to talk authoritatively about "package development process" and "software repository" for languages other than R. If you know other people who might contribute perspectives for other languages, please feel free to forward this request to them. If you are a Wikipedian, feel free to change the entries directly. Otherwise, I'd be pleased to hear your comments, suggested improvements, etc., via email. Thanks, Spencer Graves __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel