Re: [R] R and Matlab

2010-10-28 Thread Henrik Bengtsson
Hi, thanks for reporting on a potential issue with writeMat() in R.matlab. However, I think you are blaming the wrong source here. There is basically nothing wrong with writeMat() and the MAT files written by it can indeed be read by Matlab. I think you are experiencing two different problems.

Re: [R] R and Matlab

2010-10-29 Thread Henrik Bengtsson
Hi. On Fri, Oct 29, 2010 at 3:31 AM, Claudia Beleites cbelei...@units.it wrote: Dear Henrik, sorry for bothering you with a report hastily pasted together and not particularly nice for you as I used my toy data flu from a non-standard package. I should have better used e.g. the iris. I'm

Re: [R] programming questions

2010-11-03 Thread Henrik Bengtsson
On Wed, Nov 3, 2010 at 1:04 PM, ivo welch ivo.we...@gmail.com wrote: thanks, eric---I need a little more clarification.  *yes, I write functions and then forget them.  so I want them to be self-sufficient.  I want to write functions that check all their arguments for validity.)  For example,

Re: [R] Auto-killing processes spawned by foreach::doMC

2010-11-03 Thread Henrik Bengtsson
Hi, I am also interest in ways to in R send signals to other R sessions/processes, ideally in (what appears to be) an OS-independent way. For what it is worth, related question have been asked before, cf. R-devel thread 'Sending signals to current R process from R running under MS Windows (c.f.

Re: [R] Auto-killing processes spawned by foreach::doMC

2010-11-08 Thread Henrik Bengtsson
, Henrik Bengtsson h...@biostat.ucsf.edu wrote: Hi, I am also interest in ways to in R send signals to other R sessions/processes, ideally in (what appears to be) an OS-independent way.  For what it is worth, related question have been asked before, cf. R-devel thread 'Sending signals to current R

Re: [R] Full path to currently executed script file

2010-11-14 Thread Henrik Bengtsson
See findSourceTraceback() in the R.utils package. It's been discussed before, e.g. http://www.mail-archive.com/r-help@r-project.org/msg112375.html http://www.mail-archive.com/r-help@r-project.org/msg111871.html Beware, if you find yourself having to do this, it may be that you are doing

Re: [R] Globbing inconsistencies, dir() vs. unlink()

2010-11-17 Thread Henrik Bengtsson
Hi, note that to expand tilde, there is also path.expand() which should give less surprises than Sys.glob(). I can confirm that this is not only Windows, but also on Linux; dir(~/ttt) [1] foo.txt unlink(~/ttt, recursive=TRUE) dir(~/ttt) [1] foo.txt unlink(path.expand(~/ttt), recursive=TRUE)

Re: [R] all extended ASCII characters exist for R console output?

2010-11-19 Thread Henrik Bengtsson
Just to get the message through that some already tried, e.g. on Windows 7 with R (Rterm) you get: cat(\u2591,\u2592,\u2593) ¦ ¦ ¦ See it didn't even cut'n'paste the same visual symbols as I see in Rterm but I guess you cannot see that. Make sense? No? Point is, expect issues if you're

Re: [R] [beginner] simple keyword to exit script ?

