Re: [R] ff usage for glm

2012-04-02 Thread Benilton Carvalho
Did you try the example described on the ff man page? On Monday, April 2, 2012, Bond, Stephen wrote: > Thomas, > > I tried biglm and it does not work see > > > http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-td2276524.html#a2278381 > > . There are other posts from pe

Re: [R] ff usage for glm

2012-03-30 Thread Benilton Carvalho
you want to check the ff man page (?ff), there is an example described there with biglm. b On 30 March 2012 21:05, Bond, Stephen wrote: > Greetings useRs, > > Can anyone provide an example how to use ff to feed a very large data > frame to glm? > The data.frame cannot be loaded in R using conven

Re: [R] RSqlite UPDATE command problem

2012-03-27 Thread Benilton Carvalho
You probably want: sql<-"UPDATE testtable SET vals=21 WHERE countries='NewZealand'" dbGetQuery(con, sql) instead... b On 27 March 2012 14:18, Thomas Adams wrote: > All: > > I am using RSqlite and want to be able to update individual values in a > record, such as with this simple example: > >

Re: [R] read.csv and field containing single quotes

2012-03-27 Thread Benilton Carvalho
t;, gsub('^\"|\"$', "'", > readLines('../teste.csv', sep = ',', quote = "'", header = TRUE) > > On Mon, Mar 26, 2012 at 8:09 PM, Benilton Carvalho > wrote: > > I need to read in csv files, created by 3rd party, with

[R] read.csv and field containing single quotes

2012-03-26 Thread Benilton Carvalho
I need to read in csv files, created by 3rd party, with fields containing single quotes (as shown below). "header1","header2","header3","header4" "field1r1","field2r1","field3r1","field4r1" "field1r2","field2r2","field3r2PartA), field3r2PartB Very" Long","field4r2" "field1r3","field2r3","field3r3"

Re: [R] Efficient access to elements of a list of lists

2012-03-11 Thread Benilton Carvalho
Thanks Henrik!!! Hope to pay your beer soon. :) b __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-containe

[R] Efficient access to elements of a list of lists

2012-03-11 Thread Benilton Carvalho
Hi, I have a long list of lists from which I want to efficiently extract and rbind elements. So I'm using the approach below: f <- function(i){ out <- replicate(5, list(matrix(rnorm(80), nc=20))) names(out) <- letters[1:5] out } set.seed(1) lst <- lapply(1:1.5e6, f) (t0 <- system.tim

Re: [R] extracting the i-th row of a matrix in a list of lists

