Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ 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. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ 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.
Re: [R] group by and merge two dataframes
yes thanks, that's correct! here a slight variation inspired by your solution: a cartesian product restricted to non duplicated records to get the logical vector i to be used in the next natural join i-!duplicated(merge(df1$id,df1$item, by=NULL)) merge(df1[i,],df2) thanks Il 08/05/2014 18:43, arun ha scritto: Hi, May be: indx - !duplicated(as.character(interaction(df1[,-3]))) merge(df1[indx,],df2) A.K. On Thursday, May 8, 2014 12:34 PM, Massimo Bressanmbres...@arpa.veneto.it wrote: yes, thank you for all your replies, they worked out correctly indeed... ...but because of my fault, by then working on my real data I fully realised that I should have mentioned something that is changing (quite a lot, in fact) the terms of the problem... please would you consider the following (consistent) variation ? df1 - data.frame(id=rep(1:3,each=2), item=c(rep(A,2), rep(B,2), rep(C,2)), v=rnorm(6)) df2 - data.frame(id=c(1,2,3), who=c(tizio,caio,sempronio)) and again I need to group the first dataframe df1 both by id and by the first record of v, and then merge with the second dataframe df2 (again by id) now, how to do that? (that's why probably I was pointing in my first post to the use of sqldf) thanks ps: I'm in doubt wheter I must open another thread or keep going with this one (really sorry for the eventual violation of the R-help netiquette) Il 08/05/2014 17:14, arun ha scritto: Hi, May be this helps: merge(unique(df1),df2) A.K. On Thursday, May 8, 2014 5:46 AM, Massimo Bressanmbres...@arpa.veneto.it wrote: given this bare bone example: df1 - data.frame(id=rep(1:3,each=2), item=c(rep(A,2), rep(B,2), rep(C,2))) df2 - data.frame(id=c(1,2,3), who=c(tizio,caio,sempronio)) I need to group the first dataframe df1 by id and then merge with the second dataframe df2 (again by id) so far I've manged to accomplish the task by something like the following... # start require(sqldf) tmp-sqldf(select * from df1 group by id) merge(tmp, df2) #end now I'm wonderng if there is a more efficient and/or elegant way to perform it (also because in fact I'm dealing with much more heavy dataframes); may be possible through a single sql statement? or by using a different package functions (e.g. dplyr)? my attempts towards these alternative approaches miserably failed ... thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ 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. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ 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-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.
Re: [R] problem in r-code
Wrong list. This is an R list not Bugs. You may want to consult Bugs materials: http://www2.mrc-bsu.cam.ac.uk/bugs/weblinks/webresource.shtml On 8 May 2014 11:36, thanoon younis thanoon.youni...@gmail.com wrote: dear all members is there anyone explain to me the code below and how can i transfer this code to winbugs program. q[i,1]=qnorm(runif(1,min=.5,max=1),0,1) thanks in advance thanoon [[alternative HTML version deleted]] __ 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-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.
Re: [R] How can I make this nested loop faster?
Your code is not re-producable. Can you provide a working example using a standard dataset from R? But, you could first try to use compiler package, see ?enableJIT. Another option would be to use doMC/foreach packages if you can run your assignment in the nested loop in parallel, see %dopar%. On 8 May 2014 21:59, Ludwig Hilger l.hil...@ku.de wrote: Hello everybody, I have written a nested for-loop, but as length(uc) 170,000, this would take VERY long. I have tried to use sapply or something but I cannot get it to work, I would be happy if someone could point out to write this more efficiently. Thank you all, Ludwig ergsens - data.frame(budget = numeric(500)) uc - unique(rftab$startCell) for(i in 1:500){ uniquerates - rlnorm(n = length(uc), mean = -1.6, sd = 1.7) for(j in 1:length(uc)){ rftab$masskg[rftab$startCell == uc[j]] - uniquerates[j] } ergsens$budget[i] - sum(rftab$masskg, na.rm = TRUE)/1000 } - Dipl. Geogr. Ludwig Hilger Wiss. MA Lehrstuhl für Physische Geographie Katholische Universität Eichstätt-Ingolstadt Ostenstraße 18 85072 Eichstätt -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-make-this-nested-loop-faster-tp4690209.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] How to examine the parameter values during iteration (nls)
Hi everyone, I am using nls() to run a simple sigmoid curve type of regression and would like to see how the parameter values change through iterations. How can I see those values? Or ideally, can I even extract those values? For example, nls(Response~E0+Emax*Conc/(EC50+Conc), data=data, start=list()) I would like to see how Emax and EC50 values change through iterations. Thanks. Jun [[alternative HTML version deleted]] __ 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.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ 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. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ 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
Re: [R] How to examine the parameter values during iteration (nls)
Read ?nls and note the trace argument. Does nls(...,trace = TRUE) not do what you want? By using ?capture.output you could then capture the trace I would think, but I haven't tried. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 6:41 AM, Jun Shen jun.shen...@gmail.com wrote: Hi everyone, I am using nls() to run a simple sigmoid curve type of regression and would like to see how the parameter values change through iterations. How can I see those values? Or ideally, can I even extract those values? For example, nls(Response~E0+Emax*Conc/(EC50+Conc), data=data, start=list()) I would like to see how Emax and EC50 values change through iterations. Thanks. Jun [[alternative HTML version deleted]] __ 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-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.
Re: [R] DESeq vs DESeq2 different DEGs results
You're on the wrong list. This is more appropriate on the bioconductor mailing list. On Mon, May 5, 2014 at 9:42 AM, Catalina Aguilar Hurtado cata...@gmail.comwrote: Hi, I want to compare DESeq vs DESeq2 and I am getting different number of DEGs which I will expect to be normal. However, when I compare the 149 genes ID that I get with DESeq with the 869 from DESeq2 there are only ~10 genes that are in common which I donât understand (using FDR 0.05 for both). I want to block the Subject effect for which I am including the reduced formula of ~1. Shouldnât these two methods output similar results? Because at the moment I could interpret my results in different ways. Thanks for your help, Catalina This the DESeq script that I am using: DESeq library(DESeq) co=as.matrix(read.table(2014_04_01_6h_LP.csv,header=T, sep=,, row.names=1)) Subject=c(1,2,3,4,5,1,2,4,5) Treatment=c(rep(co,5),rep(c2,4)) a.con=cbind(Subject,Treatment) cds=newCountDataSet(co,a.con) cds - estimateSizeFactors( cds) cds - estimateDispersions(cds,method=pooled-CR, modelFormula=count~Subject+Treatment) #filtering rs = rowSums ( counts ( cds )) theta = 0.2 use = (rs quantile(rs, probs=theta)) table(use) cdsFilt= cds[ use, ] fit0 - fitNbinomGLMs (cdsFilt, count~1) fit1 - fitNbinomGLMs (cdsFilt, count~Treatment) pvals - nbinomGLMTest (fit1, fit0) padj - p.adjust( pvals, method=BH ) padj - data.frame(padj) row.names(padj)=row.names(cdsFilt) padj_fil - subset (padj,padj 0.05 ) dim (padj_fil) [1] 149 1 ââââââ library (DESeq2) countdata=as.matrix(read.table(2014_04_01_6h_LP.csv,header=T, sep=,, row.names=1)) coldata= read.table (targets.csv, header = T, sep=,,row.names=1) coldata Subject Treatment F1 1co F2 2co F3 3co F4 4co F5 5co H1 1c2 H2 2c2 H4 4c2 H5 5c2 dds - DESeqDataSetFromMatrix( countData = countdata, colData = coldata, design = ~ Subject + Treatment) dds dds$Treatment - relevel (dds$Treatment, co) dds - estimateSizeFactors( dds) dds - estimateDispersions(dds) rs = rowSums ( counts ( dds )) theta = 0.2 use = (rs quantile(rs, probs=theta)) table(use) ddsFilt= dds[ use, ] dds - nbinomLRT(ddsFilt, full = design(dds), reduced = ~ 1) resLRT - results(dds) sum( resLRT$padj 0.05, na.rm=TRUE ) #[1] 869 [[alternative HTML version deleted]] __ 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. [[alternative HTML version deleted]] __ 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.
Re: [R] Tukey no factors
HI, May be the below links help: http://r.789695.n4.nabble.com/TukeyHSD-troubles-td1570205.html http://r.789695.n4.nabble.com/TukeyHSD-error-td3051059.html A.K. Hi I'm trying to run a Tukey test on mortality data, where I want to test whether mortality is influenced by the amount of copper (in an one-way ANOVA) and the combination of copper and temperature (in a two-way ANOVA). These are my formulas: lm2-lm(Mortality~Cu) anova(lm2) TukeyHSD(aov(Mortality~Cu)) lm2-lm(Mortality~Cu+Temp+Cu:Temp) anova(lm2) TukeyHSD(aov(Mortality~Cu+Temp+Cu:Temp)) The ANOVA is no problem, but for both Tukey's, I get the following error message: Error in TukeyHSD.aov(aov(Mortality ~ Cu + Temp + Cu:Temp)) : no factors in the fitted model In addition: Warning messages: 1: In replications(paste(~, xx), data = mf) : non-factors ignored: Cu 2: In replications(paste(~, xx), data = mf) : non-factors ignored: Temp 3: In replications(paste(~, xx), data = mf) : non-factors ignored: Cu, Temp I've read on other posts that there should be a factor somewhere, but all my data are numbers! I'm quite baffled and have no idea what to do next. Thanks in advance for your help! Lundill __ 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] Resquest
Dear Sir, I need Your help,I am working on the comparison of l moments and trimmed l moments .,Now i face a problem in R programming of trimmed l moments. for this purpose i need your help .for example let suppose i have the following data vector abcc (148543,130470,173000,22,151080,157600,34500,20400,34500,46100,69500,37900,30600,40200,36400,22900,38600) Now i want to find its sample trimmed l moments ,trimmed l ratio and also parameter estimation of the following distribution Glog,GEV,,GNORM,,P3,,GP,and also find trimmed l ratio diagram...please help me sir kindly send me the command or the program of the above mention.. I shall be very thankful to you for this kind of act.. [[alternative HTML version deleted]] __ 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.
Re: [R] Error during working with wgcna and R
I am also working on co-expression analysis. It seems like there is no way to use TOMsimilarityFromExpr for large datasets. The option 'maxBlockSize' exists for module detection but not for TOMsimilarity? The only solution seems to reduce the dataset On Sunday, July 8, 2012 1:02:54 PM UTC+2, deeksha.malhan wrote: Hi I am working on co-expression analysis of rice dataset with the help of wgcna and R but now I am at one point which is showing error as shown below : dissTOM = 1-TOMsimilarityFromExpr(datExpr, power = 8); Error: cannot allocate vector of size 2.8 Gb In addition: Warning messages: 1: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) 2: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) 3: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) 4: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) Help me to resolve this problem -- View this message in context: http://r.789695.n4.nabble.com/Error-during-working-with-wgcna-and-R-tp4635768.html Sent from the R help mailing list archive at Nabble.com. __ r-h...@r-project.org javascript: 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-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] Pearson III distribution
Please I need your help.I'm intrested to know if there is any R-package for fit a Pearson III extreme value distribution to data.Thanks a lot Noelia [[alternative HTML version deleted]] __ 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.
Re: [R] Error during working with wgcna and R
WGCNA maintainer here. When working with a large data set, you have a few options. 1. Without being snarky, the best option is to get (or get access to) a computer with large-enough RAM. Many universities, departments, and other research institutes have computer clusters with nodes with at least 64GB of memory. If you are working on your own computer under Windows, make sure you run the 64-bit version of R and consider buying additional RAM if you can. 2. Reduce the number of the features (usually probes/probesets). This is not always possible in general applications, but for gene expression studies in a single tissue one would not expect more than about 10k genes to be expressed, so using all probes of a modern array is probably an overkill - most of them will not be expressed. If you do the reduction, I recommend filtering out probes whose expression values are low in a suitable fraction of the samples (depending on experiment design). If you can't get a computer big enough to handle a reduced data set, the next options are these: 3. Use blockwiseModules with an appropriately set argument maxBlockSize. See WGCNA tutorial I, section 2c, at http://labs.genetics.ucla.edu/horvath/htdocs/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/index.html , and pay careful attention to the paragraphs discussing the choice of maxBlockSize. The function blockwiseModules can be instructed to save the TOM matrices for each block to disk; you can load them later one-by-one if you need to. 4. If you want to do the analysis on your own, use the function projectiveKMeans to pre-cluster the genes into blocks, then run the analysis in each block separately. Remember to remove all large objects from memory and call garbage collection to free up enough memory before going to the next block. HTH, Peter On Fri, May 9, 2014 at 5:37 AM, KK kidist.kib...@gmail.com wrote: I am also working on co-expression analysis. It seems like there is no way to use TOMsimilarityFromExpr for large datasets. The option 'maxBlockSize' exists for module detection but not for TOMsimilarity? The only solution seems to reduce the dataset On Sunday, July 8, 2012 1:02:54 PM UTC+2, deeksha.malhan wrote: Hi I am working on co-expression analysis of rice dataset with the help of wgcna and R but now I am at one point which is showing error as shown below : dissTOM = 1-TOMsimilarityFromExpr(datExpr, power = 8); Error: cannot allocate vector of size 2.8 Gb In addition: Warning messages: 1: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) 2: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) 3: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) 4: In matrix(0, nGenes, nGenes) : Reached total allocation of 2550Mb: see help(memory.size) Help me to resolve this problem -- View this message in context: http://r.789695.n4.nabble.com/Error-during-working-with-wgcna-and-R-tp4635768.html Sent from the R help mailing list archive at Nabble.com. __ r-h...@r-project.org javascript: 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-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-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.
Re: [R] Pearson III distribution
On May 9, 2014, at 8:17 AM, NOELIA LEGAL wrote: Please I need your help.I'm intrested to know if there is any R-package for fit a Pearson III extreme value distribution to data.Thanks a lot You are requested to do some searching yourself before posting. If you have failed to find what you need in the CRAN Task Views, the obvious one being: http://cran.r-project.org/web/views/Distributions.html then you should say what further is needed and how those resources have failed to address your needs. Noelia [[alternative HTML version deleted]] __ 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. David Winsemius Alameda, CA, USA __ 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.
Re: [R] How to write a loop in which i has to be in POSIX format?
i is an element in zn so replace zn[i] with just i for (i in zn){ treat$su[treat$Zugnacht==as.POSIXct(i, UTC)] - min(treat$Vollzeit[treat$Zugnacht==as.POSIXct(zni, UTC)]) treat$sa[treat$Zugnacht==as.POSIXct(zni, UTC)] - max(treat$Vollzeit[treat$Zugnacht==as.POSIXct(zni, UTC)]) } If you want to keep i as an index you need something like: for(i in 1:length(i)) { #do stuff on zn[i] } On Thu, 2014-05-08 at 14:19 -0700, peregrine wrote: Hallo, I have a table in which I would like to insert the min and max values of another column (date and time in as.POSIXct Format). This is my row table, where su and sa are still the same as Vollzeit: head(treat) Vollzeit Datum Zugnacht su sa 2 2013-09-09 20:15:00 2013-09-09 2013-09-09 2013-09-09 20:15:00 2013-09-09 20:15:00 3 2013-09-09 20:30:00 2013-09-09 2013-09-09 2013-09-09 20:30:00 2013-09-09 20:30:00 4 2013-09-09 20:45:00 2013-09-09 2013-09-09 2013-09-09 20:45:00 2013-09-09 20:45:00 5 2013-09-09 21:00:00 2013-09-09 2013-09-09 2013-09-09 21:00:00 2013-09-09 21:00:00 6 2013-09-09 21:15:00 2013-09-09 2013-09-09 2013-09-09 21:15:00 2013-09-09 21:15:00 7 2013-09-09 21:30:00 2013-09-09 2013-09-09 2013-09-09 21:30:00 2013-09-09 21:30:00 Now I want to insert the minimum value of Vollzeit for each date in Zugnacht into the column su and the maximum value of Vollzeit for each date in Zugnacht into the column sa. If I do it like this, it does exactly what I want: zn - unique(treat$Zugnacht) i=zn[1] treat$su[treat$Zugnacht==as.POSIXct(i, UTC)] - min(treat$Vollzeit[treat$Zugnacht==as.POSIXct(i, UTC)]) treat$sa[treat$Zugnacht==as.POSIXct(i, UTC)] - max(treat$Vollzeit[treat$Zugnacht==as.POSIXct(i, UTC)]) This is the result for the first date in Zugnacht: head(treat) Vollzeit Datum Zugnacht su sa 2 2013-09-09 20:15:00 2013-09-09 2013-09-09 2013-09-09 20:15:00 2013-09-10 04:30:00 3 2013-09-09 20:30:00 2013-09-09 2013-09-09 2013-09-09 20:15:00 2013-09-10 04:30:00 4 2013-09-09 20:45:00 2013-09-09 2013-09-09 2013-09-09 20:15:00 2013-09-10 04:30:00 5 2013-09-09 21:00:00 2013-09-09 2013-09-09 2013-09-09 20:15:00 2013-09-10 04:30:00 6 2013-09-09 21:15:00 2013-09-09 2013-09-09 2013-09-09 20:15:00 2013-09-10 04:30:00 7 2013-09-09 21:30:00 2013-09-09 2013-09-09 2013-09-09 20:15:00 2013-09-10 04:30:00 However I am not able to create a loop that runs over all 113 dates in zn. I tried this, but it does not work. Can anybody help, please? for (i in zn){ treat$su[treat$Zugnacht==as.POSIXct(zn[i], UTC)] - min(treat$Vollzeit[treat$Zugnacht==as.POSIXct(zn[i], UTC)]) treat$sa[treat$Zugnacht==as.POSIXct(zn[i], UTC)] - max(treat$Vollzeit[treat$Zugnacht==as.POSIXct(zn[i], UTC)]) } Kind regards Christiane -- View this message in context: http://r.789695.n4.nabble.com/How-to-write-a-loop-in-which-i-has-to-be-in-POSIX-format-tp4690212.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] transition from depends to imports
Hi all, I am having trouble to do a particular transition from depends to imports in one of my packages. This packages uses 'wilcoxsign_test' from the 'coin' package. And this is the only function from the coin package that it uses (directly). (Everything works fine, as long as my package depends on the coin package.) My guess was, that I would need to only import that function from the coin package. (I.e. to move the coin package from Depends to Imports in the DESCRIPTION and in the NAMESPACE do 'importFrom(coin,wilcoxsign_test)'.) But then, calling wilcoxsign_test leads to this error: , | Error in formula2data(formula, data, subset, frame = parent.frame(), ...) : | could not find function ModelEnvFormula ` Now, formula2data is an unexported function in the coin package and ModelEnvFormula is a (exported) function in modeltools. So, I tried to import ModelEnvFormula from modeltools -- no avail. And I tried to import formula2data from coin -- not possible And I tried to import the whole coin package -- no avail. So, here is the question: How do I import 'wilcoxsign_test' from the coin package in a way, that it is usable? Many thanks in advance. Regards, Andreas __ 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.
Re: [R] Help with passing in name of XTS file into write.table as a variable.
It is a simple change. If you don't save the results of getSymbol() into a variable, then it's not available for write.table() to write. Try mydata - getSymbols(ticker,from='1990-01-01') write.table( mydata, {etc}) The help for write.table says that x (the first argument to write.table), contains the data to be written to the file (it says object to be written, not data to be written, but that's essentially what it means). The content of your variable tickler is IBM so it writes that to the file. -Don p.s., this is so basic that I'd suggest you try to spend some time with some of the introductory R documentation. Best wishies! -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 5/8/14 4:19 PM, yanni...@gmail.com yanni...@gmail.com wrote: Hi y'all, I'm using quantmod's getSymbols function, which retrieves data in XTS format. I'm trying to pass IBM into the ticker variable, then write the table referencing ticker. However, when I run the write.table command, it writes IBM, not the data inside IBM. Do you have any thoughts on how to fix this? I imagine it's a simple change. Thank you much! ticker=IBM getSymbols(ticker,from='1990-01-01') write.table(ticker,file=deleteme.csv, col.names=FALSE, sep=',') write.table(as.data.frame(ticker),file=deleteme2.csv, col.names=FALSE, sep=',') -- Yan Wu 510-333-3188 http://bigkidsbighearts.org yanni...@gmail.com [[alternative HTML version deleted]] __ 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-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.
Re: [R] transition from depends to imports
On 09/05/2014, 5:08 PM, Andreas Leha wrote: Hi all, I am having trouble to do a particular transition from depends to imports in one of my packages. This packages uses 'wilcoxsign_test' from the 'coin' package. And this is the only function from the coin package that it uses (directly). (Everything works fine, as long as my package depends on the coin package.) My guess was, that I would need to only import that function from the coin package. (I.e. to move the coin package from Depends to Imports in the DESCRIPTION and in the NAMESPACE do 'importFrom(coin,wilcoxsign_test)'.) But then, calling wilcoxsign_test leads to this error: , | Error in formula2data(formula, data, subset, frame = parent.frame(), ...) : | could not find function ModelEnvFormula ` Now, formula2data is an unexported function in the coin package and ModelEnvFormula is a (exported) function in modeltools. So, I tried to import ModelEnvFormula from modeltools -- no avail. And I tried to import formula2data from coin -- not possible And I tried to import the whole coin package -- no avail. So, here is the question: How do I import 'wilcoxsign_test' from the coin package in a way, that it is usable? Which version of the packages are you using? The current version of coin imports ModelEnvFormula from modeltools, so it should be able to find that function. Duncan Murdoch __ 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.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Hi, Duncan: Thanks very much. I used to think that everything in R was a object. Now I know that is.object(quote(x)) is FALSE. (A decade ago, S-Plus asked me if I wanted to save changes to history. I thought, Wow! Do I get to change history? Hadley's Advanced R book mentions Reference classes in his OO field guide. It includes an example where changing a changes a copy previously made: b - a b$balance # [1] 200 a$balance - 0 b$balance # [1] 0 This bothers me far more than an object in R that's not an object ;-) Best Wishes, Spencer On 5/9/2014 6:48 AM, Bert Gunter wrote: Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert this to x$y for a diagnostic message. class(quote(x$y)) = call, which suggests I could write as.character.call to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ 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,
[R] adding rows
Dear useRs, I have a matrix, say el of 30 rows and 10 columns, as el-matrix(sample(1:300),ncol=10) I want to sum up various sets of three rows of each column in the following manner sum(el[c(1,2,3),]) ##adding row number 1, 2 and 3 of each column sum(el[c(2,3,4),])##adding row number 2, 3 and 4 of each column sum(el[c(3,4,5),])##adding row number 3, 4 and 5 of each column sum(el[c(4,5,6),]) sum(el[c(5,6,7),]) sum(el[c(6,7,8),]) sum(el[c(7,8,9),]) sum(el[c(8,9,10),]) sum(el[c(9,10,11),]) .. so on .. I know how to do it manually, but since my original matrix has 2000 rows, I therefore want to figure out a more conveinient way. Thankyou so very much in advance, Eliza [[alternative HTML version deleted]] __ 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.
Re: [R] transition from depends to imports
Hi Duncan, Thank you for your follow-up and fast response! Duncan Murdoch murdoch.dun...@gmail.com writes: On 09/05/2014, 5:08 PM, Andreas Leha wrote: Hi all, I am having trouble to do a particular transition from depends to imports in one of my packages. This packages uses 'wilcoxsign_test' from the 'coin' package. And this is the only function from the coin package that it uses (directly). (Everything works fine, as long as my package depends on the coin package.) My guess was, that I would need to only import that function from the coin package. (I.e. to move the coin package from Depends to Imports in the DESCRIPTION and in the NAMESPACE do 'importFrom(coin,wilcoxsign_test)'.) But then, calling wilcoxsign_test leads to this error: , | Error in formula2data(formula, data, subset, frame = parent.frame(), ...) : | could not find function ModelEnvFormula ` Now, formula2data is an unexported function in the coin package and ModelEnvFormula is a (exported) function in modeltools. So, I tried to import ModelEnvFormula from modeltools -- no avail. And I tried to import formula2data from coin -- not possible And I tried to import the whole coin package -- no avail. So, here is the question: How do I import 'wilcoxsign_test' from the coin package in a way, that it is usable? Which version of the packages are you using? The current version of coin imports ModelEnvFormula from modeltools, so it should be able to find that function. Duncan Murdoch As it seems, the version I use(d) depends on modeltools. , | packageDescription(coin) | Package: coin | Title: Conditional Inference Procedures in a Permutation Test Framework | Date: 2013-04-26 | Version: 1.0-22 | Author: Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel and Achim | Zeileis | Maintainer: Torsten Hothorn torsten.hoth...@r-project.org | Description: Conditional inference procedures for the general | independence problem including two-sample, K-sample | (non-parametric ANOVA), correlation, censored, ordered and | multivariate problems. | Depends: R (= 2.2.0), methods, survival, mvtnorm (= 0.8-0), | modeltools (= 0.2-9) | Suggests: multcomp, xtable, e1071, vcd | Enhances: Biobase | LazyLoad: yes | LazyData: yes | License: GPL-2 | Packaged: 2013-04-26 12:33:15 UTC; hothorn | NeedsCompilation: yes | Repository: CRAN | Date/Publication: 2013-04-26 15:27:04 | Built: R 3.0.1; x86_64-pc-linux-gnu; 2013-05-29 16:07:42 UTC; unix | | -- File: /usr/lib/R/site-library/coin/Meta/package.rds ` I can confirm that updating coin (to version 1.1-0) did resolve my problem. Thank you very much! This leads to the follow-up question: How would I have correctly dealt with this situation if my dependency ('coin') had not been updated? Regards, Andreas __ 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.
Re: [R] transition from depends to imports
On 09/05/2014, 5:39 PM, Andreas Leha wrote: Hi Duncan, Thank you for your follow-up and fast response! Duncan Murdoch murdoch.dun...@gmail.com writes: On 09/05/2014, 5:08 PM, Andreas Leha wrote: Hi all, I am having trouble to do a particular transition from depends to imports in one of my packages. This packages uses 'wilcoxsign_test' from the 'coin' package. And this is the only function from the coin package that it uses (directly). (Everything works fine, as long as my package depends on the coin package.) My guess was, that I would need to only import that function from the coin package. (I.e. to move the coin package from Depends to Imports in the DESCRIPTION and in the NAMESPACE do 'importFrom(coin,wilcoxsign_test)'.) But then, calling wilcoxsign_test leads to this error: , | Error in formula2data(formula, data, subset, frame = parent.frame(), ...) : | could not find function ModelEnvFormula ` Now, formula2data is an unexported function in the coin package and ModelEnvFormula is a (exported) function in modeltools. So, I tried to import ModelEnvFormula from modeltools -- no avail. And I tried to import formula2data from coin -- not possible And I tried to import the whole coin package -- no avail. So, here is the question: How do I import 'wilcoxsign_test' from the coin package in a way, that it is usable? Which version of the packages are you using? The current version of coin imports ModelEnvFormula from modeltools, so it should be able to find that function. Duncan Murdoch As it seems, the version I use(d) depends on modeltools. , | packageDescription(coin) | Package: coin | Title: Conditional Inference Procedures in a Permutation Test Framework | Date: 2013-04-26 | Version: 1.0-22 | Author: Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel and Achim | Zeileis | Maintainer: Torsten Hothorn torsten.hoth...@r-project.org | Description: Conditional inference procedures for the general | independence problem including two-sample, K-sample | (non-parametric ANOVA), correlation, censored, ordered and | multivariate problems. | Depends: R (= 2.2.0), methods, survival, mvtnorm (= 0.8-0), | modeltools (= 0.2-9) | Suggests: multcomp, xtable, e1071, vcd | Enhances: Biobase | LazyLoad: yes | LazyData: yes | License: GPL-2 | Packaged: 2013-04-26 12:33:15 UTC; hothorn | NeedsCompilation: yes | Repository: CRAN | Date/Publication: 2013-04-26 15:27:04 | Built: R 3.0.1; x86_64-pc-linux-gnu; 2013-05-29 16:07:42 UTC; unix | | -- File: /usr/lib/R/site-library/coin/Meta/package.rds ` I can confirm that updating coin (to version 1.1-0) did resolve my problem. Thank you very much! This leads to the follow-up question: How would I have correctly dealt with this situation if my dependency ('coin') had not been updated? I think the only workaround would be for you to say your package Depends on modeltools. It's really a coin issue, not yours, and the right people fixed it. Duncan Murdoch __ 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.
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Hadley On Fri, May 9, 2014 at 4:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hi, Duncan: Thanks very much. I used to think that everything in R was a object. Now I know that is.object(quote(x)) is FALSE. (A decade ago, S-Plus asked me if I wanted to save changes to history. I thought, Wow! Do I get to change history? Hadley's Advanced R book mentions Reference classes in his OO field guide. It includes an example where changing a changes a copy previously made: b - a b$balance # [1] 200 a$balance - 0 b$balance # [1] 0 This bothers me far more than an object in R that's not an object ;-) Best Wishes, Spencer On 5/9/2014 6:48 AM, Bert Gunter wrote: Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: Is there a simple utility someplace to convert quote(x$y) to x$y? I ask, because as.character(quote(x$y)) is a character vector of length 3 = $ x y. I want to convert
Re: [R] as.character(quote(x$y) ) = $ x y not x$y?
Dear Hadley: Thanks for that. Digits are not numbers. Numbers are not data. Data is not information. Information is not intelligence. Intelligence is not knowledge. Knowledge is not wisdom. And your is. warnings are more useful than my trivia here. Spencer On 5/9/2014 2:42 PM, Hadley Wickham wrote: Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs Hadley On Fri, May 9, 2014 at 4:32 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hi, Duncan: Thanks very much. I used to think that everything in R was a object. Now I know that is.object(quote(x)) is FALSE. (A decade ago, S-Plus asked me if I wanted to save changes to history. I thought, Wow! Do I get to change history? Hadley's Advanced R book mentions Reference classes in his OO field guide. It includes an example where changing a changes a copy previously made: b - a b$balance # [1] 200 a$balance - 0 b$balance # [1] 0 This bothers me far more than an object in R that's not an object ;-) Best Wishes, Spencer On 5/9/2014 6:48 AM, Bert Gunter wrote: Ahhh. Thanks Duncan. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 09/05/2014, 2:41 AM, Bert Gunter wrote: Spencer: Hmmm Well, I don't get what's going on here -- as.character.default is internal -- but could you method-ize a simple synonym: See ?InternalMethods: For efficiency, internal dispatch only occurs on objects, that is those for which is.object returns true. Duncan Murdoch asChar- function(e,...)UseMethod(asChar) asChar.call - function(e,...)deparse(e,...) asChar.default - function(e,...)as.character(e,...) asChar(xDy) [1] x$y asChar(1:5) [1] 1 2 3 4 5 Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 8:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 5/8/2014 8:05 PM, Bert Gunter wrote: [1] x$y Spencer: Does deparse(substitute(x$y)) [1] x$y do what you want? No: The problem is methods dispatch. class(quote(x$y)) = 'call', but as.character(quote(x$y)) does NOT go to as.character.call. deparse(quote(x$y)) returns the answer I want, as Greg Snow noted earlier. However, it would be easier to remember if I could write as.character(quote(x$y)) and get the same thing. With as.character.call - function(x, ...)deparse(x, ...), as.character.call(quote(x$y)) returns x$y, as desired. However, the methods dispatch one might naively expect fails, as noted above. Thanks, Spencer Cheers, Bert -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, May 8, 2014 at 5:56 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: as.character.call seems not to work as an alias for deparse. Consider the following: xDy - quote(x$y) class(xDy) call as.character.call - function(x, ...)deparse(x, ...) as.character(xDy) [1] $ x y # fails str(xDy) # language x$y as.character.language - function(x, ...)language as.character(xDy) [1] $ x y Is it feasible to construct a method for as.character that works for objects of class call? Thanks, Spencer # Thanks for the quick replies from Richard Heiberger, Greg Show Bert Gunter. Might it make sense to create as.character.call as an alias for deparse? A few years ago, I wrote several functions like predict.fd as aliases for functions with less memorable names like eval.fd. Doing that made the fda package easier to use, at least for me ;-) Thanks again, Spencer On 5/7/2014 2:39 PM, Bert Gunter wrote: ... and str(quote(x$y)) language x$y as.list(quote(x$y)) [[1]] `$` [[2]] x [[3]] y ## may be instructive. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Wed, May 7, 2014 at 2:30 PM, Greg Snow 538...@gmail.com wrote: deparse(quote(x$y)) [1] x$y It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello,
Re: [R] transition from depends to imports
Duncan Murdoch murdoch.dun...@gmail.com writes: On 09/05/2014, 5:39 PM, Andreas Leha wrote: Hi Duncan, Thank you for your follow-up and fast response! Duncan Murdoch murdoch.dun...@gmail.com writes: On 09/05/2014, 5:08 PM, Andreas Leha wrote: Hi all, I am having trouble to do a particular transition from depends to imports in one of my packages. This packages uses 'wilcoxsign_test' from the 'coin' package. And this is the only function from the coin package that it uses (directly). (Everything works fine, as long as my package depends on the coin package.) My guess was, that I would need to only import that function from the coin package. (I.e. to move the coin package from Depends to Imports in the DESCRIPTION and in the NAMESPACE do 'importFrom(coin,wilcoxsign_test)'.) But then, calling wilcoxsign_test leads to this error: , | Error in formula2data(formula, data, subset, frame = parent.frame(), ...) : | could not find function ModelEnvFormula ` Now, formula2data is an unexported function in the coin package and ModelEnvFormula is a (exported) function in modeltools. So, I tried to import ModelEnvFormula from modeltools -- no avail. And I tried to import formula2data from coin -- not possible And I tried to import the whole coin package -- no avail. So, here is the question: How do I import 'wilcoxsign_test' from the coin package in a way, that it is usable? Which version of the packages are you using? The current version of coin imports ModelEnvFormula from modeltools, so it should be able to find that function. Duncan Murdoch As it seems, the version I use(d) depends on modeltools. , | packageDescription(coin) | Package: coin | Title: Conditional Inference Procedures in a Permutation Test Framework | Date: 2013-04-26 | Version: 1.0-22 | Author: Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel and Achim | Zeileis | Maintainer: Torsten Hothorn torsten.hoth...@r-project.org | Description: Conditional inference procedures for the general | independence problem including two-sample, K-sample | (non-parametric ANOVA), correlation, censored, ordered and | multivariate problems. | Depends: R (= 2.2.0), methods, survival, mvtnorm (= 0.8-0), | modeltools (= 0.2-9) | Suggests: multcomp, xtable, e1071, vcd | Enhances: Biobase | LazyLoad: yes | LazyData: yes | License: GPL-2 | Packaged: 2013-04-26 12:33:15 UTC; hothorn | NeedsCompilation: yes | Repository: CRAN | Date/Publication: 2013-04-26 15:27:04 | Built: R 3.0.1; x86_64-pc-linux-gnu; 2013-05-29 16:07:42 UTC; unix | | -- File: /usr/lib/R/site-library/coin/Meta/package.rds ` I can confirm that updating coin (to version 1.1-0) did resolve my problem. Thank you very much! This leads to the follow-up question: How would I have correctly dealt with this situation if my dependency ('coin') had not been updated? I think the only workaround would be for you to say your package Depends on modeltools. It's really a coin issue, not yours, and the right people fixed it. They did, indeed. Thank you for the info and for your quick help on this! Regards, Andreas __ 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.
Re: [R] adding rows
Hello, Try the following. sapply(1:(30 - 2), function(i) sum(el[i:(i+2), ])) but with number of rows instead of 30. Hope this helps, Rui Barradas Em 09-05-2014 22:35, eliza botto escreveu: Dear useRs, I have a matrix, say el of 30 rows and 10 columns, as el-matrix(sample(1:300),ncol=10) I want to sum up various sets of three rows of each column in the following manner sum(el[c(1,2,3),]) ##adding row number 1, 2 and 3 of each column sum(el[c(2,3,4),])##adding row number 2, 3 and 4 of each column sum(el[c(3,4,5),])##adding row number 3, 4 and 5 of each column sum(el[c(4,5,6),]) sum(el[c(5,6,7),]) sum(el[c(6,7,8),]) sum(el[c(7,8,9),]) sum(el[c(8,9,10),]) sum(el[c(9,10,11),]) .. so on .. I know how to do it manually, but since my original matrix has 2000 rows, I therefore want to figure out a more conveinient way. Thankyou so very much in advance, Eliza [[alternative HTML version deleted]] __ 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-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.
Re: [R] adding rows
Dear Rui and Murphy, Thanks for your help. Eliza Date: Fri, 9 May 2014 22:55:27 +0100 From: ruipbarra...@sapo.pt To: eliza_bo...@hotmail.com; r-help@r-project.org Subject: Re: [R] adding rows Hello, Try the following. sapply(1:(30 - 2), function(i) sum(el[i:(i+2), ])) but with number of rows instead of 30. Hope this helps, Rui Barradas Em 09-05-2014 22:35, eliza botto escreveu: Dear useRs, I have a matrix, say el of 30 rows and 10 columns, as el-matrix(sample(1:300),ncol=10) I want to sum up various sets of three rows of each column in the following manner sum(el[c(1,2,3),]) ##adding row number 1, 2 and 3 of each column sum(el[c(2,3,4),])##adding row number 2, 3 and 4 of each column sum(el[c(3,4,5),])##adding row number 3, 4 and 5 of each column sum(el[c(4,5,6),]) sum(el[c(5,6,7),]) sum(el[c(6,7,8),]) sum(el[c(7,8,9),]) sum(el[c(8,9,10),]) sum(el[c(9,10,11),]) .. so on .. I know how to do it manually, but since my original matrix has 2000 rows, I therefore want to figure out a more conveinient way. Thankyou so very much in advance, Eliza [[alternative HTML version deleted]] __ 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. [[alternative HTML version deleted]] __ 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.
Re: [R] Lattice Histogram with Normal Curve - Y axis as percentages
Just an afterthought if any one really needs to do it again. The crux of the matter is the different limits in the 2 plot x and y scales. It may be easier to accomplish this with a prepanel function to get the limits eg panel.loess Duncan -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jimdare Sent: Wednesday, 7 May 2014 14:53 To: r-help@r-project.org Subject: Re: [R] Lattice Histogram with Normal Curve - Y axis as percentages Thanks for your help Duncan and Peter! I ended up using a combination of your suggestions. I used Duncan's y.limits ration of two plots with differing types (percent and density), to provide me with a scale variable. I then used this in Peter's dnorm_scaled function and called it using panel.mathdensity. See below for my amended code. Regards, Jim x1-histogram(~rdf[,j]|Year,nint=20, data=rdf,main = i,strip = my.strip,xlab = j, type = density,layout=c(2,1)) x2-histogram(~rdf[,j]|Year,nint=20, data=rdf,main = i,strip = my.strip,xlab = j, type = percent,layout=c(2,1)) scale - x2$y.limits/x1$y.limits dnorm_scaled - function(...){ scale[1]*dnorm(...)} histogram(~rdf[,j]|Year,nint=20, data=rdf,main = i,strip = my.strip,xlab = j, type = percent,layout=c(2,1), panel=function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath=dnorm_scaled, col=black, # Add na.rm = TRUE to mean() and sd() args=list(mean=mean(x, na.rm = TRUE), sd=sd(x, na.rm = TRUE)), ...) }) -- View this message in context: http://r.789695.n4.nabble.com/Lattice-Histogram-with-Normal-Curve-Y-axis-as- percentages-tp469p4690093.html Sent from the R help mailing list archive at Nabble.com. __ 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-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.