Re: [R] How to use Latex code in R loop?

2012-04-01 Thread Henrik Bengtsson
On Sun, Apr 1, 2012 at 4:20 PM, Duncan Mackay mac...@northnet.com.au wrote: Hi There are a number of packages that produce latex from R, Sweave, brew, knitr - ones that come to mind. It happens that i use Sweave. The package you finally use may depend on your preferences The graphic output

Re: [R] unable to move temporary installation

2012-04-04 Thread Henrik Bengtsson
My $.01 contribution without having read the complete thread: Some other process/service is locking your file/directory. There are a few Windows tools out there helping your to narrow down exactly which, e.g. http://www.guidingtech.com/10175/tools-to-delete-locked-files-in-windows/ /Henrik

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-04 Thread Henrik Bengtsson
See ?closeAllConnections Suggestion to the maintainer of Sweave: atomify the figure generation, e.g. use { pdf(); on.exit(dev.off()); {...}; } or similar, instead of { pdf(); {...}; dev.off(); } possibly by leaving a copy of the fault figure file for troubleshooting. /Henrik On Wed, Apr 4, 2012

Re: [R] Sincere inquiry about “subscript out of bounds” error in R

2012-04-06 Thread Henrik Bengtsson
str() is your number one friend in R. Do str(A) and str(A2) after allocating the matrices and you'll be surprised. My $.02 /Henrik On Fri, Apr 6, 2012 at 7:35 AM, 卢永芳 sswwss...@126.com wrote: Hello,experts I am working on a simulation of effect of artificial selection on certain population

Re: [R] assigment operator question

2012-04-07 Thread Henrik Bengtsson
On Sat, Apr 7, 2012 at 1:30 PM, Mark Heckmann mark.heckm...@gmx.de wrote: Hello, using the - assignment operator I do not understand why the following does not work. l - list() l list() l$arg1 - test error in l$arg1 - test : Objekt 'l' not found ?- says:  The operators - and - cause a

Re: [R] assigment operator question

2012-04-07 Thread Henrik Bengtsson
, e.g. rm(list=ls(all.names=TRUE)). FYI, this updated topic may be better suited for the R-devel list. /Henrik TIA --Mark Am 07.04.2012 um 22:51 schrieb Henrik Bengtsson: On Sat, Apr 7, 2012 at 1:30 PM, Mark Heckmann mark.heckm...@gmx.de wrote: Hello, using the - assignment operator I

Re: [R] Time out for a R Function

2010-12-06 Thread Henrik Bengtsson
See also R help thread 'Wait for keystroke or timeout': http://www.mail-archive.com/r-help@r-project.org/msg97742.html /H On Mon, Dec 6, 2010 at 9:11 PM, Michael Bedward michael.bedw...@gmail.com wrote: Below is a toy function with one way of doing it. There are bound to be better ways :)

Re: [R] fast subsetting of lists in lists

