Re: [R] Reading data

2009-09-25 Thread Henrik Bengtsson
On Fri, Sep 25, 2009 at 10:18 AM, Henrik Bengtsson h...@stat.berkeley.edu wrote: You can use R.utils (on CRAN) to help you figure out why the file is not found or not readable. library(R.utils); pathname - C:/Documents and Settings/ashta/My Documents/R_data/rel.dat; pathname - Arguments

Re: [R] Problem in using BATCH command

2009-09-22 Thread Henrik Bengtsson
You probably want to use the source() command in R. R CMD BATCH is used from the command line - it's rare that people use it (unless they really know what they are doing). /Henrik On Tue, Sep 22, 2009 at 9:01 AM, Manuj Sharma smanuj1...@yahoo.in wrote: I tried to use BATCH command to run an

Re: [R] Create directory and copy files in R

2009-09-22 Thread Henrik Bengtsson
See copyDirectory() in the R.utils package. /hb On Tue, Sep 22, 2009 at 9:43 AM, Yihui Xie xieyi...@gmail.com wrote: You assigned values to 'fn' and 'dpath' outside the function body and use these names as the arguments of your function, so actually 'cyfun' does not know what 'fn' and 'path'

Re: [R] R PNG graph width limitation

2009-09-22 Thread Henrik Bengtsson
You *have to* report sessionInfo() when you ask for this kind of help. It might be that the PNG is actually generated, but it is the viewer that cannot display it. You can check with other viewers or editors. You can also try to downscale using ImageMagick, e.g. convert -geometry 10% large.png

Re: [R] cluster-lite

2009-09-16 Thread Henrik Bengtsson
The R.batch package does most of this. It's been several years, but I used it run batch jobs on multiple (30-40) machines with different OS:es but sharing the same file system. No communication needed between hosts. It worked like a charm and I could process 3-4 CPU years in a few weeks for

Re: [R] Why strsplit can be used with matrix but not data.frame?

2009-09-16 Thread Henrik Bengtsson
Hi, have a look at help(str) - the str() function will be your friend for life! ...and 99.9% of the error message in R are indeed correct, on the spot and informative. So, try str(x$y). My $.02 /Henrik On Wed, Sep 16, 2009 at 6:22 PM, Peng Yu pengyu...@gmail.com wrote: Hi, As show in the

Re: [R] how to determine if a variable is already set?

2009-09-14 Thread Henrik Bengtsson
Not the most beautiful solution: start your message with carriage return, e.g. stop(\rA long enough message); A long enough message stop(\rfoo); fooor: /H On Mon, Sep 14, 2009 at 5:06 PM, Bert Gunter gunter.ber...@gene.com wrote: I don't believe the solution proposed below works and anyway

Re: [R] R Memory Usage Concerns

2009-09-14 Thread Henrik Bengtsson
As already suggested, you're (much) better off if you specify colClasses, e.g. tab - read.table(~/20090708.tab, colClasses=c(factor, double, double)); Otherwise, R has to load all the data, make a best guess of the column classes, and then coerce (which requires a copy). /Henrik On Mon, Sep

Re: [R] Size of plots in pdf files#can it be smaller?

2009-09-07 Thread Henrik Bengtsson
No (destructive) JPGs - they are evil (draw a line as see for yourself) and should be banned from publications (only useful for pictures/photos). Use PNGs for you plots if you don't like vector graphics. /H On Mon, Sep 7, 2009 at 5:00 PM, jim holtmanjholt...@gmail.com wrote: The reason for the

Re: [R] Size of plots in pdf files#can it be smaller?

2009-09-07 Thread Henrik Bengtsson
Hi, I've got a trial version of a thinScatter() function that (down-)samples 2d-scatter plots while preserving the empirical density distribution. You can grab it by: source(http://www.braju.com/R/hbLite.R;); hbLite(scatterPlots); Example from example(thinScatter): library(scatterPlots); #

Re: [R] Google's R Style Guide

2009-09-01 Thread Henrik Bengtsson
On Tue, Sep 1, 2009 at 6:29 AM, Duncan Murdochmurd...@stats.uwo.ca wrote: On 9/1/2009 8:58 AM, Martin Morgan wrote: Corrado wrote: Thanks Duncan, Spencer, To clarify, the situation is: 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding convention 2) Our group has

Re: [R] Google's R Style Guide

2009-08-28 Thread Henrik Bengtsson
Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into

Re: [R] Google's R Style Guide

2009-08-28 Thread Henrik Bengtsson
On Fri, Aug 28, 2009 at 9:10 AM, Henrik Bengtssonh...@stat.berkeley.edu wrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at:  http://docs.google.com/View?id=dddzqd53_2646dcw759cb Google Docs seems to have a hiccup when it comes to publishing/sharing docs; here is a

Re: [R] Submit a R job to a server

2009-08-27 Thread Henrik Bengtsson
Have a look at Karim Chine's R/Biocep project: http://biocep-distrib.r-forge.r-project.org/ /henrik On Wed, Aug 26, 2009 at 9:12 PM, Moshe Olshanskym_olshan...@yahoo.com wrote: Hi Deb, Based on your last note (and after briefly looking at Rserve) I believe that you should install R with