2012-03-09 Thread Benilton Carvalho
Hi Chuck, thank you *very* much! That really helped! b On 9 March 2012 17:15, wrote: > Benilton Carvalho writes: > >> Hi, >> >> what is the proper of of "passing a missing value" so I can extract >> the entire i-th row of a matrix (in a list of lists

[R] extracting the i-th row of a matrix in a list of lists

2012-03-09 Thread Benilton Carvalho
Hi, what is the proper of of "passing a missing value" so I can extract the entire i-th row of a matrix (in a list of lists) without pre-computing the number of cols? For example, if I know that the matrices have 2 columns, I can do the following: set.seed(1) x0 <- lapply(1:10, function(i) repli

Re: [R] assigning NULL to a list element

2012-02-18 Thread Benilton Carvalho
Thanks guys... I'm already embarrassed given how simple the solutions are. b On Saturday, 18 February 2012, Hadley Wickham wrote: > On Fri, Feb 17, 2012 at 7:51 PM, Benilton Carvalho > > wrote: > > Hi everyone, > > > > For reasons beyond the scope of this messag

Re: [R] assigning NULL to a list element

2012-02-17 Thread Benilton Carvalho
Hi Mark, thank you very much! This is perfect! Naive from my part not thinking of c()... Cheers, b __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide

Re: [R] assigning NULL to a list element

2012-02-17 Thread Benilton Carvalho
Thank you very much, David. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

[R] assigning NULL to a list element

2012-02-17 Thread Benilton Carvalho
Hi everyone, For reasons beyond the scope of this message, I'd like to append a NULL element to the end of a list. tmp0 <- list(a=1, b=NULL, c=3) append(tmp0, c(d=4)) ## works as expected append(tmp0, c(d=NULL)) ## list with a/b/c only Given that I could use tmp0$a <- NULL to remove 'a', I see

Re: [R] make: Nothing to be done for `all'.

2010-05-12 Thread Benilton Carvalho
Have you removed the *.so and *.o files prior to "R CMD SHLIB hello.c"? b On Tue, May 11, 2010 at 11:39 PM, Elizabeth Lawson wrote: > I recently bought a new macbook pro 10.6.3 and I am trying to compile some C > code I have.  I reinstalled R and Xcode on the Mac but I keep running into > the sa

Re: [R] reduce size of pdf

2010-04-30 Thread Benilton Carvalho
or possibly use smoothScatter() to produce the scatter plots On Fri, Apr 30, 2010 at 12:06 PM, ONKELINX, Thierry wrote: > Dear Nevil, > > Converting your pdf to png will be the most efficient way to reduce the > file size with scatter plots. > > You can either export directly to pdf or first

Re: [R] macro variable in R?

2010-04-22 Thread Benilton Carvalho
maybe for (i in 1:10) assign(paste("matrix", i, sep="_"), matrix(nrow=i, ncol=i)) suffices? On Thu, Apr 22, 2010 at 5:08 PM, karena wrote: > > I need to create 10 matrices. say matrix 1-10. > > matrix_1 is 1 by 1 > matrix_2 is 2 by 2 > matrix_3 is 3 by 3 >   . >   . >   . > matrix_10 is 10 by 1

Re: [R] SAS like Macro variable substituion?

2010-04-12 Thread Benilton Carvalho
save(list=paste("unislopes", master.i, sep=""), file=paste("unislopes",master.i,".Rdata",sep="")) On Mon, Apr 12, 2010 at 12:06 PM, David Young wrote: > I'd like to use a string to refer to an R object with the end > objective of going through a loop and saving various files of the same > name wi

Re: [R] Help transfrom R to C

2010-04-07 Thread Benilton Carvalho
maybe inc.freqy <- sapply(unit.dist, function(x) rowSums( test <= x)) suffices? b On Mon, Apr 5, 2010 at 5:31 PM, pinusan wrote: > > Dear R users, > > I would like to transform the following "for loop" from R-code to C-code > because it takes really long time to have inc.freqy table. > Unfortu

Re: [R] Weird R behaviour?

2010-03-31 Thread Benilton Carvalho
FAQ 7.31: Why doesn't R think these numbers are equal? http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f b On Wed, Mar 31, 2010 at 10:10 AM, Gianluca Baio wrote: > Dear list, > I have observed a weird behaviour from R --- apologies if I am missing

Re: [R] using a list to index elements of a list

2010-03-23 Thread Benilton Carvalho
and in addition to bill's suggestion, you may want to consider not growing a list. Instead of 'v <- list()', use: v <- vector("list", nrow(A)) b > Will your code work as you wish if you > replace the "for(v[[1]] in x[[1]]) { ... }" > with the following? >   for(i in x[[1]]) { >      v[[2]] <- i

Re: [R] using a list to index elements of a list

2010-03-23 Thread Benilton Carvalho
can you also post an example of A and an example of the expected result? On Tue, Mar 23, 2010 at 3:36 PM, Pj253 wrote: > > Thanks for your reply Ben! > > I don't think I want v to be identical to x... I guess I haven't put the > question in the right context. What I'm actually trying to do is...

Re: [R] using a list to index elements of a list

2010-03-23 Thread Benilton Carvalho
if this was to work, wouldn't the object 'v' be identical to 'x'?... so, why not use 'x' itself? b On Tue, Mar 23, 2010 at 2:53 PM, Pj253 wrote: > > I have a list of vectors, x, with x[[1]]=1:5, say. > > And I need to go through each element of each vector in a for loop. > Something like: > > for

Re: [R] Accessing data in groups created with split() and other beginner questions

2010-03-22 Thread Benilton Carvalho
To access elements of a list (object returned by split), you need to use "[[". Therefore, summary(temp[[1]]) is what you meant to use (or even summ = lapply(temp, summary) - which will give you the summaries for every subject). About using PDFs, I'd recommend you to take a look at Sweave ( http

Re: [R] Stacking matrices

2010-03-15 Thread Benilton Carvalho
how about y = X[rep(1:nrow(X), 6), ] ? On Mon, Mar 15, 2010 at 5:37 PM, wrote: > What is an easy way to stack a matrix multiple times?  E.g.  I have a 6x6 > matrix that I need to stack vertically 154 times to get a 6*154 by 6 > matrix.  I would rather not rbind(X,X,...,X) matrices.    --Joe >

Re: [R] storing matrix(variables) in loop

2010-03-15 Thread Benilton Carvalho
If you could describe exactly what is it that you're trying to accomplish, we could be of better help (the reason I say this is because the way you're trying to implement things is a bit inefficient). Anyways, you can't use two indices with a list. One approach would be to nest lists, and you'd g

Re: [R] difference between date and times

2010-02-23 Thread Benilton Carvalho
dd = as.POSIXlt(c("2007-02-21 05:19:00", "2007-02-20 14:21:53"), format="%Y-%m-%d %H:%M:%S") dd[1]-dd[2] b On Tue, Feb 23, 2010 at 2:48 PM, karine heerah wrote: > > Hi, > > > > I have date and time in a format like this: " 2007-02-21 05:19:00". > > Do you which function i can use to derterminat

Re: [R] deleting column from data frame

2010-02-23 Thread Benilton Carvalho
i'd use: test[["Y"]] <- NULL b On Tue, Feb 23, 2010 at 4:13 PM, adam naples wrote: > try > > test <- subset(test, select = -c(Y)) > > The key is the  minus sign before c() in the select argument. > You can put in as many columns as you like. > -a > > On Feb 23, 2010, at 11:02 AM, David Winsemiu

Re: [R] gsub patterns from vector elements w/out loop?

2010-02-22 Thread Benilton Carvalho
gsub("one|two", "something else", y) ? On Mon, Feb 22, 2010 at 4:25 PM, Marianne Promberger wrote: > Dear list, > > I have two vectors: > > x <- c("one","two") > y <- paste(rep(x,2),"blah") > > I want to replace all occurrences of each element of x in y with > something else, so that y looks lik

Re: [R] rownames cannot allocate vector of size

2010-02-22 Thread Benilton Carvalho
assigning rownames (after the object is created) triggers a copy of the object... if you assign the rownames at creation time, no extra copies... b On Mon, Feb 22, 2010 at 9:46 AM, Larson, TR wrote: > Hi, > > On R 2.10.1 for Windows, when I do the following to duplicate the structure > of a larg

Re: [R] Matrix in a Reverse order

2010-02-18 Thread Benilton Carvalho
x[nrow(x):1,] b On Thu, Feb 18, 2010 at 11:45 AM, Amelia Livington wrote: > Dear 'R' friends > > I have a sort of stupid question to ask. > > I have a matrix say of the order 4 X 3 as > > 83    98    90 > 21    83    84 > 70    39    56 > 65    29    38 > > Is there any command in R which will r

Re: [R] array question

2010-02-17 Thread Benilton Carvalho
you mean something along the lines of filter(x, rep(1/4, 4)) (which you can combine with na.omit) ? On Wed, Feb 17, 2010 at 5:18 PM, Mohsen Jafarikia wrote: > Hello All: > > If I do have: > > x = (2, 4, 5, 5, 6, 4, 5, 2, 1) > y = (9, 11.5, 12.5, 13, 14, 19, 20, 21, 22) > > I wanted to find a s

Re: [R] PLEASE HELP!!! Total and heading of portfoilo table

2010-02-16 Thread Benilton Carvalho
say you read the quantity.csv file into a variable called 'quantity'... similarly, 'equity_price.csv' to equity. sweep(equity, 2, quantity, "*") b On Tue, Feb 16, 2010 at 11:20 AM, Sarah Sanchez wrote: > Dear Madam / R helpers, > > Unfortunately the solution you have suggested is not working in

Re: [R] Adressing multiple cores (CPUs)

2010-02-15 Thread Benilton Carvalho
http://cran.r-project.org/web/views/HighPerformanceComputing.html 2010/2/15 : > Dear all, > > I'm sitting here just in front of my new p...@work and wonder about the > following question: >        * How can I adress multiple CPUs (cores) out of R to speed up the > simulations I run? >        *

Re: [R] CORRECTION - Storing results in a loop

2010-02-15 Thread Benilton Carvalho
lation and for that I need to calculate LN(New rate / old >> rate for each of the instrument separately). >> >> Here is my actual code - >> >> ONS = read.csv('Instrument.csv') >> n = length(ONS) >> Y = NULL >> B = array() >> >> for

Re: [R] CORRECTION - Storing results in a loop

2010-02-15 Thread Benilton Carvalho
sorry, meant to type: B = ONS^2 cheers, benilton On Mon, Feb 15, 2010 at 12:28 PM, Benilton Carvalho wrote: > maybe you just want > > Y = ONS^2 > > ? > > b > > On Mon, Feb 15, 2010 at 12:22 PM, Madhavi Bhave > wrote: >> Dear R Helpers >> >> (Th

Re: [R] CORRECTION - Storing results in a loop

2010-02-15 Thread Benilton Carvalho
maybe you just want Y = ONS^2 ? b On Mon, Feb 15, 2010 at 12:22 PM, Madhavi Bhave wrote: > Dear R Helpers > > (There is a small correction in my earlier mail. In the 'instrument.csv' > file, I had mentioned only three columns. Actually there are 7 columns. I > regret the error. Rest contents

Re: [R] Access variables by string

2010-02-11 Thread Benilton Carvalho
On Thu, Feb 11, 2010 at 4:18 PM, Philipp Rappold wrote: > Dear all, > > I have two probably very easy questions: > > (1) Is there a way to access certain variables by their string-based name > representation? > > Example: > numbers <- c("one", "two", "three") > varname <- "numbers" > print(varname

Re: [R] question about bigmemory: releasing RAM from a big.matrix that isn't used anymore

2010-02-06 Thread Benilton Carvalho
Hi Matt, what's your sessionInfo()? Can you try installing bigmemory as follows: install.packages("bigmemory", repos="http://R-Forge.R-project.org";) it'll get you the latest version, in which I cannot reproduce the problem you're reporting (ie, after gc(), I get all the RAM back) b On Sat, Fe

Re: [R] maximum elements in an ff object?

2010-02-05 Thread Benilton Carvalho
u can use other aproaches to fill in the ff dataframe b On Fri, Feb 5, 2010 at 11:43 PM, Benilton Carvalho wrote: > Hi Matt, > > you're correct: length(ffObject) must be smaller than 2^31-1... at > least until R has a 64bit integer type, it seems... > > in the meantime

Re: [R] maximum elements in an ff object?

2010-02-05 Thread Benilton Carvalho
Hi Matt, you're correct: length(ffObject) must be smaller than 2^31-1... at least until R has a 64bit integer type, it seems... in the meantime, use the bigmemory package. ;-) b On Fri, Feb 5, 2010 at 4:18 PM, Matthew Keller wrote: > Hello all, > > I hate to add to the daily queries regarding

Re: [R] large integers in R

2010-01-28 Thread Benilton Carvalho
On Thu, Jan 28, 2010 at 11:21 AM, Duncan Murdoch wrote: > On 28/01/2010 5:30 AM, Benilton Carvalho wrote: >> >> Hi Duncan, >> >> On Tue, Jan 26, 2010 at 9:09 PM, Duncan Murdoch >> wrote: >>> >>> On 26/01/2010 3:25 PM, Blanford, Glenn wrote:

Re: [R] large integers in R

2010-01-28 Thread Benilton Carvalho
nge soon and we were to have 64bit integer type (say, when under a 64 bit OS), wouldn't this allow us to have objects whose length exceeded the 2^31-1 limit? Benilton Carvalho > The double type in R can hold exact integer values up to around 2^52. So for > example calculations like

Re: [R] summing a large, partitioned data frame

2010-01-25 Thread Benilton Carvalho
check aggregate() (the examples are quite helpful) b On Mon, Jan 25, 2010 at 4:07 PM, wrote: > Dear R community, > I'm trying to develop a fast way of summing specific rows of a large data > frame. > Here is an example of the kind of data frames I'm dealing with: > >> refls > H K L M/I

Re: [R] How to calculate the row wise means for grouped columns in matrix?

2010-01-15 Thread Benilton Carvalho
adapted from the help files of rowsum x <- matrix(runif(100), ncol=5) group <- sample(1:8, 20, TRUE) xsum <- rowsum(x, group) sweep(xsum, 1, table(group), "/") or aggregate(x, list(group), mean)[-1] b 2010/1/15 Joel Fürstenberg-Hägg : > > Hi all, > > > > I want to calculate the row wise mean o

Re: [R] processing all files with certain extension in a directory

2010-01-15 Thread Benilton Carvalho
theFiles <- list.files(inputdir, full=T, pattern="\\.[eE][xX][tT]$") for (file in theFiles){ ... } On Fri, Jan 15, 2010 at 11:43 AM, Albert Vilella wrote: > Hi all, > > I'm trying to process all files with a certain extension "*.ext" in a > directory like this: > >> R --slave --args /my/dir < di

Re: [R] how to do multiple responses in a linear regression

2009-12-24 Thread Benilton Carvalho
you need to be more clear on your question... what is it (exactly) that you want? Is it the following? y1 ~ x1 + ... + xm y2 ~ x1 + ... + xm ... yn ~ x1 + ... + xm ? if so: lm(cbind(y1, y2, ..., yn) ~ x1+x2+...+xm) b On Dec 24, 2009, at 3:33 PM, Hao Cen wrote: > Hi, > > I have multiple res

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

2009-12-23 Thread Benilton Carvalho
replace data[1:i,] by data[1:i,drop=FALSE]. b On Dec 24, 2009, at 12:46 AM, Francesco Napolitano 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): > > for(i in

Re: [R] problem with a densityplot

2009-12-16 Thread Benilton Carvalho
instead of densityplot(...) use print(densityplot(...)) b On Dec 16, 2009, at 3:19 PM, c...@autistici.org wrote: > Hi, > i have a script how i launch lattice to make a densityplot. > in the script: > > jpeg(file="XXX.jpg") > densityplot(~f_diametro+m_diametro+n_diametro, plot.points="rug", > a

Re: [R] Is there lazy copy in R?

2009-12-14 Thread Benilton Carvalho
use tracemem() to figure out... and read its documentation in detail. b On Dec 15, 2009, at 1:03 AM, Peng Yu wrote: > I'm wondering if lazy copy is available in R or not. For example, in > the following code, I'm wondering if the memory for y is allocated in > the 2nd line or the 3rd line. Is th

Re: [R] extracting vectors from lists of lists

2009-12-11 Thread Benilton Carvalho
oh.. and i just saw the bonus part... just replace lapply() by sapply(). b On Dec 11, 2009, at 8:33 PM, Jennifer Young wrote: > Good evening > > I often have as output from simulations a list of various values, vectors > and matrices. > Supposing that I then run said simulation several times, I

Re: [R] extracting vectors from lists of lists

2009-12-11 Thread Benilton Carvalho
lapply(output, "[[", "vec") b On Dec 11, 2009, at 8:33 PM, Jennifer Young wrote: > Good evening > > I often have as output from simulations a list of various values, vectors > and matrices. > Supposing that I then run said simulation several times, I often want to > extract a particular result

Re: [R] Converting a Matrix in a colum vector

2009-12-04 Thread Benilton Carvalho
matrix(t(G), nc=1) b On Dec 4, 2009, at 1:19 PM, Jose Narillos de Santos wrote: > Hi all, > > Imagine I have a matrix G > > with N rows > > and M columns > > So L=NxM is the number of different cells in my matrix. > > I want to create a column vector F whose size will be F(L,1) > > So the

Re: [R] Using two (...) in a function

2009-12-01 Thread Benilton Carvalho
isn't it simpler just to pass two vectors, say v1 and v2, in which one contains the object names and the other has the associated variances? (btw, "data" isn't a good function name) myData <- function(v1, v2){ Vec <- matrix(v1) varF <- v2 } I may have misunderstood your question, but IMHO a

Re: [R] How to: highlight R syntax on webpages ?

2009-11-20 Thread Benilton Carvalho
take a look at geshi. b On Nov 20, 2009, at 4:26 PM, Tal Galili wrote: My question if in the Subject, but if to extend: I am specifically curious about WordPress blogs. But any solution will give me a lead. Thanks, Tal -- Contact me: tal.gal...@gm

Re: [R] read a file into a matrix

2009-11-20 Thread Benilton Carvalho
I can't think of anything that is already built in. But you can always: read.as.matrix <- function(...) as.matrix(read.delim(...)) and now you get one step only ;-) b On Nov 20, 2009, at 4:01 PM, Peng Yu wrote: On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou wrote: read.delim gives me a

Re: [R] Importing tRNA data into R ?

2009-11-18 Thread Benilton Carvalho
readFASTA in the BioConductor Biostrings package. b On Nov 18, 2009, at 8:14 AM, Tal Galili wrote: Hello dear R help group, I would like to download the tRNA data on: http://gtrnadb.ucsc.edu/download.html And then import it into R. Can anyone direct me as to how to do so? Thanks, Tal -

Re: [R] :Problem with Looping

2009-11-17 Thread Benilton Carvalho
it doesn't skip... think about why: seq(.30,.5,.01) * 100 - 29 == 1:21 isn't always TRUE. b On Nov 17, 2009, at 9:17 PM, Bruno Giovannetti wrote: Hello, Sometimes the looping (using "for") seems to skip some iterations. An example: arg <- matrix(NA,length(seq(.30,.5,.01)),1) for (i in se

Re: [R] Simple if else statement problem

2009-11-13 Thread Benilton Carvalho
align the else with the curly brackets if (yes){ be happy }else{ complain } b On Nov 13, 2009, at 3:33 PM, anna_l wrote: Hello, I am getting an error with the following code: if( P2 > P1) + { + P<-P2 + } else Erro: unexpected 'else' in "else" { + P<-P1 + } I checked the syntax so I don´

Re: [R] Error: cannot allocate vector of size 3.4 Gb

2009-11-11 Thread Benilton Carvalho
ready for the next release. If you're trying to run RMA on your data, I can think of ways of working around this problem. Cheers, b On Nov 7, 2009, at 5:46 PM, Benilton Carvalho wrote: ok, i'll take a look at this and get back to you during the week. b On Nov 7, 2009, at 1:19 PM

Re: [R] R process gets killed spontaneously

2009-11-10 Thread Benilton Carvalho
Hi Peng, in a very simplistic manner, what happens is that the Operating System "thinks" it is too dangerous to let the R process to use so much memory. So, to protect the whole system, it kills R, before the system becomes unstable. I've been looking at the problem you observed last week

Re: [R] Error: cannot allocate vector of size 3.4 Gb

2009-11-07 Thread Benilton Carvalho
ok, i'll take a look at this and get back to you during the week. b On Nov 7, 2009, at 1:19 PM, Peng Yu wrote: Most of the 8GB was available, when I run the code, because R was the only computation session running. On Sat, Nov 7, 2009 at 7:51 AM, Benilton Carvalho wrote: you ha

Re: [R] Error: cannot allocate vector of size 3.4 Gb

2009-11-07 Thread Benilton Carvalho
ave enough resources when trying to read. best, b On Nov 7, 2009, at 10:12 AM, Peng Yu wrote: On Fri, Nov 6, 2009 at 8:19 PM, Benilton Carvalho wrote: this is converging to bioc. let me know what your sessionInfo() is and what type of CEL files you're trying to read, additionall

Re: [R] convert list to numeric

2009-11-01 Thread Benilton Carvalho
it appears that what you really want is to use: task[[i]] instead of task[i] b On Nov 1, 2009, at 11:04 PM, dadrivr wrote: I would like to preface this by saying that I am new to R, so I would ask that you be patient and thorough, so that I'm not completely clueless. I am trying to con

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

2009-10-28 Thread Benilton Carvalho
or unlist(l) and possibly you want a unique() on that... b On Oct 28, 2009, at 5:15 PM, Jorge Ivan Velez wrote: Hi Peng, Here is a suggestion: unique(do.call(c, l)) # [1] 1 3 4 6 7 Best regards, Jorge On Wed, Oct 28, 2009 at 3:07 PM, Peng Yu <> wrote: Suppose that I have a list of ve

Re: [R] regression on large file

2009-10-28 Thread Benilton Carvalho
bigmemory and biglm packages may be of your interest. b On Oct 28, 2009, at 8:50 AM, Georg Ehret wrote: Dear R community, I have a fairly large file with variables in rows. Every variable (thousands) needs to be regressed on a reference variable. The file is too big to load into R (or R ge

Re: [R] How to clear colnames?

2009-10-27 Thread Benilton Carvalho
colnames(x) <- NULL On Oct 27, 2009, at 8:09 PM, Peng Yu wrote: I only see how to assign values to colnames() in help. Is there a way to remove colnames? colnames(x) <- value __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo

Re: [R] How to make R packages?

2009-10-22 Thread Benilton Carvalho
Maybe http://cran.r-project.org/doc/manuals/R-exts.pdf ? b On Oct 23, 2009, at 2:10 AM, Peng Yu wrote: I found the following document on making R packages. But it is old. I'm wondering if there is more current ones and hopefully more complete ones. http://biosun1.harvard.edu/courses/individ

Re: [R] PDF too large, PNG bad quality

2009-10-22 Thread Benilton Carvalho
Dear Lasse, This won't answer your specific questions and I apologize for that. AFAIK, pdf() produces uncompressed PDFs only. But you could use tools like pdftk to compress your PDFs. About the PNGs, you can always set the 'res' argument to improve resolution, but it won't beat the PDFs.

Re: [R] How to average subgroups in a dataframe? (not sure how to apply aggregate(..))

2009-10-21 Thread Benilton Carvalho
aves = aggregate(df1$score, by=list(col1=df1$col1, col2=df1$col2), mean) results = merge(df1, aves) b On Oct 21, 2009, at 9:03 AM, Tony Breyal wrote: Dear all, Lets say I have the following data frame: set.seed(1) col1 <- c(rep('happy',9), rep('sad', 9)) col2 <- rep(c(rep('alpha', 3), rep('

Re: [R] Cacheing computationally expensive getter methods for S4 objects

2009-10-14 Thread Benilton Carvalho
# cheap [1] 50 b <- a area(b) [1] 50 length(b) <- 20 area(a) [1] 50 area(b) expensive [1] 100 Martin Thanks, -steve On Oct 14, 2009, at 2:57 PM, Benilton Carvalho wrote: If you change 'area' to an environment, you may be able to get something close

Re: [R] Cacheing computationally expensive getter methods for S4 objects

2009-10-14 Thread Benilton Carvalho
If you change 'area' to an environment, you may be able to get something close to what you want. For example: setClass("Square", representation( length='numeric', width='numeric', area='environment'

Re: [R] else if statement error

2009-10-03 Thread Benilton Carvalho
align the 'else if' and 'else' with the closing curly brackets. if (condA){ doStuff() } else if (condB){ doOtherStuff() } else { doWhatever() } b On Oct 3, 2009, at 12:54 PM, Chen Gu wrote: Hello, I am doing a simple if else statement in R. But it always comes out error such as 'une

Re: [R] read.delim very slow in reading files with lots of columns

2009-09-25 Thread Benilton Carvalho
mb, while the other took ~4GB for reading the matrix. I will try the scan() and see if it helps. Thanks! Mike -Original Message- From: Benilton Carvalho [mailto:bcarv...@jhsph.edu] Sent: Wednesday, September 23, 2009 4:56 PM To: Ping-Hsun Hsieh Cc: r-help@r-project.org Subject: Re: [R] r

Re: [R] read.delim very slow in reading files with lots of columns

2009-09-25 Thread Benilton Carvalho
rvation: The one with the options does save memory a lot. It took ~150mb, while the other took ~4GB for reading the matrix. I will try the scan() and see if it helps. Thanks! Mike -Original Message- From: Benilton Carvalho [mailto:bcarv...@jhsph.edu] Sent: Wednesday, September 23, 2009

Re: [R] read.delim very slow in reading files with lots of columns

2009-09-23 Thread Benilton Carvalho
use the 'colClasses' argument and you can also set 'nrows'. b On Sep 23, 2009, at 8:24 PM, Ping-Hsun Hsieh wrote: Hi, I am trying to read a tab-delimited file into R (Ver. 2.8). The machine I am using is 64bit Linux with 16 GB. The file is basically a matrix(~600x70) and as large as

Re: [R] generate random number without repetition

2009-09-23 Thread Benilton Carvalho
if you want to sample integers in [1, 33K] without replacement: theSample = sample(33000, 18000) b On Sep 23, 2009, at 7:29 PM, phoebe kong wrote: Hi all, I would like to generate ~18K random number from range 1 to ~33K. I was thinking to use round(runif(18000,1,33000)), however the some

Re: [R] How to read zip file?

2009-09-23 Thread Benilton Carvalho
and note that if, instead of zip files, you were using gzip files, you could: conn <- gzfile("file.gz", "rt") theData <- read.table(conn) close(conn) b On Sep 22, 2009, at 11:21 PM, Gabor Grothendieck wrote: Linux is a type of UNIX so follow the instructions I gave for UNIX. On Tue, Sep 22

Re: [R] sparse vectors

2009-09-08 Thread Benilton Carvalho
library(Matrix) a = sparseMatrix(i=c(20, 30, 1), j=rep(1, 3), x=c(2.2, 3.3, 4.4)) b = sparseMatrix(i=c(3, 30), j=rep(1, 2), x=c(0.1, 0.1), dims=dim(a)) theSum = a+b summary(theSum) hth, b On Sep 8, 2009, at 10:19 AM, Henrique Dallazuanna wrote: Try this: abMerge <- merge(a, b, by

Re: [R] Is there a fast way to do several hundred thousand ANOVA tests?

2009-08-24 Thread Benilton Carvalho
have you tried: fits <- lm(a~b) fstat <- sapply(summary(fits), function(x) x[["fstatistic"]][["value"]]) it takes 3secs for 100K columns on my machine (running on batt) b On Aug 23, 2009, at 9:55 PM, big permie wrote: Dear R users, I have a matrix a and a classification vector b such that

Re: [R] integer and character conversion

2009-08-22 Thread Benilton Carvalho
it's 'scipen' you want to look at.. b On Aug 22, 2009, at 11:16 PM, David Winsemius wrote: On Aug 22, 2009, at 6:13 PM, Dajiang J. Liu wrote: Dear all,I want to convert a long integer to a string, and for example, 1 I used as.character(10) e.g, and it gives me back 1e+???. Wha

Re: [R] computation of matrices in list of list

2009-08-22 Thread Benilton Carvalho
result <- Reduce("+", unlist(z, recursive=FALSE)) b On Aug 22, 2009, at 2:03 PM, kathie wrote: Dear Gabor Grothendieck, thank you for your comments. Ive already tried that. but I've got this error message. Reduce("+",z) Error in f(init, x[[i]]) : non-numeric argument to binary operato

Re: [R] Strange package installation error

2009-08-21 Thread Benilton Carvalho
you may also consider installing from the command line... R CMD INSTALL ~/Desktop/Camino-downloads/DiagnosisMed_0.2.2.1.tar.gz b On Aug 21, 2009, at 11:27 PM, Juliet Hannah wrote: Hi Janet, Were you able to install the package? I just installed it without problems. I don't think there should

Re: [R] Geometric mean of rows in matrix

2009-08-20 Thread Benilton Carvalho
set.seed(1) x <- matrix(runif(1000), 100) system.time(tmp1 <- exp(rowMeans(log(x system.time(tmp2 <- apply(x, 1, function(y) prod(y)^(1/length(y all.equal(tmp1, tmp2) ## tmp1 is more robust, btw On Aug 20, 2009, at 3:22 PM, Edward Chen wrote: Is there a function or an easier way to comp

[R] possible problem with plot.lm

2009-08-20 Thread Benilton Carvalho
Hi, Here's one toy example that shows what I believe to be a problem with plot.lm. This was brought up by another user (Marcos Tadeu Andrade Cordeiro). I took a look at the source and the problem appears to be related to the fact that you need to reorder the data by the group means and th

Re: [R] jpeg() does not work

2009-08-18 Thread Benilton Carvalho
what do you get with: capabilities()[["jpeg"]] ? b On Aug 18, 2009, at 7:27 PM, Edward Chen wrote: My script: raw = read.table("c:\\Documents and Settings\\protein\\My Documents\ \My Fragments\\file1.txt", header = TRUE) #Normal Average Signal VS Pool jpeg("Normal Average Signal vs Pool_t

Re: [R] paste first row string onto every string in column

2009-08-12 Thread Benilton Carvalho
you could stick everything in a 1-liner, but that would make it less readable: myf <- function(x){ tmp <- as.character(x) c(tmp[1], paste(tmp[1], tmp[-1], sep="")) } df2 <- as.data.frame(sapply(df, myf)) b On Aug 12, 2009, at 3:39 AM, milton ruser wrote: Hi Jill, Completely not elega

Re: [R] Selecting/Accessing the last vector in a list of a list of data.frames

2009-08-11 Thread Benilton Carvalho
what are exactly "some operations"? if you could provide a reproducible code, it would make it easier to understand what you're trying to achieve. for example, if you were to get the means, you could do something like: theMeans <- rapply(test, mean) cheers, b On Aug 11, 2009, at 8:59 PM,

Re: [R] including a variable in another variable name

2008-04-02 Thread Benilton Carvalho
?assign b On Apr 2, 2008, at 4:26 PM, Georg Ehret wrote: Dear R community,I wish to include a variable (e.g. slice of "a" below) in another variable's name. My objective would be to get a variable- name "data_A" and so on. How can I do this? a<-LETTERS[1:25] a [1] "A" "B" "C" "D" "E" "F

Re: [R] R CMD SHLIB errors

2008-03-19 Thread Benilton Carvalho
Brain indeed. On Mar 19, 2008, at 11:21 AM, sun wrote: Thanks Prof. Brain, Following your suggestion I found the reason of my problem in the document ''R Installation and Administration' and the links it points to'. After I updated to R2.6.2, the RTools's default compiler chaged to gcc4

Re: [R] character strings and functions

2008-03-18 Thread Benilton Carvalho
get("x1") On Mar 19, 2008, at 1:07 AM, Erin Hodgess wrote: Dear R People: I have a function x1 Next, I have a character vector x which has one element, "x1". How would I retrieve the original function x1 from the character vector, please? thanks, Erin -- Erin Hodgess Associate Professo

Re: [R] ls() and classes

2008-03-18 Thread Benilton Carvalho
On Mar 18, 2008, at 11:44 PM, Rolf Turner wrote: On 19/03/2008, at 4:39 PM, Erin Hodgess wrote: do.call(class,list=ls()) sapply(ls(),function(x){class(get(x))}) or, in case you want to save some typing: eapply(globalenv(), class) b__ R-help@r-

Re: [R] Splitting a set of vectors in a list (Solved )

2008-03-13 Thread Benilton Carvalho
or the suggestive :) ?"[" b On Mar 13, 2008, at 2:58 PM, Henrique Dallazuanna wrote: On 13/03/2008, John Kane <[EMAIL PROTECTED]> wrote: Can you point me to some documentation that discusses these usages. I have seen them before but I have never actually figured out how to use them.? See ?

Re: [R] subset list based on logical within element flag

2008-03-12 Thread Benilton Carvalho
gene.pair.tf.lst[sapply(gene.pair.tf.lst, "[[", "sig.cor")] b On Mar 12, 2008, at 5:24 PM, Mark W Kimpel wrote: I have a very long list that I'd like to subset based on a logical value within each element. Example below. I'd like to get just those list elements for further study whose $sig.

Re: [R] (no subject)

2008-03-11 Thread Benilton Carvalho
imprecise are our eyes :) check where 4336.543 actually is and note how the range of the data confused you. plot(a~b) abline(model) abline(h=4336.543, v=10) b On Mar 11, 2008, at 11:27 AM, Aad Termorshuizen wrote: # PROBLEM WITH ABLINE # I have a question about a seemingly imprecise abl

Re: [R] Warning: matrix by vector division

2008-03-07 Thread Benilton Carvalho
and you might want to check ?prop.table > prop.table(a, 2) [,1] [,2] [1,] 0.0 0.333 [2,] 0.5 0.333 [3,] 0.5 0.333 or even ?sweep (which will be useful for more complex situations) > sweep(a, 2, colSums(a), "/") [,1] [,2] [1,] 0.0 0.333 [2,] 0.5 0.333

Re: [R] Array arithmetic

2008-03-06 Thread Benilton Carvalho
no, it won't. you're doing the right math on the "valid" subset... but you're not returning the zeros where needed therefore, the whole thing will get recycled to match the dimensions. b On Mar 6, 2008, at 2:03 PM, Henrique Dallazuanna wrote: I think this should work: array(A[abs(B)

Re: [R] Array arithmetic

2008-03-06 Thread Benilton Carvalho
apparently you forgot the "commented, minimal, self-contained, reproducible code" part... L = 10 M = 20 N = 30 P = 40 set.seed(1) A = array(rnorm(L*M*N*P), dim=c(L, M, N, P)) B = array(rnorm(L*M*N), dim=c(L, M, N)) B[sample(100, 10)] = 0 C = array(0, dim=c(L, M, N, P)) for (i in 1:L) { for (j i

Re: [R] renaming objects

2008-03-03 Thread Benilton Carvalho
or, in other terms: > set.seed(1) > x <- runif(1e7) > x.add <- tracemem(x) > y <- x > y.add <- tracemem(y) > identical(x.add, y.add) [1] TRUE ie, both objects have the same memory address - therefore, not a copy: > x.add [1] "<0x200>" > y.add [1] "<0x200>" now, observe what happens whe

Re: [R] Calculating the t-test for each row

2008-03-03 Thread Benilton Carvalho
apparently you want to check the genefilter package... it defines functions like: rowttests colttests rowFtests colFtests rowVars rowSds moreover, a quick look at Biobase is recommended... that would save you lots of time as you wouldn't have to reinvent the wheel. b On Mar 3, 2008, at

Re: [R] A question on getting all possible combinations

2008-03-01 Thread Benilton Carvalho
target = c("u", "d") apply(expand.grid(rep(list(target), 6)), 1, paste, sep="", collapse="") b On Mar 1, 2008, at 9:13 AM, Megh Dal wrote: Hi all, Suppose I have to letters 'u' and 'd'. Now I want to find all combinations like that : uu ud du . dd This t

  1   2   >