2010-12-07 Thread Henrik Bengtsson
First, subset 'test' once, e.g. testT - test[1:3]; and then use sapply() on that, e.g. val - sapply(testT, FUN=function (x) { x$a }) Then you can avoid one level of function calls, by val - sapply(testT, FUN=[[, a) Second, there is some overhead in [[, $ etc. You can use .subset2() to avoid

Re: [R] Tiff compression bug

2010-12-09 Thread Henrik Bengtsson
Hi On Wed, Dec 8, 2010 at 11:18 PM, Ganqiang Liu g@imb.uq.edu.au wrote: Is there a bug in tiff compression output in Mac version? My program is correct when I run on windows version; However, in Mac, the compression fail~ Friendly and constructive sarcasm follows: Talking cars, your

Re: [R] Time out for a R Function

2010-12-13 Thread Henrik Bengtsson
FYI, I've added evalWithTimeout() to R.utils v1.6.0 (now on CRAN). It utilizes the built-in setTimeLimit() feature of R. You can either have it throw an error, which you then have to catch, or you can have it just give a warning that your evaluation timed out and then silently continue. From

Re: [R] R.matlab memory use

2010-12-21 Thread Henrik Bengtsson
Hi, I am using Octave; what does that save options do, more specifically, is compression taking place when saving that file? If compression is done, then the Rcompression package is utilized by R.matlab (otherwise not). BTW, you don't have to load Rcompression explicitly; R.matlab will do it

Re: [R] R.matlab memory use

2010-12-21 Thread Henrik Bengtsson
On Tue, Dec 21, 2010 at 10:15 AM, Henrik Bengtsson h...@biostat.ucsf.edu wrote: Hi, I am using Octave; what does that save options do, more specifically, is compression taking place when saving that file? That should be: I am [not] using Octave... /H If compression is done

Re: [R] Setting bioconductor repository in .Rprofile. Is there a permanent way?

2011-01-24 Thread Henrik Bengtsson
It is easier than that. Use http://www.bioconductor.org/packages/release/bioc or http://www.bioconductor.org/packages/devel/bioc /Henrik On Mon, Jan 24, 2011 at 10:56 AM, Martin Morgan mtmor...@fhcrc.org wrote: On 01/24/2011 10:45 AM, Kevin Wright wrote: I currently set the Bioconductor

Re: [R] building a subscript programatically

2011-11-01 Thread Henrik Bengtsson
2011/11/1 Ernest Adrogué nfdi...@gmail.com: Hi, On ocasion, you need to subscript an array that has an arbitrary (ie. not known in advance) number of dimensions. How do you deal with these situations? It appears that it is not possible use a list as an index, for instance this fails: x -

Re: [R] download.file

2011-11-08 Thread Henrik Bengtsson
See downloadFile() of the R.utils package (on CRAN); it allows you to download to a file to a given path (without have to replicate the filename), and it also have an option (the default) to drop zero-size files that are (sometimes) created when download.file() tries to download a non-existing

Re: [R] R v2.13.2 - Cannot find Rcmd on path?

2011-11-14 Thread Henrik Bengtsson
FYI, you can use tools such as Path Manager 1.1.1 (GPL) on Windows: http://www.softpedia.com/get/System/System-Miscellaneous/Path-Manager.shtml to list, modify (add, remove, reorder, remove duplicates, normalize) your PATH environment variable. For each directory it identifies in PATH it will

Re: [R] unable to get R CMD to work as expected on a 64 bit windows machine

2011-11-14 Thread Henrik Bengtsson
See if Rcmd check --help works. I've always been use that form (I'm on Win7 64-bit). /Henrik On Mon, Nov 14, 2011 at 9:06 AM, Martyn Byng martyn.b...@nag.co.uk wrote: Hi Josh, Thanks for that, which directory needs to be in the path? There is a file called R.exe in C:\Program

Re: [R] Putting directory path as a parameter

2011-11-15 Thread Henrik Bengtsson
file.path() is much better for this than paste(), e.g. dir - C:/Users/Desktop pathname - file.path(dir, bs_dev_segment_file.csv) temp_data - read.csv(pathname) /Henrik On Tue, Nov 15, 2011 at 10:08 AM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: Try pasting

Re: [R] Event handling in R

2011-12-16 Thread Henrik Bengtsson
...because you're catching the timeout error with try() so it has not effect, and hence the while(TRUE) {} loop keeps running. Without knowing anything about graphics event handlers per se, here's an alternative to catch the timeout event: library(R.utils); plot(0, 0); eventEnv -

Re: [R] Event handling in R

2011-12-21 Thread Henrik Bengtsson
Hi. On Wed, Dec 21, 2011 at 4:20 AM, beetonn nicholas.bee...@utas.edu.au wrote: Thanks, Henrik! That's given me some food for thought, and evalWithTimeout certainly seems to be a nicer way of doing this than setTimeLimit. I should probably explain a little more clearly: I want to stop

Re: [R] Indexing multi-dimensional table

2011-12-22 Thread Henrik Bengtsson
On Thu, Dec 22, 2011 at 4:34 AM, David A Vavra dava...@verizon.net wrote: I want to take slices of a multi-dimensional table (or array) without knowing the number of dimensions in advance. As a test I tried using (in this example a 3d table):     do.call(`[`, list(tbl, x,NULL,NULL)]

Re: [R] is there an equivalent for #ifdef (C langage) in R

2012-01-12 Thread Henrik Bengtsson
You could generate an R script using an RSP template 'main.R.rsp' containing: % DEBUG - TRUE % % if (!DEBUG) { %   make_addition = function(a, b) { % } % % if (DEBUG) { %   a = 1   b = 2 % } %   c=a+b   plot(c) % if (!DEBUG) { %        return(c)    } % } % which you can compile into 'main.R'

Re: [R] Virus Infection in colorspace_1.1-1.zip (R x64 2.14.1)

2012-01-24 Thread Henrik Bengtsson
[R] False Virus detection with colorspace package? [Tue Nov 8 00:44:37 CET 2011] https://stat.ethz.ch/pipermail/r-help/2011-November/294875.html /H On Tue, Jan 24, 2012 at 11:46 AM, Stephen P Molnar s.mol...@sbcglobal.net wrote: I keep finding the Win32\Huer virus in colorspace_1.1-1.zip for R

Re: [R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Henrik Bengtsson
The quick solution: parseAndEval - function(x, ...) eval(parse(text=x)) apply(BM, MARGIN=c(1,2), FUN=parseAndEval) My $.02 /Henrik On Mon, Jan 30, 2012 at 10:26 AM, Paul Johnson pauljoh...@gmail.com wrote: A user question today has me stumped.  Can you advise me, please? User wants a matrix

Re: [R] how to unzip files in R

2012-01-31 Thread Henrik Bengtsson
I may be wrong, but I don't think unz() handles bz2 files - only zip files. See bunzip2() of the R.utils package (which utilizes bzfile connections). /Henrik On Tue, Jan 31, 2012 at 2:34 PM, ql16717 ql16...@gmail.com wrote: Hi, I have downloaded a bunch of bz2 files. I wonder if R will be

Re: [R] passing an extra argument to an S3 generic

2012-02-10 Thread Henrik Bengtsson
For these type of setups, I typically turn to default values, e.g. hatvalues.mlm - function(model, m=1, infl=NULL, ...) { if (is.null(infl)) { infl - mlm.influence(model, m=m, do.coef=FALSE); } hat - infl$H m - infl$m names(hat) - if(m==1) infl$subsets else

Re: [R] If (x 0)

2012-02-13 Thread Henrik Bengtsson
Try adding --vanilla when calling R, e.g. R --vanilla --no-save --args 5 test1.R because I think you're picking up and previously stored session. You'll most likely will find that res - conditional1(x) will give an error saying 'conditional1' is not defined; you need to define the function

Re: [R] Powerful PC to run R

2011-05-15 Thread Henrik Bengtsson
On Sun, May 15, 2011 at 9:31 AM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Also:  A previous post in this tread suggested Rprof [sec. 3.2 in Writing R Extensions, available via help.start()]. This should identify the functions that consume the most time.  The standard

Re: [R] R Style Guide -- Was Post-hoc tests in MASS using glm.nb

2011-05-18 Thread Henrik Bengtsson
-styleguide.googlecode.com/svn/trunk/google-r-style.html] [4] R style guide by Hadley Wickham (based on [3]) http://had.co.nz/stat405/resources/r-style-guide.html [5] R Coding Conventions (RCC) - a draft by Henrik Bengtsson http://aroma-project.org/developers/RCC [6] The Aroma R Coding

Re: [R] Problem with Princurve

2011-05-23 Thread Henrik Bengtsson
You may have to tune the curve fitting parameters. Have a look at arguments 'smoother' and '...' in help(principal.curve), i.e. by default principal.curve() uses smoother function smooth.spline() in each iteration and principal.curve() passes down any additional arguments to it that you give (via

Re: [R] Rtools - The setup files are corrupted message when trying to install

2011-06-09 Thread Henrik Bengtsson
FYI, Rtools212.exe: File size: 44,224,666 bytes MD5:15ce69dcfc989c43825bedeaa8389aa6 Rtools213.exe: File size: 38,122,354 bytes MD5: 09052655da7c6e8a81f2d398ed6004b5 /Henrik On Thu, Jun 9, 2011 at 6:12 AM, Martyn Byng martyn.b...@nag.co.uk wrote: Hi, Apologies if this is the wrong list to

Re: [R] merge large number of raster objects

2011-06-09 Thread Henrik Bengtsson
See ?get and ?do.call. That should be enough. ?Reduce may be an alternative for do.call(), but could also be less memory efficient. My $.02 /Henrik On Thu, Jun 9, 2011 at 7:57 PM, Ben Zaitchik zaitc...@jhu.edu wrote: Hello, I have a large number of raster objects in memory, with names

Re: [R] merge large number of raster objects

2011-06-10 Thread Henrik Bengtsson
...and ?mget for retrieving multiple objects as a list. /Henrik On Thu, Jun 9, 2011 at 10:32 PM, Henrik Bengtsson h...@biostat.ucsf.edu wrote: See ?get and ?do.call.  That should be enough. ?Reduce may be an alternative for do.call(), but could also be less memory efficient. My $.02

Re: [R] Question about R.oo package

2011-06-27 Thread Henrik Bengtsson
Hi W. Kaisers, sorry for the delay - I just spotted you question: On Thu, Jun 16, 2011 at 5:52 AM, kais...@med.uni-duesseldorf.de wrote: Dear R.oo package users, while testing some functionality of the R.oo, I found that during the first construction of a object from a class, the

Re: [R] Querying the path separator?

2011-06-28 Thread Henrik Bengtsson
See file.path(). /Henrik On Tue, Jun 28, 2011 at 6:59 PM, Jonathan Greenberg greenb...@ucdavis.edu wrote: Hopefully this is a pretty easy fix -- I need to have R query the path separator for some code I'm trying to write (it involves using a system() call) -- the call requires a path and a

Re: [R] read tab delimited file from a certain line

2013-01-18 Thread Henrik Bengtsson
Christof, I've added support for this to the R.filesets package. In your case, then all you need to do is: library(R.filesets) dlf - readDataFrame(filename, skip=^year) No need to specify any other arguments - they're all automagically inferred - and the default is stringsAsFactors=FALSE.

Re: [R] Hard Stop?

2013-02-06 Thread Henrik Bengtsson
See abort() in the R.oo package, with some discussion here https://stat.ethz.ch/pipermail/r-devel/2012-September/064838.html /Henrik On Wed, Feb 6, 2013 at 7:05 PM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: stop() does not have momentum... it is designed to play nice. Perhaps you want

Re: [R] Windows 7 installation issues

2012-05-29 Thread Henrik Bengtsson
You probably meant testInstalledPackage(base) without the 's', cf. help(testInstalledPackage, package=tools). /Henri On Tue, May 29, 2012 at 4:18 PM, jalantho...@verizon.net jalantho...@verizon.net wrote: I installed R version 2.15.0 under C:/ on a PC running Windows 7.  When I load

Re: [R] Inconsistency using seq

2012-06-18 Thread Henrik Bengtsson
FYI, isZero - function(x, neps=1, eps=.Machine$double.eps, ...) { + (abs(x) neps * eps) + } x - seq(from=0, to=4, by=0.1) isZero(x[4]-0.3) [1] TRUE isZero(x[4]-0.3, neps=1) [1] TRUE isZero(x[4]-0.3, neps=0.1) [1] FALSE You could also have called isZero() isValueSmallEnoughForWhatINeed().

Re: [R] Going backwards through plot panels

2012-06-20 Thread Henrik Bengtsson
FYI, from help(layout, package=graphics): [...] Warnings These functions are totally incompatible with the other mechanisms for arranging plots on a device: par(mfrow), par(mfcol) and split.screen. /Henrik On Wed, Jun 20, 2012 at 3:17 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote:

Re: [R] Having two different versions of a package in the same R installation

2012-10-02 Thread Henrik Bengtsson
Install the two versions in two different *libraries* and update .libPaths() to prioritize one over the other. /Henrik On Tue, Oct 2, 2012 at 1:18 PM, Søren Højsgaard sor...@math.aau.dk wrote: Dear list, I am making some comparisons of two versions of the lme4 package: The CRAN version and

Re: [R] Download a file from url

2012-10-15 Thread Henrik Bengtsson
You didn't say what errors you've got but you probably wants to specify argument mode=wb in your download.file() call, cf. https://stat.ethz.ch/pipermail/r-devel/2012-August/064739.html /Henrik On Mon, Oct 15, 2012 at 1:57 AM, veepsirtt veepsi...@gmail.com wrote: Hi Download the xls file

Re: [R] Download a file from url

2012-10-16 Thread Henrik Bengtsson
'readWorksheet': Error: object 'wb' not found On Mon, Oct 15, 2012 at 11:58 PM, Henrik Bengtsson-3 [via R] ml-node+s789695n4646268...@n4.nabble.com wrote: You didn't say what errors you've got but you probably wants to specify argument mode=wb in your download.file() call, cf. https://stat.ethz.ch

[R] rJava not loading on Windows

2012-11-07 Thread Henrik Bengtsson
Hi, I've successfully used it on a Linux setup, but when I try to load rJava on Windows 7 64-bit (session info below) I get: % R --vanilla library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: dirname(this$RuntimeLib) error: a character vector argument

Re: [R] Setting default graphics device options

2013-05-26 Thread Henrik Bengtsson
Hi, see the R.devices package [http://cran.r-project.org/web/packages/R.devices/]. FYI, there is a vignette [R.devices-overview.pdf], but for some reason it's hard find. However it is there: help.start() - R.devices - 'User guides, package vignettes and other documentation.' -

Re: [R] Setting default graphics device options

2013-05-26 Thread Henrik Bengtsson
Sorry, forgot to add: Hi, [a somewhat different approach but] see the R.devices package /Henrik On Sun, May 26, 2013 at 10:14 AM, Henrik Bengtsson h...@biostat.ucsf.edu wrote: Hi, see the R.devices package [http://cran.r-project.org/web/packages/R.devices/]. FYI, there is a vignette

Re: [R] Bytes to Numeric/Float conversion

2013-06-11 Thread Henrik Bengtsson
On Tue, Jun 11, 2013 at 2:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 11, 2013, at 9:01 AM, Bikash Agrawal wrote: Is there any packages available in R, that can convert Bytes array to Float. Using rJava we can do it. But it is kind of slow. Is there any R specific packages.

Re: [R] stopping functions with long execution times

2013-07-18 Thread Henrik Bengtsson
See evalWithTimeout() of R.utils, e.g. tryCatch({ evalWithTimeout({ slowFunction(); }, timeout=7*24*3600); }, TimeoutException=function(ex) { cat(Timeout. Skipping.\n); }) help(evalWithTimeout) have more information and cross links. /Henrik On Thu, Jul 18, 2013 at 11:37 AM, ONKELINX,

Re: [R] Chinese characters in html source captured by download.file() are garbled code , how to convert it readable

2013-07-29 Thread Henrik Bengtsson
Try with adding mode=wb to download.file(), or just use downloadFile() of R.utils. /Henrik On Sun, Jul 28, 2013 at 8:32 PM, Yong Wang wangyo...@gmail.com wrote: Dear list, I am working with R to download numerous html source code from which the data extracted will be further processed. The

Re: [R] package environment versus namespace environment

2014-03-08 Thread Henrik Bengtsson
See Suraj Gupta's online article 'How R Searches and Finds Stuff' from March 29, 2012: http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/ It's a very useful write up on this topic. /Henrik On Sat, Mar 8, 2014 at 3:42 PM, Benjamin Tyner bty...@gmail.com wrote: Duncan, Thank

Re: [R] pre-allocation not always a timesaver

2014-04-02 Thread Henrik Bengtsson
I don't think you got a response to this one; x - array(dim=(c(j, n))) for (i in 1:n) { x[,i] - rnorm(j) } Note that array() allocates a logical array by default, which means that in your first iteration (i==1) it has to be coerced to a double array before assigning the value

Re: [R] How to implement a recurring check for updates for R and packages?

2014-04-09 Thread Henrik Bengtsson
[Sounds like a question for R-devel] On Wed, Apr 9, 2014 at 5:02 AM, Tal Galili tal.gal...@gmail.com wrote: Hello all, I wish to add to the installrhttp://cran.r-project.org/web/packages/installr/package the ability to check for new versions of R once every X units of time (maybe once

Re: [R] stop a function

2014-05-15 Thread Henrik Bengtsson
Two quick comments: 1. You do not need to reset the timeout limits yourself; it's already taken care of, cf. help(evalWithTimeout). 2. Have you tried example(evalWithTimeout)? It should illustrate how it works/is used. It's also a good example to verify that it also works on your machine (I'd

Re: [R] R-memory: clearing memory within a function?

2014-06-03 Thread Henrik Bengtsson
See blog post 'Speed trick: Assigning large object NULL is much faster than using rm()!': http://www.jottr.org/2013/05/speed-trick-assigning-large-object-null.html /Henrik On Tue, Jun 3, 2014 at 5:35 PM, Ista Zahn istaz...@gmail.com wrote: Hi Frank, I don't think it is possible to state a

Re: [R] as.character.call?

2014-06-03 Thread Henrik Bengtsson
cl - quote(round(10.5)) deparse(cl) [1] round(10.5) /Henrik On Tue, Jun 3, 2014 at 8:07 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: How can I get a call object as a character string? Example: cl - quote(round(10.5)) str(cl) language round(10.5)

Re: [R] .Rprofile: contains invalid line(s)

2014-06-05 Thread Henrik Bengtsson
Make sure that the last line has a newline at the end, otherwise that expression will be silently ignored, cf. R-devel thread '[Rd] Last line in .Rprofile must have newline (PR#4056)' on 2003-09-03 [https://stat.ethz.ch/pipermail/r-devel/2003-September/027455.html]. I'm pretty sure many many

Re: [R] return the name of source.

2013-08-27 Thread Henrik Bengtsson
See findSourceTraceback() of R.utils. /Henrik On Mon, Aug 26, 2013 at 10:58 PM, peter dalgaard pda...@gmail.com wrote: On Aug 27, 2013, at 07:12 , nevil amos wrote: Is there a fuction that will allow me to retrun the filename for a script from within that script. Not a standard one, but

Re: [R] Installing package from website

2013-08-27 Thread Henrik Bengtsson
On Sun, Aug 25, 2013 at 10:55 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, I need to install Rmpi package from this http://www.stats.uwo.ca/faculty/yu/Rmpi/download/windows/MPICH2 I was wondering if there is any direct way to install this in R. The trivial method

Re: [R] Help: concurrent R sessions for different settings of simulations

2013-09-29 Thread Henrik Bengtsson
I strongly suggest to use the BatchJobs package [http://cran.r-project.org/web/packages/BatchJobs] for this. It is easy to install and cross platform and does not rely on external software such as perl. It allows you develop your script running sequentially/interactively on your local

Re: [R] When to use RProfile.site or .Rprofile

2013-10-03 Thread Henrik Bengtsson
Unless you're trying to provide your startup settings to multiple users (typically only sysadms do this), stick with .Rprofile (in your home directory). There is no need to have one per working directory, unless they differ, cf. ?Startup [...a file called ‘.Rprofile’ is searched for in the

Re: [R] system2 commands with backslash

2013-10-11 Thread Henrik Bengtsson
system2(sed, args=c(-i, s/oldword\\s/newword/g, d:/junk/x/test.tex)) /Henrik On Fri, Oct 11, 2013 at 8:58 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 10, 2013, at 8:16 AM, Zev Ross wrote: Hi All, I'm trying to edit a file in place using system2 and sed from within R. I can

Re: [R] R - How to physically Increase Speed

2013-10-21 Thread Henrik Bengtsson
On Mon, Oct 21, 2013 at 4:12 PM, Alexandre Khelifa akhel...@logitech.com wrote: Hi, My name is Alexandre Khelifa and I have been using R at my work for about 2 years. I have been working on a project when we do Monte Carlo Simulation and it involves a lot of calculations. I am currently

Re: [R] Depends and Imports in DESCRIPTION file

2013-10-22 Thread Henrik Bengtsson
On Tue, Oct 22, 2013 at 8:03 PM, Marc Girondot marc_...@yahoo.fr wrote: Dear list members: I try to check my updated package to include a new version in CRAN (phenology) but a new error is indicated and I don't find the logic. First my system: * using R version 3.0.2 Patched (2013-09-27

Re: [R] XML package not working

2013-10-24 Thread Henrik Bengtsson
Have you tried to download from another CRAN mirror, e.g. http://cran.r-project.org/web/packages/XML/ More mirrors at http://cran.r-project.org/mirrors.html As already others said, it's very unlikely that this is not an issue on your end. /Henrik On Thu, Oct 24, 2013 at 4:54 AM, Steven

Re: [R] Reading .gsheet within R

2012-11-30 Thread Henrik Bengtsson
On Fri, Nov 30, 2012 at 9:43 AM, Luca Meyer lucam1...@gmail.com wrote: Hello R-experts, I would like to know if there is a solution to read files with extension .gsheet directly into R - see http://www.fileinfo.com/extension/gsheet for more info on this file format. AFAIK, those files

Re: [R] Calling a .bat to set environment variables and subsequent .exe execution from within R

2012-12-23 Thread Henrik Bengtsson
If all you need to do is to set environment variables, you can do that from within R, e.g. shell(echo %FOO%) %FOO% Sys.setenv(FOO=42); shell(echo %FOO%) 42 My $.02 On Sun, Dec 23, 2012 at 11:14 AM, Ludwig Hilger l.hil...@ku.de wrote: Dear list, I have found a thread dealing with similar

Re: [R] how to check if an attribute exists

2011-02-02 Thread Henrik Bengtsson
On Wed, Feb 2, 2011 at 7:25 PM, Peter Langfelder peter.langfel...@gmail.com wrote: On Wed, Feb 2, 2011 at 7:22 PM, Nick Matzke mat...@berkeley.edu wrote: Oh wait, this basically does it: if (a %in% attributes(z)$names) + print(TRUE) [1] TRUE (but there may be a better way) If z is a

Re: [R] Write File to Shared Drive

2011-02-15 Thread Henrik Bengtsson
FYI, you can use the following to troubleshoot what is going on: library(R.utils); filename - MyFile.csv; path - ... # The directory where to store pathname - Arguments$getWritablePathname(filename, path=path); or if you already have the full pathname: pathname -

Re: [R] Weird error (special character) of read.table

2011-02-22 Thread Henrik Bengtsson
On Tue, Feb 22, 2011 at 7:43 AM, John Edwards jhnedwards...@gmail.com wrote: Hi, I have the following input file. $ cat main.txt CEL_A CELL_B 1 4 2 5 2 6 Then I run read.table in R. f=read.table('main.txt', header=T, check.names=F, sep='\t') head(f)  \ufeffCEL_A CELL_B 1    1      4

Re: [R] Removing elements ..., NO bug in which() function

2011-02-23 Thread Henrik Bengtsson
On Wed, Feb 23, 2011 at 1:02 PM, Martin Maechler maech...@stat.math.ethz.ch wrote: RK == Rumen Kostadinov rkost...@gmail.com     on Sun, 13 Feb 2011 12:46:52 -0500 writes:    RK Thanks Sarah,    RK Yes, the function behaves Exactly as documented:    RK check this out:     a = c(1,2,3,4,5)

Re: [R] Any existing functions for reading and extracting data from path names?

2011-03-11 Thread Henrik Bengtsson
Hi, the R.filesets package was designed for this. It is heavily used by the aroma framework (http://www.aroma-project.org/), so it got a fair bit of mileage now (in a good a way). Here is how you could setup your data set and work with the data. # - - - - - - - - - - - - # Setup file data set

Re: [R] Persistent storage between package invocations

2011-03-15 Thread Henrik Bengtsson
It would be nice to have a standard directory where R can write things this way. A semi-standard directory is given by Sys.getenv(R_LIBS_USER), which defaults to ~/R/.../. Maybe ~/R/ could serve as that convention? That way we (various developers etc) would also not clutter up users home

[R] This day in history: R-help, R-devel and R-announce (1997-04-01)

2013-04-01 Thread Henrik Bengtsson
Today it's 16 years ago and 367,496 messages later since MartinMächler started the R-help (321,119 msgs), R-devel (45,830 msgs) and R-announce (547 msgs) mailing lists [1] - a great benefit to all of us. Special thanks to Martin and also thanks to everyone else contributing to these forums. [1]

Re: [R] Question: how to convert raw to numeric

2013-04-03 Thread Henrik Bengtsson
See ?readBin - works also with raw objects. Henrik On Apr 3, 2013 1:18 AM, Mike Chen chenminyi1...@gmail.com wrote: I know that there is a function to convert binary data to string named rawToChar.but I wander is there any similar function for Integer and float.I need to read some binary file

Re: [R] rep() fails at times=0.29*100

2013-04-09 Thread Henrik Bengtsson
FYI, (0.29*100) 29 [1] TRUE See R FAQ 7.31 for why. /Henrik On Tue, Apr 9, 2013 at 9:11 AM, Jorge Fernando Saraiva de Menezes jorgefernandosara...@gmail.com wrote: Dear list, I have found an unusual behavior and would like to check if it is a possible bug, and if updating R would fix it.

Re: [R] how to transform string to Camel Case?

2013-04-15 Thread Henrik Bengtsson
See for instance capitalize() in the R.utils package. Henrik On Apr 14, 2013 11:51 PM, Liviu Andronic landronim...@gmail.com wrote: Dear all, Given the following vector: (z - c('R project', 'hello world', 'something Else')) [1] R project hello worldsomething Else I know how to

Re: [R] texi2pdf texinputs arguments

2013-04-18 Thread Henrik Bengtsson
I'm pretty sure the intended design is to always use the current working directory as the output directory, cf. 'Value' section in help(texi2dvi, package=tools): Used for the side effect of creating a dvi or PDF file in the current working directory (and maybe other files, especially if clean =

Re: [R] R CMD build

2013-04-20 Thread Henrik Bengtsson
On Sat, Apr 20, 2013 at 3:10 PM, Knut Krueger r...@knut-krueger.de wrote: Am 20.04.2013 15:50, schrieb Gabor Grothendieck: Note that there is a separate directory for the 64-bit R executables. Does it make any difference to check and pack the source files iwth 32 or 64 bit? Also,

Re: [R] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread Henrik Bengtsson
FYI, whenever getting an error, run traceback() *immediately after* (i.e. before any other commands) and include that in your error report. Also include the output of sessionInfo(). It helps tremendously and spares lots of second guessing. /Henrik On Wed, Apr 11, 2012 at 8:28 AM, krtek

Re: [R] Organizations where IT has approved the use of R software

2012-04-12 Thread Henrik Bengtsson
May be of use too: The R Foundation for Statistical Computing, R: Regulatory Compliance and Validation Issues - A Guidance Document for the Use of R in Regulated Clinical Trial Environments, August 17, 2008 [http://www.r-project.org/certification.html] /Henrik On Thu, Apr 12, 2012 at 1:06 PM,

Re: [R] Can a matrix have 'list' as rows/columns?

2012-04-16 Thread Henrik Bengtsson
On Mon, Apr 16, 2012 at 9:13 PM, Worik R wor...@gmail.com wrote: After a lot of processing I get a matrix into M.  I expected each row and column to be a vector.  But it is a list. Lists are also vectors, e.g. x - list() is.vector(x) [1] TRUE y - vector(list, length=3) str(y) List of 3 $

Re: [R] Error with Rcmd check library --as-cran

2012-04-17 Thread Henrik Bengtsson
paleotree imports phangorn which depends on Matrix, so your example does indeed depend on Matrix. A possible reason is that your installed Matrix was built for a different version of R, i.e. check packageDescription(Matrix). /Henrik On Tue, Apr 17, 2012 at 4:23 PM, David Bapst

Re: [R] load only one object from a .RData file

2012-04-24 Thread Henrik Bengtsson
You could do: library(R.utils); value - loadToEnv(MyFile.RData)[[nameOfObject]]; It still load all of the data, but it is not kept; only the object you grab. /Henrik On Tue, Apr 24, 2012 at 11:30 AM, Shi, Tao shida...@yahoo.com wrote: Hi list, Is there a way to load one specific object

Re: [R] ErrError in f(x, ...) : object 'g.' not found

2012-04-26 Thread Henrik Bengtsson
If it helps... R is not Matlab. There is no '.*' operator in R. /H On Thu, Apr 26, 2012 at 2:37 PM, Sarah Goslee sarah.gos...@gmail.com wrote: On Thu, Apr 26, 2012 at 5:34 PM, Guaramy _ guar...@hotmail.com wrote: Thanks for your answer, but how can i correct that, the mathematical expression

Re: [R] Memoize and vectorize a custom function

2012-04-27 Thread Henrik Bengtsson
On Thu, Apr 26, 2012 at 3:21 PM, Kamil Slowikowski kslowikow...@gmail.com wrote: My goal is simple: calcuate GC content of each sequence in a list of nucleotide sequences. I have figured out how to vectorize, but all my attempts at memoization failed. Can you show me how to properly memoize

Re: [R] Quickest way to make a large empty file on disk?

2012-05-02 Thread Henrik Bengtsson
An R solution is: allocateFile - function(pathname, nbrOfBytes) { con - file(pathname, open=wb); on.exit(close(con)); seek(con, where=nbrOfBytes-1L, origin=start, rw=write); writeBin(as.raw(0), con=con); invisible(pathname); } # allocateFile() allocateFile(foo.bin, nbrOfBytes=985403)

Re: [R] download extremely slow

2012-05-05 Thread Henrik Bengtsson
On Sat, May 5, 2012 at 2:10 PM, Hillary Sardiñas herongr...@gmail.com wrote: I have been trying to download the latest version to my Macbook X version 10.6.8 from my institutions mirror http://cran.cnr.Berkeley.edu Usually is only takes minutes, but regardless of the browser or where I connect

Re: [R] how to download source code, pdf manual for any package from internet?

2012-05-19 Thread Henrik Bengtsson
You need to specify that you want a binary download - make sure to read help(download.file), particular that of argument 'mode'. Alternatively, use downloadFile() in the R.utils package which download as binary by default. /Henrik On Sat, May 19, 2012 at 7:22 AM, sagarnikam123

Re: [R] Median computation

2012-05-22 Thread Henrik Bengtsson
See rowMedians() of the matrixStats package for replacing apply(x, MARGIN=1, FUN=median). /Henrik On Tue, May 22, 2012 at 12:34 PM, Preeti pre...@sci.utah.edu wrote: Hi, I have a 250,000 by 300 matrix. I am trying to calculate the median of those columns (by row) with column names that are

Re: [R] Median computation

2012-05-23 Thread Henrik Bengtsson
(colnames(df)), function(x) rowMedians(as.matrix(df[,colnames(df) == x]),na.rm=TRUE)) Thanks again! On Tue, May 22, 2012 at 3:23 PM, Henrik Bengtsson h...@biostat.ucsf.edu wrote: See rowMedians() of the matrixStats package for replacing apply(x, MARGIN=1, FUN=median). /Henrik On Tue, May

Re: [R] importing many csv files into separate matrices

2013-12-04 Thread Henrik Bengtsson
On Wed, Dec 4, 2013 at 6:53 PM, Greg Snow 538...@gmail.com wrote: As you have noticed, using assign is not simple, and your approach has potential to cause even more problems even if you get it working. Here is another approach: loadCSVfiles - function(path) { x - list.files(path,

Re: [R] Error: C stack usage is too close to the limit when using list.files()

2013-12-04 Thread Henrik Bengtsson
FYI, in R.utils (= 1.28.4) you can use listDirectory() to control how deep the recursion goes, which would give you protection against your problem, e.g. R.utils::listDirectory(dir, recursive=5L) where recursive=0L is equivalent to recursive=FALSE. Using recursive=TRUE corresponds to

Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-15 Thread Henrik Bengtsson
See ?png and argument 'pointsize'. You can increase that as you increase the dimensions of the output image. /Henrik On Sun, Dec 15, 2013 at 3:00 PM, david hamer j.david.ha...@gmail.com wrote: Hello, My x-y scatterplot produces a very ragged best-fit line when imported into Word. * plot

Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-15 Thread Henrik Bengtsson
And possibly better, argument 'res', e.g. png(R.graph.png, width=1200, height = 700, res=144) plot(...) dev.off() Default corresponds to res=72. /Henrik On Sun, Dec 15, 2013 at 3:13 PM, Henrik Bengtsson h...@biostat.ucsf.edu wrote: See ?png and argument 'pointsize'. You can increase

Re: [R] seq_len and loops

2013-12-21 Thread Henrik Bengtsson
What about seq_len2 - function(length.out, from=1L) { seq(from=from, length.out=max(0L, length.out-from+1L)) } lapply(0:4, FUN=seq_len2, from=2L) [[1]] integer(0) [[2]] integer(0) [[3]] [1] 2 [[4]] [1] 2 3 [[5]] [1] 2 3 4 /Henrik On Sat, Dec 21, 2013 at 2:57 PM, Göran Broström

Re: [R] Unable to Install a package from source in Windows

2014-01-09 Thread Henrik Bengtsson
The answer most likely is in the message: '\\homer.win.ad.jhu.edu\users$\rvaradh1\Documents' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory. That path starting with a \\ is a *UNC path* (a Windows thing), which I

Re: [R] Unable to Install a package from source in Windows

2014-01-09 Thread Henrik Bengtsson
On Thu, Jan 9, 2014 at 11:04 AM, Henrik Bengtsson h...@biostat.ucsf.edu wrote: The answer most likely is in the message: '\\homer.win.ad.jhu.edu\users$\rvaradh1\Documents' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows

Re: [R] problem with Rstudio e X11

2014-01-15 Thread Henrik Bengtsson
Unless you have the same issues using plain R, this sounds like a question specific to RStudio which needs to be addressed to https://support.rstudio.com/ Henrik On Jan 15, 2014 6:35 AM, Ronaldo Reis Júnior chryso...@gmail.com wrote: Hi all, I has astrange problem with Rstudio desktop and X11

Re: [R] How do you install cran mac binaries

2014-01-27 Thread Henrik Bengtsson
As you install basically all CRAN packages and all OSes; install.packages(forecast) /Henrik On Mon, Jan 27, 2014 at 8:18 PM, ce zadi...@excite.com wrote: Sorry if the question is stupid, how you you install mac os binaries like in :

Re: [R] How do you install cran mac binaries

2014-01-28 Thread Henrik Bengtsson
. -Original Message- From: Henrik Bengtsson [h...@biostat.ucsf.edu] Date: 01/28/2014 12:30 AM To: ce zadi...@excite.com CC: r-help@r-project.org Subject: Re: [R] How do you install cran mac binaries As you install basically all CRAN packages and all OSes; install.packages

<    1   2   3   4   5   6   >