Re: [R] Help with R.oo

2009-07-17 Thread Henrik Bengtsson
On Fri, Jul 17, 2009 at 11:41 PM, Jim Nemeshnem...@broad.mit.edu wrote: Hi!  I'm trying to learn about object oriented R, as it seems like it would be very useful. I'm going over an example from the documentation, and I'm very confused: http://www1.maths.lth.se/help/R/R.oo/ [assume you've

Re: [R] Help with R.oo

2009-07-17 Thread Henrik Bengtsson
On Sat, Jul 18, 2009 at 3:21 AM, Henrik Bengtssonh...@stat.berkeley.edu wrote: On Fri, Jul 17, 2009 at 11:41 PM, Jim Nemeshnem...@broad.mit.edu wrote: Hi!  I'm trying to learn about object oriented R, as it seems like it would be very useful. I'm going over an example from the documentation,

Re: [R] Learning S3

2009-06-18 Thread Henrik Bengtsson
Not a suggestion on documentation, but to ease S3 coding and hiding some of the details, you might want to consider the R.methodsS3 package. It basically provides some S3 code generators and makes it clear what class of objects a method is dispatched on. From the example code: setMethodS3(foo,

Re: [R] saving loess fit

2009-06-11 Thread Henrik Bengtsson
See save() and load(), but the following might be easier because it does not mess with your existing object names: library(R.utils) saveObject(pv.lo, myLoessFit.Rbin) pv.lo - loadObject(myLoessFit.Rbin) foo - loadObject(myLoessFit.Rbin) print(identical(pv.lo, foo)) # = TRUE /Henrik On Thu,

Re: [R] Installing the Rstem package

2009-06-11 Thread Henrik Bengtsson
Google Rstem package - first hit. It is hosted by the Omegahat project. /H On Thu, Jun 11, 2009 at 10:29 AM, Rajan, Ravira...@rand.org wrote: Hi, I can't find the package for LSA. When I try http://www.statistik.uni-dortmund.de/~ligges/Rstem_0.3-1.zip

Re: [R] R CMD check does not find a mistake

2009-06-09 Thread Henrik Bengtsson
using R version 2.9.0 beta (2009-04-04 r48290) As a start, Kurt et al. are for sure using a much more recent version (probably also the very latest patched version). /H On Tue, Jun 9, 2009 at 7:17 AM, Christophe Genolinicgeno...@u-paris10.fr wrote: Hi the list, I build a package. They was a

Re: [R] Good Programming Practice Question - Functions in Different Files

2009-06-09 Thread Henrik Bengtsson
library(R.utils); sourceDirectory(C:/appropriatepath/R/, modifiedOnly=TRUE); On Tue, Jun 9, 2009 at 8:09 PM, spencergspencer.gra...@prodsyse.com wrote: Sundar Dorai-Raj taught me to do the following:           Rdir - c:\appropriatepath\R           Rfiles - dir(Rdir, pattern='\\.R$',

Re: [R] IP-Address

2009-06-01 Thread Henrik Bengtsson
Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote: wow! :) vQ Henrik Bengtsson wrote: library(gsubfn) library(gtools) library(rbenchmark) n - 1 df - data.frame(   a = rnorm(n),   b = rnorm(n),   c = rnorm(n),   ip = replicate(n, paste(sample(255, 4), collapse

Re: [R] IP-Address

2009-05-31 Thread Henrik Bengtsson
library(gsubfn) library(gtools) library(rbenchmark) n - 1 df - data.frame( a = rnorm(n), b = rnorm(n), c = rnorm(n), ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE) ) res - benchmark(columns=c('test', 'elapsed'), replications=10, order=NULL, peda = {

Re: [R] IP-Address

2009-05-31 Thread Henrik Bengtsson
Not really, just the old saying that any piece of code can be made twice as fast (which often holds true recursively). /Henrik On Sun, May 31, 2009 at 1:58 PM, Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote: wow! :) vQ Henrik Bengtsson wrote: library(gsubfn) library(gtools

Re: [R] Reading Binary Files

2009-02-11 Thread Henrik Bengtsson
Argument 'size' is what you are looking for, cf. help(readBin). Whenever reading binary files this way, I strongly recommend that you are explicit about all arguments of readBin(), e.g. readBin(con, what=integer(), size=2, signed=TRUE, endian=little, n=n); For instance, you probably do not want

Re: [R] Rterm.exe stops responding to keyboard input

2009-02-10 Thread Henrik Bengtsson
Hi, this sounds awfully similar to what I reported in r-help thread '[R] Windows Vista, Rterm LeftAlt + Tab issue' on Aug 21, 2008, cf. https://stat.ethz.ch/pipermail/r-help/2008-August/171548.html At least we are not alone ;) ...and I though it was an issue with Windows Vista only, because

Re: [R] error in my previous message

2009-02-10 Thread Henrik Bengtsson
You want to do: temp2 - matrix(rnorm(10),nc=1,nrow=10) rownames(temp2) - c(a,b,c,d,e,f,g,h,i,j) print(temp2) o - order(temp2[,1]) temp2 - temp2[o,,drop=FALSE] print(temp2) Note that it makes no difference if you drop the dimension of a single column vector or not when passed to order(). /H On

Re: [R] list.files changed in 2.7.0

2009-02-03 Thread Henrik Bengtsson
exactly the same results. My current directory (getwd()) is not C:. I'm puzzled by your output. -- David -Original Message- From: henrik.bengts...@gmail.com [mailto:henrik.bengts...@gmail.com] On Behalf Of Henrik Bengtsson Sent: Friday, January 23, 2009 8:36 PM To: David Reiner dav

Re: [R] scoping rules for 'for' [was - Re: for/if loop ]

2009-01-29 Thread Henrik Bengtsson
[mailto:henrik.bengts...@gmail.com] On Behalf Of Henrik Bengtsson Sent: Wednesday, January 28, 2009 5:08 PM To: David Reiner dav...@rhotrading.com Cc: SnowManPaddington; r-help@r-project.org Subject: Re: [R] - Re: for/if loop On Wed, Jan 28, 2009 at 2:41 PM, dav...@rhotrading.com wrote: Well

Re: [R] [SPAM] - Re: for/if loop - Bayesian Filter detected spam

2009-01-28 Thread Henrik Bengtsson
On Wed, Jan 28, 2009 at 2:41 PM, dav...@rhotrading.com wrote: Well, maybe you are just bad at typing then ;-) The lines rr==ii, pp==pp+1, etc. are not setting rr and pp but comparing them. Probably you want rr - ii and pp - pp+1, etc. And the last line of your loop 'ii=ii+1' means that,

Re: [R] .Renviron for multiple hardwares...

2009-01-25 Thread Henrik Bengtsson
The script .Rprofile evaluates R code on startup. You could use that to test for various environment variables. Alternatively, use Unix shell scripts to set system environment variables to be used in a generic .Renviron. See help(Startup) for more details. /Henrik On Sun, Jan 25, 2009 at

Re: [R] list.files changed in 2.7.0

2009-01-23 Thread Henrik Bengtsson
And I'm not sure that list.files(C:, full.names=TRUE) returns correct pathnames, because it lists the files in the current directory (of C:), not the root of C:. There is a difference between C: and C:/, and you should get: list.files(C:, full.names=TRUE) [1] C:aFile.txt [2] C:anotherFile.txt

Re: [R] Faster Printing Alternatives to 'cat'

2009-01-17 Thread Henrik Bengtsson
Do it in chunks of rows. /H On Sat, Jan 17, 2009 at 6:55 AM, Gundala Viswanath gunda...@gmail.com wrote: Hi Hadley, I had to do it by line. Because, in practice, I will manipulate the figures and string before printing it. And I can't bind these results into one new object, because there

Re: [R] Faster Printing Alternatives to 'cat'

2009-01-17 Thread Henrik Bengtsson
= FALSE, quote = TRUE, sep = , eol = \n, na = NA, dec = ., row.names = TRUE, col.names = TRUE, qmethod = c(escape, double)) - Gundala Viswanath Jakarta - Indonesia On Sun, Jan 18, 2009 at 12:09 AM, Henrik Bengtsson h...@stat.berkeley.edu wrote: Do

Re: [R] Summary of Total Object.Size in R Script

2009-01-15 Thread Henrik Bengtsson
See also ll() in the R.oo package, e.g. # To list all objects in .GlobalEnv: ll() member data.class dimension objectSize 1*tmp* Person 1 428 2 as.character.Person function NULL1208 3 country character 1

Re: [R] Faster Printing Alternatives to 'cat'

2009-01-08 Thread Henrik Bengtsson
On Thu, Jan 8, 2009 at 3:12 AM, Gundala Viswanath gunda...@gmail.com wrote: Dear all, I found that printing with 'cat' is very slow. For example in my machine this snippet __BEGIN__ # I need to resolve to use this type of loop. # because using write(), I need to create a matrix which #

Re: [R] VCOV Source Code

2009-01-08 Thread Henrik Bengtsson
stats::vcov.lm Error: 'vcov.lm' is not an exported object from 'namespace:stats' stats:::vcov.lm function (object, ...) { so - summary.lm(object, corr = FALSE) so$sigma^2 * so$cov.unscaled } environment: namespace:stats /Henrik On Thu, Jan 8, 2009 at 1:44 AM, Carlos J. Gil Bellosta

Re: [R] First call to constructor fails (R.oo)

2008-12-10 Thread Henrik Bengtsson
Hi, Any R.oo Object must accept no arguments, e.g. Object(). Thus, in your case you need to be able to support the call MyClass(). The reason is that the first time you use the class, R.oo will create a static object of the class by calling ClassName(). Typically, I would do it this way:

Re: [R] memory limit

2008-11-26 Thread Henrik Bengtsson
On Wed, Nov 26, 2008 at 1:16 PM, Stavros Macrakis [EMAIL PROTECTED] wrote: I routinely compute with a 2,500,000-row dataset with 16 columns, which takes 410MB of storage; my Windows box has 4GB, which avoids thrashing. As long as I'm careful not to compute and save multiple copies of the

Re: [R] how to test for the empty set

2008-11-24 Thread Henrik Bengtsson
length() /Henrik On Mon, Nov 24, 2008 at 9:41 AM, G. Jay Kerns [EMAIL PROTECTED] wrote: Dear R-help, I first thought that the empty set (for a vector) would be NULL. x - c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode,

Re: [R] The use of F for False and T for True

2008-11-17 Thread Henrik Bengtsson
To save my fingers and still being on the safe side, I always do: !0 [1] TRUE !1 [1] FALSE ;) ...still hackable though. /Henrik On Mon, Nov 17, 2008 at 5:25 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 17/11/2008 8:03 AM, hadley wickham wrote: On Sun, Nov 16, 2008 at 7:41 PM, Simon

Re: [R] Cannot quit R - fame package issue?

2008-11-17 Thread Henrik Bengtsson
To solve the immediate problem of quitting R, you could try to define a dummy of the missing function, e.g. validServerIsRunning - function(...) FALSE; and then quit(). This does of course ignore any potential problems of not finalizing the 'fame' package correctly. Alternatively, since the

Re: [R] HOW to provide a CITATION file?

2008-11-15 Thread Henrik Bengtsson
See 'Writing R Extensions' via help.start() and then search for CITATION. My $.02 /Henrik On Sat, Nov 15, 2008 at 2:35 PM, Charles Annis, P.E. [EMAIL PROTECTED] wrote: Greetings, R-ians: I am sure I am missing something obvious. How do I provide a CITATION file for my home-brew package, so

Re: [R] HOW to provide a CITATION file?

2008-11-15 Thread Henrik Bengtsson
the obvious File - Save Page As, because that gives me HTML. Instead, there is a Save a copy button in the upper left of the subwindow containing R-exts.pdf, which I must press to get that particular document. Best Wishes, Spencer Henrik Bengtsson wrote: See 'Writing R Extensions

Re: [R] Problems when I try to download.file pdfs

2008-11-14 Thread Henrik Bengtsson
See ?download.file and argument 'mode'. You want to use mode=wb. To R-core: I've asked it before, isn't the most common use case to download files in 'binary' mode? I cannot even remember when I last wanted to transfer a file in 'text' mode. I vote for making mode=wb the default. /Henrik On

Re: [R] how to stop without error message?

2008-11-10 Thread Henrik Bengtsson
I've also been looking for solutions to similar problems, but I never found a good solution. However, I think that if it would be possible to send an interrupt signal/condition by code (cf. user press Ctrl-C) one could achieve plenty of things with and without tryCatch(). See Thread 'New

Re: [R] Methods dispatch and inheritance R.oo

2008-11-06 Thread Henrik Bengtsson
Hi, On Thu, Nov 6, 2008 at 2:12 AM, Yuri Volchik [EMAIL PROTECTED] wrote: Thanks for reply Henrik, seems obvious now. Can child class (B) access argument of the parent class, i.e. can i rewrite definition of the class B as setConstructorS3(ClassB, function() { extend(ClassA(), ClassB,

Re: [R] Saving a 3d array into a matlab file

2008-11-01 Thread Henrik Bengtsson
Hi, a follow up on this: I've fixed the below bug in writeMat(). R.matlab v1.2.4 is now available on CRAN. Please update. Henrik On Tue, Oct 28, 2008 at 3:30 PM, Henrik Bengtsson [EMAIL PROTECTED] wrote: Hi, On Tue, Oct 28, 2008 at 2:25 PM, Minho Chae [EMAIL PROTECTED] wrote: Dear R users

Re: [R] writeMat error

2008-11-01 Thread Henrik Bengtsson
Hi, a follow up on this as well: I've fixed the below bug in writeMat(). R.matlab v1.2.4 is now available on CRAN. Please update. Henrik On Wed, Oct 1, 2008 at 12:55 PM, Henrik Bengtsson [EMAIL PROTECTED] wrote: Hi. On Sat, Sep 27, 2008 at 5:17 AM, Steele, Dr Douglas [EMAIL PROTECTED

Re: [R] [ifelse] how to maintain a value from original matrix without probs?

2008-10-31 Thread Henrik Bengtsson
A - matrix(-4:4, ncol=3) A [,1] [,2] [,3] [1,] -4 -12 [2,] -303 [3,] -214 Apos - A; Apos[A = 0] - NA; Apos [,1] [,2] [,3] [1,] NA NA2 [2,] NA NA3 [3,] NA14 Aneg - A; Aneg[A = 0] - NA Aneg [,1] [,2] [,3] [1,] -4 -1 NA

Re: [R] Saving a 3d array into a matlab file

2008-10-28 Thread Henrik Bengtsson
Hi, On Tue, Oct 28, 2008 at 2:25 PM, Minho Chae [EMAIL PROTECTED] wrote: Dear R users, I am tryting to save an 3d array to a matlab file like the following. A - array(1:24, c(2,3,4)) writeMat(filename, A=A) But if I load the mat file from Matlab, it is not 3d matrix anymore. Does anyone

Re: [R] Help regarding oo package

2008-10-24 Thread Henrik Bengtsson
Hi, comments below. On Fri, Oct 24, 2008 at 1:47 PM, Aditya Udas [EMAIL PROTECTED] wrote: Hi Henrik, I'm sorry to be bothering you, but there is something that I have been stuck with for a while now. I am trying to create a class like : setConstructorS3(MyPTCM,function(tokenslist=0) {

Re: [R] R-code in Latex --- $ sign causes error

2008-10-17 Thread Henrik Bengtsson
Check out the 'fancyvrb' latex package - that is quite flexible and I wouldn't be surprised if it can help you. Make sure to read the docs (fancyvrb.pdf). /H On Fri, Oct 17, 2008 at 8:37 PM, erwann rogard [EMAIL PROTECTED] wrote: Thanks for clarifying. Yes, \$ works in latex, but not *within*

Re: [R] writeMat error

2008-10-01 Thread Henrik Bengtsson
Hi. On Sat, Sep 27, 2008 at 5:17 AM, Steele, Dr Douglas [EMAIL PROTECTED] wrote: Hi I am using Ubuntu 8.04 64 bit, R as below, Matlab 7.6.0. I would like to transfer mat files back and forward between R and Matlab. Whilst I have used Matlab for years its been a long time since I have

Re: [R] string to numeric question

2008-09-24 Thread Henrik Bengtsson
See ?sprintf, e.g. x2Str - sprintf(%02d, as.integer(x)) where 'x2' is numeric. Use x - as.numeric(xStr) to convert string 'xStr' to numeric and x - x + 1 to change the value. /HB On Wed, Sep 24, 2008 at 2:51 PM, [EMAIL PROTECTED] wrote: this seems l ike it shouldn't be that hard but i give

Re: [R] SmoothScatter plot range issue

2008-09-22 Thread Henrik Bengtsson
Hi, Bioconductor.org is the home of the geneplotter package. You get a quicker response if you ask there. /Henrik On Mon, Sep 22, 2008 at 7:06 AM, Jason Pare [EMAIL PROTECTED] wrote: Hello, I am attempting to use smoothScatter to plot a heatmap of locations of events in an x-y axis. When I

Re: [R] Newbie: Formatting numbers with commas

2008-09-22 Thread Henrik Bengtsson
x - c(123023,143494035); format(x, big.mark=,); [1] 123,023 143,494,035 format(x, big.mark=,, trim=TRUE); [1] 123,023 143,494,035 See also ?prettyNum (and formatC). /Henrik On Mon, Sep 22, 2008 at 9:23 PM, Matthew Pettis [EMAIL PROTECTED] wrote: Hi, Search through the R archives,

[R] Suggestion: Re: Fatal error .RData

2008-09-18 Thread Henrik Bengtsson
R-core, may I suggest that the error message returns the absolute path (or even the relative path) and not just the filename/basename, e.g. Fatal error: unable to restore saved data in C:/Users/foo/.RData /Henrik On Thu, Sep 18, 2008 at 6:41 AM, Green, Paul [EMAIL PROTECTED] wrote: We are

Re: [R] Suggestion: Re: Fatal error .RData

2008-09-18 Thread Henrik Bengtsson
Hi. On Thu, Sep 18, 2008 at 8:16 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 18/09/2008 10:55 AM, Henrik Bengtsson wrote: R-core, may I suggest that the error message returns the absolute path (or even the relative path) and not just the filename/basename, e.g. Fatal error: unable

Re: [R] detecting null values in a CSV file

2008-09-18 Thread Henrik Bengtsson
What have you tried this far? Can't you parse them as missing values, i.e. NAs? See ?read.csv and arguments '...', i.e. the arguments '...' are passed to read.table() which takes argument 'na.strings' - a character *vector* of strings that you want to be interpreted as NAs. See ?read.table for

Re: [R] reading in results from system(). There must be an easier way...

2008-09-18 Thread Henrik Bengtsson
On Thu, Sep 18, 2008 at 1:39 PM, Michael A. Gilchrist [EMAIL PROTECTED] wrote: Wow, that's elegant and simple. It's also faster than my approach. NB, you don't need to use close(), read.delim() closes the pipe when its done reading. If read.delim() close the connection in this case, it's a

Re: [R] How to find the index

2008-09-16 Thread Henrik Bengtsson
See ?order, ?sort, and possibly match(). Pay attention to the arguments provided. /Henrik On Tue, Sep 16, 2008 at 8:04 AM, Peng Jiang [EMAIL PROTECTED] wrote: Dear R experts, i have a vector z , i have to do something after z is sorted. how can i find the original index, i.e., before

Re: [R] reading in results from system(). There must be an easier way...

2008-09-12 Thread Henrik Bengtsson
Hi, a few comments below. On Fri, Sep 12, 2008 at 9:34 AM, Michael A. Gilchrist [EMAIL PROTECTED] wrote: Hello, I am currently using R to run an external program and then read the results the external program sends to the stdout which are tsv data. When R reads the results in it converts

Re: [R] tryCatch question

2008-09-12 Thread Henrik Bengtsson
On Fri, Sep 12, 2008 at 6:02 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I have a nested call of lapply in which I do a tryCatch statement like this lapply(1:length(p_names), function(w_idx) { r - as.numeric(pos_r[[w_idx]][1]) c - as.numeric(pos_c[[w_idx]][1]) pos -

Re: [R] Scatterplot with data grouped by color

2008-09-12 Thread Henrik Bengtsson
See argument 'col' to plot()/points(). Setup a 'col' vector of length equal to the number of data points and have the 'C' variable specify the colors of the individual elements. Then call plot()/points() with argument 'col'. My $.02 /HB On Fri, Sep 12, 2008 at 3:29 PM, Amanda Young [EMAIL

Re: [R] RSiteSearch for words ``as one entity''.

2008-09-11 Thread Henrik Bengtsson
me, especially (again) to Henrik Bengtsson cheers, Rolf ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help

Re: [R] How to load functions in R

2008-09-11 Thread Henrik Bengtsson
Wow... source() on a text file is the way to go - forget everything else. If you have multiple *.R script files, in a directory, say R/, you can load them all by: pathnames - list.files(pattern=[.]R$, path=R/, full.names=TRUE); sapply(pathnames, FUN=source); or even shorter:

Re: [R] Problem with dir.create in windows servers

2008-09-10 Thread Henrik Bengtsson
This sounds vaguely familiar to me. This could be reason for why I wrote mkdirs() of the R.utils package. mkdirs() does it's own (manual) recursive creation of directories. See if that does it for you. /Henrik On Wed, Sep 3, 2008 at 1:14 AM, Francisco Jose Sastre [EMAIL PROTECTED] wrote:

Re: [R] : writeMat

2008-09-10 Thread Henrik Bengtsson
know what. Thank you. On Tue, Sep 9, 2008 at 8:58 PM, Henrik Bengtsson [EMAIL PROTECTED] wrote: Hi, On Tue, Sep 9, 2008 at 9:53 AM, erola pairo [EMAIL PROTECTED] wrote: I write a .mat file using the writeMat() command, but when i try to load it in Matlab it says that file may

Re: [R] RSiteSearch for words ``as one entity''.

2008-09-10 Thread Henrik Bengtsson
Seems that one of the slashed is dropped after the protocol prefix, i.e. http:/search.r-project.org/... should be http://search.r-project.org/... Someone else has to take it from here. /Henrik On Wed, Sep 10, 2008 at 2:03 PM, Rolf Turner [EMAIL PROTECTED] wrote: I tried to search for a

Re: [R] RSiteSearch for words ``as one entity''.

2008-09-10 Thread Henrik Bengtsson
On Wed, Sep 10, 2008 at 3:09 PM, Marc Schwartz [EMAIL PROTECTED] wrote: on 09/10/2008 04:49 PM Rolf Turner wrote: On 11/09/2008, at 9:29 AM, Marc Schwartz wrote: on 09/10/2008 04:03 PM Rolf Turner wrote: I tried to search for a string of words ``as one entity'' following the example in the

Re: [R] Hardwarefor R cpu 64 vs 32, dual vs quad

2008-09-09 Thread Henrik Bengtsson
On Tue, Sep 9, 2008 at 6:31 AM, Nic Larson [EMAIL PROTECTED] wrote: Need to buy fast computer for running R on. Today we use 2,8 MHz intel D cpu and the calculations takes around 15 days. Is it possible to get the same calculations down to minutes/hours by only changing the hardware? Should I

Re: [R] binary order combinations

2008-09-05 Thread Henrik Bengtsson
names - sprintf(V%d, 1:4); n - length(names); stopifnot(n = 32); # Theoretical upper limit x - matrix(intToBits(1:(2^n-1)), ncol=2^n-1); x - x[1:n,,drop=FALSE]; keys - apply(x, MARGIN=2, FUN=function(z) paste(names[as.logical(z)], collapse=:)); print(keys); [1] V1 V2 V1:V2

Re: [R] saving an object

2008-09-04 Thread Henrik Bengtsson
Alternatively you can use saveObject() and loadObject() of R.utils - that will not hardwire the name of the loaded object avoiding name conflicts, e.g. library(R.utils); foo - 1:10; saveObject(foo, file=foo.RData); bar - loadObject(foo.RData); /HB On Thu, Sep 4, 2008 at 8:44 AM, Williams, Robin

Re: [R] algorithm to create unique identifiers

2008-09-04 Thread Henrik Bengtsson
On Thu, Sep 4, 2008 at 8:44 PM, Ralph S. [EMAIL PROTECTED] wrote: Hi all, I am trying to create a unique identifier for each row, combining numbers from three columns. Do you know if there is a general formula to do this (or some manual where I can read about this)? I figure I can use

Re: [R] Odp: optimizing speed of calculation (recursive product)

2008-09-03 Thread Henrik Bengtsson
Note: n - 100; x - rnorm(n); t1 - system.time({ xp - prod(x); xpA2 - xp/x[n]; xpB2 - xp/x[1]; }); is calculating the product only once and is *constant in memory*. With the suggest approach you are not only calculating the same thing twice but you are also allocating a lot of memory,

Re: [R] Notice

2008-08-28 Thread Henrik Bengtsson
On Thu, Aug 28, 2008 at 10:42 AM, stephen sefick [EMAIL PROTECTED] wrote: WHAT is this in reguard too? It seems to be a message from another universe (SAS something) - maybe a wormhole? Are we not alone? /H On Thu, Aug 28, 2008 at 12:56 PM, Ajay ohri [EMAIL PROTECTED] wrote: For the

[R] Windows Vista, Rterm LeftAlt + Tab issue

2008-08-21 Thread Henrik Bengtsson
Hi, my Rterm does not longer take key presses after I have pressed Left Alt+Tab in order to switch away from an active Rterm window. I have found a way to get Rterm to respond again. I basically have to kill the process. This occurs on a fresh Windows Vista Business 32-bit installation (with

Re: [R] How I can read the binary file with different type?

2008-08-21 Thread Henrik Bengtsson
Wow, one of those might binary file format likely to be dumped from memory by a C/C++ program. ...anyway, here is how I deal with interveawed data types: # Read all of the file as raw (bytes) values fileSize - file.info(pathname)$size; raw - readBin(pathname, what=raw, n=fileSize); # Sanity

Re: [R] jpeg, dev.off() inside function

2008-08-19 Thread Henrik Bengtsson
In your function, split up your code in two lines as: pathname - paste(test , deparse(substitute(series)), i, .jpg); jpeg(filename=pathname, width=1200, height=800, pointsize=12, quality=400, bg=white); The focus on what 'pathname' is/becomes when you put it inside your function. That will help

Re: [R] exonmap question: rma (or justplier) crashes

2008-08-18 Thread Henrik Bengtsson
Hi, this is clearly a Bioconductor-specific issue. Please post your question to the Bioconductor mailing list instead. /Henrik On Mon, Aug 18, 2008 at 12:20 AM, Tae-Hoon Chung [EMAIL PROTECTED] wrote: Hi, All; I simply followed the exonmap vignette but came up with an unexpected error.

Re: [R] how to override/replace a function in a package namespace?

2008-08-18 Thread Henrik Bengtsson
/Henrik On Mon, Aug 18, 2008 at 8:10 AM, Ben Bolker [EMAIL PROTECTED] wrote: Henrik Bengtsson hb at stat.berkeley.edu writes: The few times I want to patch a function like this, I use: unlockBinding(name, env); assignInNamespace(name, value, ns=pkgName, envir=env); assign(name, value

Re: [R] use expression() in a loop

2008-08-18 Thread Henrik Bengtsson
...or use the more generic substitute() to replace parts of an expression, e.g. i - 3; xlab1 - substitute(g[idx], list=list(idx=i)); xlab2 - bquote(g[.(i)]); stopifnot(identical(xlab1, xlab2)); /Henrik On Mon, Aug 18, 2008 at 3:18 PM, Marc Schwartz [EMAIL PROTECTED] wrote: on

Re: [R] problem with save function

2008-08-18 Thread Henrik Bengtsson
...and see saveObject() and loadObject() in R.utils, which might do what you expected, e.g. x - stats::runif(20) y - list(a=1, b=TRUE, c=oops) saveObject(list(foo=x,bar=y), xy.Rdata) xy - loadObject(xy.Rdata) str(xy) List of 2 $ foo: num [1:20] 0.1154 0.6534 0.0876 0.5977 0.6841 ... $

Re: [R] how to override/replace a function in a package namespace?

2008-08-17 Thread Henrik Bengtsson
The few times I want to patch a function like this, I use: unlockBinding(name, env); assignInNamespace(name, value, ns=pkgName, envir=env); assign(name, value, envir=env); lockBinding(name, env); /Henrik On Sun, Aug 17, 2008 at 10:50 AM, Gabor Grothendieck [EMAIL PROTECTED] wrote: In

Re: [R] Convert text string to object pointer

2008-08-15 Thread Henrik Bengtsson
See the Object class in the R.oo package. /Henrik On Thu, Aug 14, 2008 at 7:35 PM, Abiel Reinhart [EMAIL PROTECTED] wrote: I would like to use a text string to get a reference to an object whose name is the text string. I have seen people using get() for this purpose, but as far as I can tell

Re: [R] Saving environment object

2008-08-15 Thread Henrik Bengtsson
On Fri, Aug 15, 2008 at 6:43 AM, Benjamin Otto [EMAIL PROTECTED] wrote: Hi Erik, Yes this is what I was trying and your example or the one of luke is working fine with me. So now I'm not sure if this is due to an environment which takes too much space. The environment troubling me has

Re: [R] Department of Redundancy Department.

2008-08-14 Thread Henrik Bengtsson
Hmm, couldn't resists: X - NA is.logical(X) [1] TRUE (X == TRUE) [1] NA ==.MaybeNA - function(e1, e2) { !is.na(e1) (e1 == e2) } X - structure(NA, class=MaybeNA) is.logical(X) [1] TRUE (X == TRUE) [1] FALSE Ta da ;) Henrik PS. It might be worth mentioning base::isTRUE() when we're

Re: [R] ignoring zeros or converting to NA

2008-08-13 Thread Henrik Bengtsson
FYI, there is an isZero() in the R.utils package that allows you to specify the precision. It looks like this: isZero - function (x, neps=1, eps=.Machine$double.eps, ...) { (abs(x) neps*eps); } /Henrik On Wed, Aug 13, 2008 at 8:23 AM, Roland Rau [EMAIL PROTECTED] wrote: Hi, since many

Re: [R] Determining cause of error?

2008-08-13 Thread Henrik Bengtsson
See ?traceback /Henrik On Wed, Aug 13, 2008 at 7:33 PM, [EMAIL PROTECTED] wrote: This is both a specific question and a general one. First, I am running 'fitdistr' from library(MASS) and I get the following: Error in fitdistr(templist, weibull) : optimization failed What is the cause of

Re: [R] tilde on a spanish keyboard?

2008-08-12 Thread Henrik Bengtsson
Since as long as I can remember, on Windows there is something called Alt [Key Numeric] Codes, which allows you to enter many symbols that are not directly accessible via a single key, cf. http://en.wikipedia.org/wiki/Alt_codes For lists of Alt codes, see for instance

Re: [R] Senging commands to the GUI in Windows through a script

2008-08-12 Thread Henrik Bengtsson
With AutoIt [http://www.autoitscript.com/] you can setup scripts that send keyboard and mouse events, wait for windows to open and more. It is quite powerful. /Henrik On Tue, Aug 12, 2008 at 4:51 AM, [EMAIL PROTECTED] wrote: OK thanks, Tolga Prof Brian Ripley [EMAIL PROTECTED] 12/08/2008

Re: [R] which(df$name==A) takes ~1 second! (df is very large), but can it be speeded up?

2008-08-12 Thread Henrik Bengtsson
To simplify: n - 2.7e6; x - factor(c(rep(A, n/2), rep(B, n/2))); # Identify 'A':s t1 - system.time(res - which(x == A)); # To compare a factor to a string, the factor is in practice # coerced to a character vector. t2 - system.time(res - which(as.character(x) == A)); # Interestingly enough,

Re: [R] Naming dataframes, vectors etc within a loop

2008-08-12 Thread Henrik Bengtsson
See help(list) and help([[) ...and 'An Introduction to R'. /Henrik On Tue, Aug 12, 2008 at 7:49 PM, Gareth Campbell [EMAIL PROTECTED] wrote: Hi there, I know this is probably a really simple question, but without the correct keywords, or knowledge of the correct function it is hard to search

Re: [R] max size of a matrix

2008-08-05 Thread Henrik Bengtsson
Are you aware that that matrix will have 147456^2 elements each of size 8 bytes (double) resulting in R trying to allocate (147456^2)*8/1024^3 = 162 GB of RAM? If you are aware of this and still trying to allocate a large matrix, it is unfortunately too large due to technical limitations in R.

Re: [R] Create data frame from header only

2008-08-04 Thread Henrik Bengtsson
See dataFrame() in R.utils. It was design for the purpose of allocating empty data frames in an efficient way. Example: library(R.utils); df - dataFrame(colClasses=c(a=integer, b=double), nrow=10); str(df) 'data.frame': 10 obs. of 2 variables: $ a: int 0 0 0 0 0 0 0 0 0 0 $ b: num 0 0

Re: [R] RE SHAPE package question.

2008-08-02 Thread Henrik Bengtsson
On Sat, Aug 2, 2008 at 3:56 PM, hpdutra [EMAIL PROTECTED] wrote: That works. I still think you should have named RESHAPE as MAGIC! It is amazing how much of a time-saver this tool is! Following that suggest would make it even harder for you to find the package you're looking for - there are

Re: [R] Case statements in R

2008-07-28 Thread Henrik Bengtsson
Hi. On Mon, Jul 28, 2008 at 11:21 AM, Ted Harding [EMAIL PROTECTED] wrote: On 28-Jul-08 17:52:31, Henrik Bengtsson wrote: Use '' for vectors and '' for scalars. Ditto applies to the OR operator(s). /Henrik What's wrong with using for scalars? Surely it gives the correct answer? Maybe

Re: [R] Is there a way to avoid loading dependendent packages?

2008-07-28 Thread Henrik Bengtsson
On Mon, Jul 28, 2008 at 4:29 PM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 28/07/2008 6:42 PM, [EMAIL PROTECTED] wrote: Hello R help list I have been using the smoothScatter function within the geneplotter package to make some graphs using a Sweave Rnw script called via Rscript in a

Re: [R] Are there any packages that can process images other than pixelmap (i.e. pnm)?

2008-07-27 Thread Henrik Bengtsson
See EBImage on Bioconductor.org. /Henrik On Sun, Jul 27, 2008 at 10:21 PM, Arthur Roberts [EMAIL PROTECTED] wrote: Hi, all, I am having trouble getting R to take pnm images via mogrify i.e. mogrify -resize 320x217 -format pnm *.png However R via pixmap says that it can't read the file.

<    1   2   3   4   5   6   >