2010-11-21 Thread Henrik Bengtsson
Better is probably to return() from a function, i.e. define a function in your script and call that at the end of your function, e.g. - - - - main - function() { # bla # bla if (something) { return(); } # otherwise # bla } main(); - - - - Otherwise, here is a hack:

Re: [R] Splitting 3D matrix from for loop to generate/save 2D matrices

2010-11-21 Thread Henrik Bengtsson
Hi, On Sun, Nov 21, 2010 at 9:27 PM, Hana Lee hana...@email.unc.edu wrote: Hi! I have a matrix called M with dimension (586,100,100). First of all, In R it is only an object with *two* dimensions that is called matrix. Anything with two or more dimensions is called an array. Example: x -

Re: [R] Splitting 3D matrix from for loop to generate/save 2D matrices

2010-11-21 Thread Henrik Bengtsson
Sorry, I did a mistake corrected below. On Sun, Nov 21, 2010 at 9:50 PM, hb h...@biostat.ucsf.edu wrote: Hi, On Sun, Nov 21, 2010 at 9:27 PM, Hana Lee hana...@email.unc.edu wrote: Hi! I have a matrix called M with dimension (586,100,100). First of all, In R it is only an object with *two*

Re: [R] Executing multiple .R files

2010-11-23 Thread Henrik Bengtsson
See R.utils package and sourceDirectory(), e.g. sourceDirectory(R/); You can also specify that you only want to reload files that have been modified, e.g. sourceDirectory(R/, modifiedOnly=TRUE); /Henrik On Tue, Nov 23, 2010 at 7:04 AM, Santosh Srinivas santosh.srini...@gmail.com wrote: Hello

Re: [R] how to find a row index in a matrix or a data frame ?

2010-11-25 Thread Henrik Bengtsson
rows - which(apply(mapply(x, r, FUN===), MARGIN=1, FUN=all)); /H On Thu, Nov 25, 2010 at 1:59 AM, Luedde, Mirko mirko.lue...@sap.com wrote: Dear all, this looks pretty much a standard problem, but I couldn't find a satisfying and understandable solution. (A) Given a data frame (or matrix),

Re: [R] Rows index/colProds

2010-08-15 Thread Henrik Bengtsson
What is your sessionInfo()? /Henrik On Sun, Aug 15, 2010 at 10:47 AM, pablo.andrade pablo.andr...@gmail.com wrote: Hi, Is there any function to replace colProds that finds column-wise products of a matrix? Or is there any other function that would give a better solution this problem ?

Re: [R] on abort error, always show call stack?

2010-08-22 Thread Henrik Bengtsson
For what's it worth, the Exception class of R.oo extends the simpleError class. When an Exception object is instantiated it also records the stack trace (traceback()). Then when the exception is thrown it will behave just as stop(). For the convenience, throw(message) does all this in one go,

Re: [R] previous work on linking to ROOT data structures

2010-08-22 Thread Henrik Bengtsson
See the xps package over at Bioconductor: http://www.bioconductor.org/packages/release/bioc/html/xps.html /H On Sun, Aug 22, 2010 at 4:53 PM, Sebastian White swh...@bnl.gov wrote: Hello, I was told that work had been done to use R with the CERN developed framework ROOT but can't find anything

Re: [R] R.matlab package help

2010-08-27 Thread Henrik Bengtsson
Hi, what is the version of Matlab you are running? Could you show a minimum verbatim example - starting with a fresh R session and library(R.matlab) - that gives you the error? Have you tried the example of help(Matlab)? Then, for troubleshooting it could be useful to ask Matlab to display

Re: [R] R.matlab package help

2010-08-27 Thread Henrik Bengtsson
Hi, could you send me what Matlab is outputting. When I send the following from R: evaluate(matlab, A=2;); Sending expression on the Matlab server to be evaluated...: 'A=2;' and Matlab should print something like: Received cmd: 1 eval string: A=2; Received an 'OK' reply (0) from the Matlab

Re: [R] R.matlab package help

2010-08-27 Thread Henrik Bengtsson
Hi, the reason for your problem is that there is a single quotation mark in the temporary pathname generated by Matlab which confuses Matlab when trying to save the file. Try replacing the existing MatlabServer.m file (should be in the directory where Matlab is running), with this file:

Re: [R] R.matlab package help

2010-08-27 Thread Henrik Bengtsson
Hi, let's stick with the remote=FALSE case first. What output does Matlab produce now? That is really key information in order to solve this. Also, make sure that you really restart the MatlabServer. /H On Fri, Aug 27, 2010 at 3:56 PM, michael tufemich...@gmail.com wrote: Henrik,          I

Re: [R] R.matlab package help

2010-08-27 Thread Henrik Bengtsson
On Fri, Aug 27, 2010 at 6:16 PM, michael tufemich...@gmail.com wrote: Henrik,          When I set remote=FALSE, I got this error: ??? Error: A MATLAB string constant is not terminated properly. Error in == MatlabServer at 197      eval(expr); Also the lines before. /Henrik In R:  

Re: [R] R.matlab package help

2010-08-28 Thread Henrik Bengtsson
Hi. On Fri, Aug 27, 2010 at 7:08 PM, michael tufemich...@gmail.com wrote: Henrik, The line before that is: Received cmd: 2 save C:\Users\FAN'S~1\AppData\Local\Temp\tpe2b4012b_f9ed_402d_af0f_f21ebd8116a6.mat -V6 B You should see have seen something like: save(tmpname, '-V6', 'B');

Re: [R] R.matlab package help

2010-08-28 Thread Henrik Bengtsson
Michael, could you please give me *verbatim* details on what messages you are seeing. In your previous reply you did *not* report seeing save(tmpname, '-V6', 'B'); and now you say you get it. Please do not abbreviate what you are getting (e.g. save(temp,-v6,B)), because that will not be useful

Re: [R] R.matlab package help

2010-08-28 Thread Henrik Bengtsson
Hi. On Sat, Aug 28, 2010 at 3:50 PM, michael tufemich...@gmail.com wrote: Henrik,           OK, finally I got the problem:  I have an  apostrophe in my windowns 7 user name. That mess up the file name. So I logged in using a guest account and it works: Received cmd: 1 eval string: B B =  

Re: [R] Which language is faster for numerical computation?

2010-09-10 Thread Henrik Bengtsson
Don't underestimate the importance of the choice of the algorithm you use. That often makes a huge difference. Also, vectorization is key in R, and when you use that you're really up there among the top performing languages. Here is an example from the official R wiki illustrating my points:

Re: [R] dataframe of dataframes?

2010-09-14 Thread Henrik Bengtsson
You can create an empty matrix (or even array) of list elements and then assign your data frames to whichever element you want. Example: # Allocate empty matrix... x - matrix(list(), nrow=2, ncol=3); # ...alternatively x - array(list(), dim=c(2,3)); print(x); [,1] [,2] [,3] [1,] NULL

Re: [R] How to uncompress a gz file in R

2010-09-14 Thread Henrik Bengtsson
To uncompress an *.gz file into another file on disk, see also ?gunzip in the R.utils package. /Henrik 2010/9/14 Uwe Ligges lig...@statistik.tu-dortmund.de: See ?gzfile Uwe Ligges On 14.09.2010 11:02, Wonsang You wrote: Dear Fellows, I would like to know how to uncompress a gz file at

Re: [R] How to uncompress a gz file in R

2010-09-15 Thread Henrik Bengtsson
the function 'gzfile'. Best Regards, Wonsang On 14 September 2010 15:23, Henrik Bengtsson h...@stat.berkeley.edu wrote: To uncompress an *.gz file into another file on disk, see also ?gunzip in the R.utils package. /Henrik 2010/9/14 Uwe Ligges lig...@statistik.tu-dortmund.de: See ?gzfile Uwe

Re: [R] Matrix- create mean/min/max/stdev on column of matrix or rows?

2010-09-17 Thread Henrik Bengtsson
See also the matrixStats package on CRAN. /Henrik On Fri, Sep 17, 2010 at 10:17 AM, Dennis Murphy djmu...@gmail.com wrote: Hi: Here's a simple example that you can tune to your needs: m - matrix(rpois(100, 10), nrow = 10) # Function to compute summary statistics: f - function(x) c(min =

Re: [R] Date issues

2010-09-18 Thread Henrik Bengtsson
Make sure to look at as.character(FnO_Data$Date[m:l]) My $.02 /Henrik On Sat, Sep 18, 2010 at 10:31 PM, Santosh Srinivas santosh.srini...@gmail.com wrote: I tried this and it works too (For most part) strangely for certain dates (20090831) it is giving NA ... FnO_Data$Date[m:l]  [1]

Re: [R] Problem with unlist

2010-09-26 Thread Henrik Bengtsson
x - lapply(SumaPluvi, FUN=[, 1); n - sapply(x, FUN=length); print(table(n)); print(which(n != 1)); My $.02 /H On Sun, Sep 26, 2010 at 4:12 PM, Luis Felipe Parra felipe.pa...@quantil.com.co wrote: Hello I want to unlist the attached element getting only the first element in each element of the

Re: [R] Problem with unlist

2010-09-26 Thread Henrik Bengtsson
it the number of elements changes from 5065 to 5084 if there is no list element with length greater than one. Do you know what can be happening? Thank you Felipe Parra On Mon, Sep 27, 2010 at 8:05 AM, Henrik Bengtsson h...@stat.berkeley.edu wrote: x - lapply(SumaPluvi, FUN=[, 1); n - sapply(x

Re: [R] Problem with unlist

2010-09-27 Thread Henrik Bengtsson
On Mon, Sep 27, 2010 at 5:27 AM, Ben Bolker bbol...@gmail.com wrote: Luis Felipe Parra felipe.parra at quantil.com.co writes:  Hello, I am trying to unlist a list, which is attached, and I am having the problem that when I unlist it the number of elements changes from 5065 to 5084   x -

Re: [R] efficient equivalent to read.csv / write.csv

2010-09-28 Thread Henrik Bengtsson
To speed things up, you certainly want to give R more clues about your data files by being more explicit by many of the arguments (cf. help(read.table), especially specifying argument 'colClasses' makes a big difference. /Henrik On Tue, Sep 28, 2010 at 10:24 AM, statquant2 statqu...@gmail.com

Re: [R] Script auto-detecting its own path

2010-10-01 Thread Henrik Bengtsson
See findSourceTraceback() of R.utils, e.g. library(R.utils); example(findSourceTraceback); However, in general I would avoid using the above, because in nearly all cases there is a better solution which does not rely on knowing paths, e.g. setting up functions and calling those instead of using

Re: [R] How to apply vector value function to a multidimensional array indexed by the remaining dimensions?

2010-10-02 Thread Henrik Bengtsson
apply() is your friend. You can specify more than one dimension in argument 'MARGIN'. Example: x - array(1:100,c(3,4,5)) y - apply(x, MARGIN=c(2,3), FUN=sum) y [,1] [,2] [,3] [,4] [,5] [1,]6 42 78 114 150 [2,] 15 51 87 123 159 [3,] 24 60 96 132 168 [4,] 33

Re: [R] Output Graphics GIF

2010-10-03 Thread Henrik Bengtsson
On Sun, Oct 3, 2010 at 5:47 AM, Mike Marchywka marchy...@hotmail.com wrote: Date: Sat, 2 Oct 2010 23:59:50 -0300 From: nilzabar...@gmail.com To: tal.gal...@gmail.com CC: r-help@r-project.org Subject: Re: [R] Output Graphics GIF On Mon, Sep

Re: [R] readBin which has two different sizes

2010-10-03 Thread Henrik Bengtsson
On Sun, Oct 3, 2010 at 10:59 AM, Ab Hu master.rs...@yahoo.com wrote: Hi, I have a binary file which has the following structure: 1) Some header in the beginning 2) Thousands of 216-byte data sub-grouped into 4 54-byte data structured as 4-byte time stamp (big endian) followed by 50 1-byte

Re: [R] R doesn't want to update packages (Windows 7)

2010-10-05 Thread Henrik Bengtsson
Just to clarify to the OP (and please correct me if I'm wrong), having to run as admin should only be needed when you have to *update* (update.packages()) the so called recommend packages (comes with R) that sits under 'Program Files'. If you don't run as admin and try to *install*

Re: [R] maximum matrix size if it runs with 64-bit R

2010-10-05 Thread Henrik Bengtsson
On Tue, Oct 5, 2010 at 5:21 PM, Carrie Li carrieands...@gmail.com wrote: I am sorry that it has been couple days. I've read the website you provided below, but still don't quite know if this is doable. The maximum vector length is 2^31-1, so here is what I tired, and it returned errors as

Re: [R] Source awareness?

2010-10-06 Thread Henrik Bengtsson
See findSourceTraceback() in the R.utils package. /Henrik On Wed, Oct 6, 2010 at 8:49 AM, Ralf B ralf.bie...@gmail.com wrote: Here the general (perhaps silly question) first: Is it possible for a script to find out if it was sourced by another script or run directly? Here a small example

Re: [R] Quantile question

2010-10-07 Thread Henrik Bengtsson
Alternatively, see rowQuantiles() in the matrixStats package. /Henrik On Wed, Oct 6, 2010 at 10:34 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi, This should do it, for details, see ?apply a - matrix(rnorm(1),100,100) t(apply(a, 1, quantile, probs = c(.3, .5))) Basically you

[R] Line Type Specification: lty=onoff but lty=offon?

2010-10-10 Thread Henrik Bengtsson
Hi, Section 'Line Type Specification' in help(par) explains how you can do custom line types. For example: plot(NA, xlim=c(0,1), ylim=c(0,1)); abline(h=1/2, col=blue, lwd=2, lty=88); will draw a dashed line segment where the line is composed of 8 units of on (blue color) and 8 units of off

Re: [R] Line Type Specification: lty=onoff but lty=offon?

2010-10-10 Thread Henrik Bengtsson
device dependent (I'm using Windows). HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Henrik Bengtsson Sent: Monday, 11 October 2010 10:50 a.m. To: r-help Subject: [R] Line Type Specification: lty=onoff

Re: [R] Mixing LaTeX and R Code in Loops and Functions in Sweave

2009-10-17 Thread Henrik Bengtsson
...or the R.rsp package. -H On Sat, Oct 17, 2009 at 10:37 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: results=latex,echo=false= for(i in 1:10) {  cat(...latex code...) } @ or check out the brew package. On Fri, Oct 16, 2009 at 3:25 PM, Jacob R. Marcus

Re: [R] Determining which file is newer

2009-10-23 Thread Henrik Bengtsson
Have a look at your company name and your phone number. Nudge nudge, wink wink, say no more... /H On Fri, Oct 23, 2009 at 9:02 AM, Dennis Fisher fis...@plessthan.com wrote: Colleagues, I wish to execute a task only if a particular file is newer than a second file.  I can access the file

Re: [R] R.oo and S4?

2009-10-26 Thread Henrik Bengtsson
There are two basic class method dispatching mechanisms in R: S3 and S4. These are not R.oo. From a *design* point of view, S3 and S4 are rather similar, or more precisely, you can do the same things in both if you're careful. From an implementation point of view, they are different, and the

Re: [R] How to union the elements in a list?

2009-10-28 Thread Henrik Bengtsson
unlist(..., use.names=FALSE) is heaps faster than the default unlist(..., use.names=TRUE), cf. z - split(sample(1000,1e6,rep=TRUE),rep(1:1e5,10)) system.time(y1 - Reduce(union,z)) user system elapsed 5.980.005.89 system.time(y2 - unique(unlist(z))) user system elapsed

Re: [R] save an object by dynamicly created name

2009-11-01 Thread Henrik Bengtsson
path - data; dir.create(path); for (i in 1:10) { m - i:5; filename - sprintf(m%02d.Rbin, i); pathname - file.path(path, filename); save(m, file=pathname); } /H On Sun, Nov 1, 2009 at 6:53 PM, jeffc h...@andrew.cmu.edu wrote: Hi, I would like to save a few dynamically created objects

Re: [R] save an object by dynamicly created name

2009-11-01 Thread Henrik Bengtsson
On Sun, Nov 1, 2009 at 7:48 PM, David Winsemius dwinsem...@comcast.net wrote: On Nov 1, 2009, at 10:16 PM, Henrik Bengtsson wrote: path - data; dir.create(path); for (i in 1:10) {  m - i:5;  filename - sprintf(m%02d.Rbin, i);  pathname - file.path(path, filename);  save(m, file=pathname

Re: [R] save an object by dynamicly created name

2009-11-01 Thread Henrik Bengtsson
On Sun, Nov 1, 2009 at 9:18 PM, David Winsemius dwinsem...@comcast.net wrote: On Nov 1, 2009, at 11:28 PM, Henrik Bengtsson wrote: On Sun, Nov 1, 2009 at 7:48 PM, David Winsemius dwinsem...@comcast.net wrote: On Nov 1, 2009, at 10:16 PM, Henrik Bengtsson wrote: path - data; dir.create

Re: [R] How to execute a funcition which name is stored in a string?

2009-11-01 Thread Henrik Bengtsson
?do.call /H On Sun, Nov 1, 2009 at 10:58 PM, Charlie Sharpsteen ch...@sharpsteen.net wrote: On Sun, Nov 1, 2009 at 8:07 PM, Ning Ma pnin...@gmail.com wrote: Hi, everybody Is there any way to execute a function, which name is stored in a string. such as: a - ls() foo(a) ## same as ls()

Re: [R] new help pages in R 2.10.0

2009-11-05 Thread Henrik Bengtsson
On Thu, Nov 5, 2009 at 11:03 PM, antonio.gasparr...@lshtm.ac.uk wrote: Thanks to everyone who replied. I think the html based one works fine (even if I definitely preferred the old chtml). Only another comment: I chose html in my installation with Windows Vista, but still the help pages

Re: [R] R.oo and S4?

2009-11-11 Thread Henrik Bengtsson
Please what I already wrote in my previous message of this thread. Also, everything in R.oo is based on S3 and it uses standard R constructs and data types to achieve what it does. You can submit packages based on R.oo, and there are several such packages on CRAN, see 'Reverse dependencies' on

Re: [R] Calculating a Maximum for a row or column with NA's

2010-04-18 Thread Henrik Bengtsson
On Sun, Apr 18, 2010 at 7:26 AM, steven mosher mosherste...@gmail.com wrote: Ya I got that result but fixing it was a mystery. especially since I will eventually want to subtract the row max from the row Min ( or calculate the range) if a matrix thus is:   [,1] [,2] [,3] [1,]   NA   NA   NA

Re: [R] how to make read in a vector of 0s and 1s with no space between them

2010-04-25 Thread Henrik Bengtsson
See readBin(), e.g. r - readBin(pathname, what=raw, n=10e6); str(r); # raw [1:21] 30 31 30 31 ... c - rawToChar(x, multiple=TRUE); str(c); # chr [1:21] 0 1 0 1 0 0 1 0 1 0 ... i - as.integer(r); str(i); # int [1:21] 48 49 48 49 48 48 49 48 49 48 ... /Henrik On Sun, Apr 25, 2010 at 6:52 PM,

Re: [R] Problem installing gtools package

2010-04-27 Thread Henrik Bengtsson
See this thread: Stefan Theußl, Update: working mirrors and services due to IT failure at WU, April 26, 2010: https://stat.ethz.ch/pipermail/r-help/2010-April/236601.html /Henrik On Tue, Apr 27, 2010 at 3:02 PM, Andrew Hill andy.bob.h...@gmail.com wrote: Hello, I am attempting to install

Re: [R] R cannot access the web?

2010-05-14 Thread Henrik Bengtsson
On Fri, May 14, 2010 at 12:29 AM, Trojan ypa...@usc.edu wrote: Hi, I had originally posted regarding an error when trying to install package - GenABEL - it has now become clear that R is not able to connect to the net. Below are a couple of things I've tried with the resulting errors I am

Re: [R] Running gplots package with Windows 7

2010-05-17 Thread Henrik Bengtsson
I won't have an answer but it will help others to help you if you also report what the following gives: library(gtools); print(sessionInfo()); and print(packageDescription(gtools)); My $.02 Henrik On Mon, May 17, 2010 at 4:01 AM, agusdon agus...@gmail.com wrote: Hello, I'm fairly new to

Re: [R] Dynamically build variable names

2010-05-17 Thread Henrik Bengtsson
On Mon, May 17, 2010 at 11:12 AM, jim holtman jholt...@gmail.com wrote: ?'[[' What I think you want is: x - V1_1 mean(l[[x]]) Also you need to look at 'get'. ...and if the answer is get() or assign() you should usually consider library(fortunes); fortune(rethink the question); /Henrik

Re: [R] issues with R Library on a Server

2010-05-18 Thread Henrik Bengtsson
On Tue, May 18, 2010 at 4:03 AM, Daisy Englert Duursma daisy.duur...@gmail.com wrote: Hello, I am a bit over my head on this issue. My colleagues and I are running R off of our server. We all have admin rights and prior to yesterday we all had our own libraries. Our main system administrator

Re: [R] avoiding reinstall already installed *package*

2010-05-18 Thread Henrik Bengtsson
On Wed, May 19, 2010 at 7:20 AM, milton ruser milton.ru...@gmail.com wrote: *but* going back to my question, is not true that already installed packages will not be reinstaled. I ran: install.packages(c(ggplot2),dependencies=T)

Re: [R] use object within rda file in for loop

2010-05-20 Thread Henrik Bengtsson
On Thu, May 20, 2010 at 3:06 PM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: I've found the answer: get() is exactly what I need, I completely forgot about this function. There might be a better way, but that works for me. I R.utils, there are saveObject() and loadObject(), which allows

Re: [R] escape character OK in R environment, fails in R CMD CHECK

2010-05-22 Thread Henrik Bengtsson
R version/sessionInfo()? /H On Fri, May 21, 2010 at 10:08 PM, David Reiss dre...@systemsbiology.org wrote: Hi, I am trying to check a package via R CMD CHECK and it is failing with Error: '\s' is an unrecognized escape in character string starting \s The culprit looks something like this:

Re: [R] Getting sink to work with message on R 2.11.0 - what didI miss?

2010-05-26 Thread Henrik Bengtsson
On Wed, May 26, 2010 at 8:26 AM, Tal Galili tal.gal...@gmail.com wrote: Hello Greg, Thank you for the coding. A few questions and remarks: 1) I have a feature request that I believe Faiz is interested in: He would like to have the formatting of tables/data.frames in the output to be

Re: [R] Hgu133acdf Installation Problem

2010-05-26 Thread Henrik Bengtsson
This is sounds like a Bioconductor related issue; please ask your question on the bioc mailing list. /Henrik On Wed, May 26, 2010 at 8:51 AM, mahalakshmi sivamani mahasiva1...@gmail.com wrote: Hi, While trying to install hgu133acdf- windows package in R im getting the following error and

Re: [R] shorten str() output for long list

2009-12-03 Thread Henrik Bengtsson
str(head(x)) str(head(x, n=5)) /H On Thu, Dec 3, 2009 at 10:18 PM, David Winsemius dwinsem...@comcast.net wrote: On Dec 3, 2009, at 10:11 PM, Peng Yu wrote: x=split(1:1000,1:1000) str(x) Although str() can suppress long output for vectors, but it can not suppress long output for list.

Re: [R] About R memory management?

2009-12-10 Thread Henrik Bengtsson
Related... Rule of thumb: Pre-allocate your object of the *correct* data type, if you know the final dimensions. /Henrik On Thu, Dec 10, 2009 at 8:26 AM, Peng Yu pengyu...@gmail.com wrote: I'm wondering where I can find the detailed descriptions on R memory management. Understanding this

Re: [R] copyING directories and files

2009-12-11 Thread Henrik Bengtsson
copyDirectory() in the R.utils package. /Henrik On Fri, Dec 11, 2009 at 1:01 AM, Paul Evans p.evan...@yahoo.com wrote: Hi, I am using the windows version of R. I wanted to copy a directory (containing several files) to another directory. Is there any command in R that will let me do this

Re: [R] save an object by dynamicly created name

2009-12-12 Thread Henrik Bengtsson
-Original Message- From: henrik.bengts...@gmail.com [mailto:henrik.bengts...@gmail.com] On Behalf Of Henrik Bengtsson Sent: Monday, November 02, 2009 12:34 AM To: David Winsemius Cc: r-help@r-project.org; jeffc Subject: Re: [R] save an object by dynamicly created name On Sun, Nov 1

Re: [R] What is the fastest way to see what are in an RData file?

2009-12-19 Thread Henrik Bengtsson
library(R.oo); setMethodS3(ll, character, function(pathname, ..., force=FALSE) { require(R.cache) || throw(Package not loaded: R.cache); # Argument 'pathname': pathname - Arguments$getReadablePathname(pathname, mustExist=TRUE); # Check for cache results fi - file.info(pathname);

Re: [R] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Henrik Bengtsson
Use submat - data[1:i,, drop=FALSE] /H On Wed, Dec 23, 2009 at 6:46 PM, Francesco Napolitano franap...@gmail.com wrote: Hi all, I'm trying to learn R after years of Matlab's experience. Here is an issue I couldn't solve today. Consider the following piece of code (written by memory):

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Henrik Bengtsson
Please give reproducible example, more information on your troubleshooting and sessionInfo(). Cannot reproduce: pathname - empty.txt cat(file=pathname) print(file.info(pathname)) size isdir mode mtime ctime empty.txt0 FALSE 666 2010-01-01 12:50:55

Re: [R] Calling FING.EXE under RGui.EXE for windows.

2010-01-07 Thread Henrik Bengtsson
No paths for shell() - instead throw it commands as if you were at the Windows command prompt, i.e. res - shell(find, intern=TRUE); str(res); chr [1:3454] . ./.Rhistory ./aroma.affymetrix ... /H 2010/1/7 Uwe Ligges lig...@statistik.tu-dortmund.de: Argh. I see it as well. Will dig a lit

Re: [R] how to organize a lot of R source files

2010-01-08 Thread Henrik Bengtsson
library(R.utils); sourceDirectory(myRFiles/, modifiedOnly=TRUE); See ?sourceDirectory (regardless what the Rd help say, any '...' argument is passed to sourceTo()). /Henrik On Fri, Jan 8, 2010 at 7:38 AM, Hao Cen h...@andrew.cmu.edu wrote: Hi, I wonder what is a better way to organize a lot

Re: [R] how to organize a lot of R source files

2010-01-09 Thread Henrik Bengtsson
. Nothing to worry about. I've added readLines(con=fh, warn=FALSE) for the next release to get rid of such warnings. /Henrik Maybe the two issues are related. Please advise. thanks Jeff On Fri, January 8, 2010 7:56 pm, Henrik Bengtsson wrote: library(R.utils); sourceDirectory(myRFiles

Re: [R] Calling FING.EXE under RGui.EXE for windows.

2010-01-10 Thread Henrik Bengtsson
Forgot to say that when you use that findit.bat script, you get: Rgui.exe: system(findit.bat) Errorlevel is 1, not found shell(findit.bat) Errorlevel is 1, not found Rterm.exe: shell(findit.bat) c:\config.sys Errorlevel is 0, found system(findit.bat) c:\config.sys Errorlevel is 0,

Re: [R] Calling FING.EXE under RGui.EXE for windows.

2010-01-10 Thread Henrik Bengtsson
cat(file=foo.txt, Hello world\n) shell('find Hello foo.txt') Hello world shell('find Hello foo.txt', intern=TRUE) [1] Hello world shell('type foo.txt | find Hello') Hello world shell('type foo.txt | find Hello', intern=TRUE) [1] Hello world A person at

Re: [R] increase memory

2010-06-03 Thread Henrik Bengtsson
On Thu, Jun 3, 2010 at 11:11 AM, azam jaafari azamjaaf...@yahoo.com wrote: Dear All Pleas help me to increase the memory in R. In order increase memory, I read the FAQ and follow the instruction as below Close R, then right-click on your R program icon (the icon on your desktop or in

Re: [R] strange behaviour of CairoPNG

2010-06-05 Thread Henrik Bengtsson
FYI, follow the information in the email footer: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and make sure at a minimum to report your sessionInfo(). That increases your chances to get a response. /Henrik On Sat, Jun 5, 2010 at 11:42 AM, Thomas Steiner

Re: [R] Odp: strange issue with which on seq

2010-06-09 Thread Henrik Bengtsson
On Wed, Jun 9, 2010 at 2:20 PM, Nikhil Kaza nikhil.l...@gmail.com wrote: which(abs(v - .1) = .Machine$double.eps) seems to me too cumbersome to write. Any other easier way? all.equal does not quite work See isZero() in R.utils, e.g. isZero(abs(v - 0.1)); You can adjust the precision with

Re: [R] OOP and passing by value

2010-06-09 Thread Henrik Bengtsson
Pass an object of, or containing an, environment. Then whenever you modify any object inside the environment, the changes will remain also when exiting from the function(s). This has been used by many for quite some time and is the standard way to do it, if you need this feature. See packages

Re: [R] setting the current working directory to the location of the source file

2010-06-11 Thread Henrik Bengtsson
Isn't this what source(..., chdir=TRUE) is for? See help(source). /H On Fri, Jun 11, 2010 at 2:33 AM, Marcin Gomulka mrgo...@gmail.com wrote: AFAIK a script run through source() does not have any legit way to learn about it's own location. I need this to make sure that the script will find

Re: [R] Unable to load an object

2010-06-11 Thread Henrik Bengtsson
If file 'geoFeatures.RData' contains an object with name 'geoFeatures', it is loaded if you do: load(geoFeatures.RData); However, when you do: geoFeatures - load(geoFeatures.RData); it will be loaded, but immediately overwritten because you create a new object with the same name. Note that

Re: [R] Decoding raw vectors every other byte

2010-06-16 Thread Henrik Bengtsson
x - 1:10; dim(x) - c(length(x)/2, 2); print(x); [,1] [,2] [1,]16 [2,]27 [3,]38 [4,]49 [5,]5 10 str(x[,1]); str(x[,2]); If length(x) is odd, some care is needed, e.g. x - matrix(x, ncol=2, byrow=FALSE); /H On Wed, Jun 16, 2010 at 1:15 PM, Alex van der

Re: [R] Find the 50 highest values in a matrix

2010-06-18 Thread Henrik Bengtsson
You might also want to consider _partial sorting_ by using the 'partial' argument of sort(), especially when the number of data points is really large. Since argument 'decreasing=FALSE' is not supported when using 'partial', you have to flip it yourself by negating the values, e.g. x -

Re: [R] S3 generics need identical signature?

2010-06-21 Thread Henrik Bengtsson
On Mon, Jun 21, 2010 at 4:23 PM, Gábor Csárdi csa...@rmki.kfki.hu wrote: On Mon, Jun 21, 2010 at 4:17 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: [...] The requirement is that the methods need to have signatures that contain all the arguments of the generic.  If the generic includes

Re: [R] Error in affypdnn package

2010-07-06 Thread Henrik Bengtsson
Hi, repost your question to the Bioconductor mailing list instead, and your chances for getting help will be much greater: http://bioconductor.org/docs/mailList.html /Henrik On Tue, Jul 6, 2010 at 9:06 AM, Hasan, Ahmed Ryadh - hasar001 ahmed.ha...@postgrads.unisa.edu.au wrote: Dear all, I

Re: [R] Linux-Windows problem

2010-07-06 Thread Henrik Bengtsson
Sorry for asking the obvious, but have you confirmed that you are running the same version of R on both systems? /H On Tue, Jul 6, 2010 at 2:11 PM, Bos, Roger roger@rothschild.com wrote: Uwe, I suspect I might be having a similar problem as the R code I generate in Windows editor

Re: [R] Newbie mistakes saving images to files

2010-01-14 Thread Henrik Bengtsson
?png says: If you plot more than one page on one of these devices and do not include something like %d for the sequence number in file, the file will contain the last page plotted. meaning png(foo%03d.png, width=300, height=300); plot(1); plot(2); plot(3); dev.off(); generates foo001.png,

Re: [R] R.oo installation warnings?

2010-01-20 Thread Henrik Bengtsson
Hi, don't worry about those setGenericS3()/setMethodS3(0 warnings - they are just informative. I am aware of that last warning: Warning: package 'R.oo' claims to be built under R version 2.10.0 but is missing some help files and needs to be re-installed but it does not go away when you

Re: [R] Optimizing C code

2010-01-22 Thread Henrik Bengtsson
A side note: The NA vs NaN does not seem to play a role here, because: #define both_non_NA(a,b) (!ISNAN(a) !ISNAN(b)) So, it is the same type of test used in line 9 and in line 11. /Henrik On Fri, Jan 22, 2010 at 9:52 AM, Christophe Genolini cgeno...@u-paris10.fr wrote: Thanks both of you.

Re: [R] ff package: ff objects don't reload completely on NFS drives from a different machine

2010-01-23 Thread Henrik Bengtsson
Hi, this could be due to how NFS works. Note that there can be up to a 30 second delay before other hosts on the same file system see the updates that was flushed by one machine. You basically cannot treat files on an shared NFS file system as if you are working on a single machine. You have

Re: [R] End of File for binary files

2010-01-24 Thread Henrik Bengtsson
On Sun, Jan 24, 2010 at 3:56 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 23/01/2010 10:40 PM, rn00b wrote: I am using readBin to continuously read characters from the binary file. I'm trying to figure out how many characters are in the file. What I would like to do is something like

Re: [R] How to export the examples in help(something) to a file?

2010-02-04 Thread Henrik Bengtsson
On Thu, Feb 4, 2010 at 9:18 PM, Liaw, Andy andy_l...@merck.com wrote: From: Peng Yu On Wed, Feb 3, 2010 at 10:01 AM, Peng Yu pengyu...@gmail.com wrote: Some examples in the help page are too long to be copied from screen. Could somebody let me know some easy way on how to extract the

Re: [R] Fast way to determine number of lines in a file

2010-02-08 Thread Henrik Bengtsson
I was looking for a fast line counter as well a while ago and ended up writing a small function in R: countLines() in the R.utils package At least at the time, it was faster than readLines() [for unknown reasons]. It is also more memory efficient. It supports connections. I don't think it

Re: [R] trouble with read.table and colClasses='raw'

2010-02-12 Thread Henrik Bengtsson
The OP may be interested in using low-level readBin() and writeBin() instead. One can then either assign dimension attributes to the object to access the data as a matrix/an array. Note that assigning dimension attributes will probably(?) allocate a copy. If that is not wanted, it is not that

Re: [R] Using seq_len() vs 1:n]

2010-02-12 Thread Henrik Bengtsson
If S+ has seq(length=...), that would solve any parsing problems. /Henrik On Fri, Feb 12, 2010 at 4:59 PM, William Dunlap wdun...@tibco.com wrote: The next version of S+ will have seq_len in it.  Currently the CSAN package Rcompat contains it. Parsing the name seq_len can be a problem, since

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Henrik Bengtsson
On Thu, Feb 18, 2010 at 7:15 PM, Erik Iverson er...@ccbr.umn.edu wrote: Erik Iverson wrote: Cannot reproduce, what is branches?  If you can narrow it down to a commented, minimal, self-contained, reproducible example, you're far more likely to get help from the list. My blinded guess

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Henrik Bengtsson
What does print(as.integer(branches)) give? That is what rep() uses. /H On Thu, Feb 18, 2010 at 7:49 PM, dkStevens david.stev...@usu.edu wrote: I could send the entire bit of code but I was hoping that someone would recognize the issue from past experience. I may be an artifact of other

  1   2   3   4   5   6   >