Re: [R] Help batch saving elements of a list into unique files

2016-03-22 Thread Jim Lemon
Okay. Got some lunch, I can think about this with both halves of the brain. drop_token1<-function(x) { return(paste(x[2:length(x)],sep="",collapse=".")) } affnames<-c("X0.Classical.10.11.1_.HuEx.1_0.st.v2..CEL", "X1.Classical.10.11.1_.HuEx.1_0.st.v2..CEL") affnames.split<-strsplit(affnames,"[.]"

Re: [R] Help batch saving elements of a list into unique files

2016-03-22 Thread Jim Lemon
Transcription. I forgot the "collapse" argument when I wrote the email: drop_token1<-function(x) { return(paste(x[2:length(x)],sep="",collapse=".")) } Jim On Wed, Mar 23, 2016 at 10:14 AM, Christian T Stackhouse (Campus) wrote: > Very close! The header now looks like this: c("10", "11", "1_",

Re: [R] Help batch saving elements of a list into unique files

2016-03-22 Thread Jim Lemon
I think it's the "unlist". I can only test this with one set of made up names at a time. names(out[[affdf]])<- lapply(strsplit(names(out[[affdf]]),"[.]"),drop_token1) Jim On Wed, Mar 23, 2016 at 9:57 AM, Christian T Stackhouse (Campus) wrote: > This is what I ran: > >> drop_token1<-function(x

Re: [R] Help batch saving elements of a list into unique files

2016-03-22 Thread Jim Lemon
Sorry, should be: names(out[[affdf]])<- lapply(unlist(strsplit(names(out[[affdf]]),"[.]")),drop_token1) Jim On Wed, Mar 23, 2016 at 9:43 AM, Christian T Stackhouse (Campus) wrote: > Thank you, Jim. I got this error returned: > > Error in strsplit(names(out[[affdf]])) : > argument "split" is

Re: [R] Help batch saving elements of a list into unique files

2016-03-22 Thread Jim Lemon
Okay, I just snipped off the first token in the header labels assuming that there would be no more periods. Try this: drop_token1<-function(x) { return(paste(x[2:length(x)],sep=".")) } for(affdf in 1:length(out)) { names(out[[affdf]])<-lapply(unlist(strsplit(names(out[[affdf]]))),drop_token1) wri

Re: [R] Help batch saving elements of a list into unique files

2016-03-22 Thread Jim Lemon
Hi Christian, This untested script might get you going (assuming you want a CSV format): for(affdf in 1:length(out)) { names(out[[affdf]])<-lapply(strsplit(names(out[[affdf]]),"[.]"),"[",2) write.csv(out[[affdf]],file=paste("affymetrix",affdf,".txt",sep="")) } Jim On Wed, Mar 23, 2016 at 6:32

Re: [R] arranging axis within plotting area

2016-03-22 Thread Jim Lemon
Hi Eliza, I think you only need to change the margins and the placement of the right axis label: colours <- c("black", "grey") par(mar=c(5,4,4,4)) barplot(prop,ylab = "Numbers", cex.lab = 1.5, cex.main = 1.4, beside=TRUE, col=colours,ylim=c(0,250)) axis(side=3,xlim=c(0,45), at=c(6,12,18,24,30,36,

[R] bug (?) with lapply / clusterMap / clusterApply etc

2016-03-22 Thread jacob
Hello I have encountered a bug(?) with the parallel package. When run from within a function, the parLapply function appears to be copying the entire parent environment (environment of interior of function) into all child nodes in the cluster, one node at a time - which is very very slow

[R] splm: fixed effects for time-invariant variables

2016-03-22 Thread Kwan Nok Chan
Dear users: Has anyone tried using splm to estimate a fixed effects model with one or more time-invariant variables? I may have missed something in the manual, but there isn't a clear way to switch to estimators (e.g. first difference) suited for data like that in splm. My colleagues and I are v

[R] arranging axis within plotting area

2016-03-22 Thread Eliza Botto
Dear useRs, I have defined two matrices "prop" and "ELE" in the following manner > dput(prop) structure(c(122.4667, 87.1500875, 94.3647755102041, 84.8471625, 95.2767755102041, 84.15558125, 121.8467, 90.75970625, 98.2028979591837, 87.1500875, 88.2953043478261, 72.81219375, 88.234,

[R] Help batch saving elements of a list into unique files

2016-03-22 Thread Christian T Stackhouse (Campus)
Hello! The overall goal I have is taking a large data frame and splitting it into several smaller data frames (preserving column headers) which I can save as txt files to feed into my APACHE ANY23 server for conversion into RDF. This is what I call to split up the original file: out <- spli

Re: [R] Memory usage in prcomp

2016-03-22 Thread Roy Mendelssohn - NOAA Federal
> On Mar 22, 2016, at 10:00 AM, Martin Maechler > wrote: > >> Roy Mendelssohn <- NOAA Federal > >>on Tue, 22 Mar 2016 07:42:10 -0700 writes: > >> Hi All: >> I am running prcomp on a very large array, roughly [50, 3650]. The >> array itself is 16GB. I am running on a Unix mac

Re: [R] R studio kniter

2016-03-22 Thread Duncan Murdoch
On 22/03/2016 1:08 PM, Jan Kacaba wrote: Hello, is it possible to run kiniter by script instead by clicking on button compile PDF? Say I have "texfile.rnw" and "myscript.R". I would like to knit texfile.rnw by runnig script "myscript.R". In "myscript.R" I would write something like this: knit("t

[R] R studio kniter

2016-03-22 Thread Jan Kacaba
Hello, is it possible to run kiniter by script instead by clicking on button compile PDF? Say I have "texfile.rnw" and "myscript.R". I would like to knit texfile.rnw by runnig script "myscript.R". In "myscript.R" I would write something like this: knit("texfile.rnw") [[alternative HTML ve

Re: [R] Memory usage in prcomp

2016-03-22 Thread Martin Maechler
> Roy Mendelssohn <- NOAA Federal > > on Tue, 22 Mar 2016 07:42:10 -0700 writes: > Hi All: > I am running prcomp on a very large array, roughly [50, 3650]. The array itself is 16GB. I am running on a Unix machine and am running “top” at the same time and am quite surpri

[R] Memory usage in prcomp

2016-03-22 Thread Roy Mendelssohn - NOAA Federal
Hi All: I am running prcomp on a very large array, roughly [50, 3650]. The array itself is 16GB. I am running on a Unix machine and am running “top” at the same time and am quite surprised to see that the application memory usage is 76GB. I have the “tol” set very high (.8) so that it s

Re: [R] Reshaping an array - how does it work in R

2016-03-22 Thread Roy Mendelssohn - NOAA Federal
Thanks all. This is interesting, and for what I am doing worthwhile and helpful. I have to be careful in each operation whether a copy is made or not, and knowing this allows me to test on small examples what any command will do before I use, Thanks again, I appreciate all the help. I will

Re: [R] Is there dpois equivalent for zero-inflated Poisson?

2016-03-22 Thread Thierry Onkelinx
dpois(0, lambda) == e^(-lambda) The wikipedia formula is ifelse(x == 0, zero + dpois(0, lambda) * (1-zero), dpois(x, lambda) * (1-zero)) or ifelse(x == 0, zero + dpois(x, lambda) * (1-zero), dpois(x, lambda) * (1-zero)) so we can move the dpois() out of the ifelse() ifelse(x == 0, zero, 0) +

Re: [R] Is there dpois equivalent for zero-inflated Poisson?

2016-03-22 Thread Matti Viljamaa
And why is the first term of ifelse(x == 0, zero, 0) + dpois(x, lambda) / (1 - zero) ifelse(x == 0, zero, 0) rather than something corresponding to zero+(1-zero)e^{-lambda} https://en.wikipedia.org/wiki/Zero-inflated_model#Zero-inflated_Poisson > On 22 Mar 2016, at 14:25, Matti Viljamaa wrot

Re: [R] Is there dpois equivalent for zero-inflated Poisson?

2016-03-22 Thread Thierry Onkelinx
zero = proportion of zero inflation part lamba = expected value of poisson part There was a typo in the distribution. It should multiple by (1 - zero) instead of divide by it. dzeroinflpois <- function(x, lambda, zero){ ifelse(x == 0, zero, 0) + dpois(x, lambda) * (1 - zero) } ir. Thierry Onke

Re: [R] Is there dpois equivalent for zero-inflated Poisson?

2016-03-22 Thread Matti Viljamaa
Could you clarify what are the parameters and why it’s formulated that way? -Matti > On 22 Mar 2016, at 14:17, Thierry Onkelinx wrote: > > Dear Matti, > > What about this? > > dzeroinflpois <- function(x, lambda, zero){ > ifelse(x == 0, zero, 0) + dpois(x, lambda) / (1 - zero) > } > plot(x,

Re: [R] Is there dpois equivalent for zero-inflated Poisson?

2016-03-22 Thread Thierry Onkelinx
Dear Matti, What about this? dzeroinflpois <- function(x, lambda, zero){ ifelse(x == 0, zero, 0) + dpois(x, lambda) / (1 - zero) } plot(x, dzeroinflpois(x, lambda = 10, zero = 0.2), type = "l") ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Fo

[R] Is there dpois equivalent for zero-inflated Poisson?

2016-03-22 Thread Matti Viljamaa
I’m doing some optimisation that I first did with normal Poisson (only parameter theta was estimated), but now I’m doing the same with a zero-inflated Poisson model which gives me two estimated parameters theta and p (p is also pi in some notation). My question is, is there something equivalent

Re: [R] regex - extracting src url

2016-03-22 Thread Martin Morgan
On 03/22/2016 12:44 AM, Omar André Gonzáles Díaz wrote: Hi,I have a DF with a column with "html", like this: https://ad.doubleclick.net/ddm/trackimp/N344006.1960500FACEBOOKAD/B9589414.130145906;dc_trk_aid=303019819;dc_trk_cid=69763238;ord=[timestamp];dc_lat=;dc_rdid=;tag_for_child_directed_tre

Re: [R] Reshaping an array - how does it work in R

2016-03-22 Thread Dénes Tóth
Hi Martin, On 03/22/2016 10:20 AM, Martin Maechler wrote: >Dénes Tóth > on Fri, 18 Mar 2016 22:56:23 +0100 writes: > Hi Roy, > R (usually) makes a copy if the dimensionality of an array is modified, > even if you use this syntax: > x <- array(1:24, c(2, 3, 4))

Re: [R] Reshaping an array - how does it work in R

2016-03-22 Thread Martin Maechler
> Dénes Tóth > on Fri, 18 Mar 2016 22:56:23 +0100 writes: > Hi Roy, > R (usually) makes a copy if the dimensionality of an array is modified, > even if you use this syntax: > x <- array(1:24, c(2, 3, 4)) > dim(x) <- c(6, 4) > See also ?tracemem, ?data.table: