Re: [R] Using read.table for importing gz file

2019-08-10 Thread David Winsemius
Further note: After three minutes of waiting  ... not a particularly long wait in my opinion, I get this: > z <- read.table( text=readLines(gzcon(url('https://TCGA.xenahubs.net/download/TCGA.GBMLGG.sampleMap/HumanMethylation450.gz')) ), header=TRUE, sep="\t") > dim(z) [1] 485577    686 S

Re: [R] Using read.table for importing gz file

2019-08-10 Thread David Winsemius
Well, let's see about "rules"  ... you posted in HTML when this is a plain text mailing list and then you replied to only me when you are supposed reply to the list (so I'm putting back the list address in my reply: When I copied your code and then attempted to do a bit of debugging I get:

Re: [R] vectorizing the integrate function

2019-08-10 Thread Bert Gunter
Ravi: I believe you are under a misconception. The Vectorize() function vectorizes the function call, **but it does not vectorize the computation by moving loops down to the C level**, which is typically what is meant when it is recommended that R users use inbuilt vectorized functions when possib

Re: [R] vectorizing the integrate function

2019-08-10 Thread ravi via R-help
Bert,Thanks a lot. This meets all my expectations for the moment. Thanks.Ravi On Sunday, 11 August 2019, 00:52:02 CEST, Bert Gunter wrote: Cleaner, I think, is to use ?expand.grid and ?do.call, noting that any n-column data frame is also an n-component list. Using your example as befo

Re: [R] vectorizing the integrate function

2019-08-10 Thread ravi via R-help
Rui,Thanks for your help in getting the result with for loops. That is useful, but I have a complicated integral and I am interested in improving the performance with the benefit of vectorization. In the solution from Bert, I would like to know how I can extract the numerical vector from the fu

Re: [R] vectorizing the integrate function

2019-08-10 Thread Bert Gunter
Cleaner, I think, is to use ?expand.grid and ?do.call, noting that any n-column data frame is also an n-component list. Using your example as before: > f2 <- function(a,b,m)integrate(function(x){exp(-a*x^3-b*x^2-m*x)},lower =0,upper = Inf) > fv <- Vectorize(f2,vectorize.args=c("a","b","m"),SIMPLI

Re: [R] vectorizing the integrate function

2019-08-10 Thread Rui Barradas
Hello, The following code might not be the best way of computing the integrals for all combinations of the arguments but it gets the job done and I believe it's readable code. f2 <- function(a, b, c){ integrate(function(x) {exp(-a*x^3 - b*x^2 - c*x)}, lower = 0, upper = Inf) }

Re: [R] Using read.table for importing gz file

2019-08-10 Thread David Winsemius
Have you tried using readLines in the manner illustrated on the ?gzfile help page? David. On 8/10/19 12:29 PM, Spencer Brackett wrote: Hello, I am trying to read the following Xena dataset into R for data analysis: https://tcga.xenahubs.net/download/TCGA.GBMLGG.sampleMap/HumanMethylation450.

Re: [R] vectorizing the integrate function

2019-08-10 Thread ravi via R-help
Bert,Thanks a lot for your help. I have a few follow-up questions (shown in the comment lines).  Numerical values and error for a (i) vector and (ii) array. a <- seq(from=0,to=1,by=0.5) b <- seq(from=5,to=10,by=1) m <- seq(from=10,to=20,by=5) f2 <- function(a,b,m)integrate(function(x){exp(-a*x^

[R] Using read.table for importing gz file

2019-08-10 Thread Spencer Brackett
Hello, I am trying to read the following Xena dataset into R for data analysis: https://tcga.xenahubs.net/download/TCGA.GBMLGG.sampleMap/HumanMethylation450.gz I tried to run the following read.table(gzfile("HumanMethylation450.gz")), but R ended up crashing as a result. Is there perhaps a way t

Re: [R] vectorizing the integrate function

2019-08-10 Thread Bert Gunter
Ravi: First of all, you're calling Vectorize incorrectly. The first argument must be a function *name*, not a function call. Here's what you need to do (and thanks for the reprex -- wouldn't have been able to help without it!): f2 <- function(a,b,c)integrate(function(x){exp(-a*x^3-b*x^2-c*x)},low

[R] vectorizing the integrate function

2019-08-10 Thread ravi via R-help
Hi all,I am having some difficulties in vectorizing the integrate function. Let me explain with an example. a <- 10; b <- 3; c <- 4 f <- function(x) {exp(-a*x^3-b*x^2-c*x)} integrate(f,0,Inf) # works fine My difficulties start when I want to vectorize. # attempts to vectorize fail a <- seq(from=