[R] Fw: Value of 'pi'
Indeed, Indiana had a go at pi. Have a look here http://en.wikipedia.org/wiki/Indiana_Pi_Bill Dr. Iasonas Lamprianou Department of Social and Political Sciences University of Cyprus [[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] need help for R Installation in AIX 5.3
Dear Sir/ Madam, I am trying to install R in my AIX-5.3 machine but its giving some error during configuration as given below: checking how to hardcode library paths into programs... immediate checking for cos in -lm... yes checking for sin in -lm... yes checking for dlopen in -ldl... yes checking readline/history.h usability... no checking readline/history.h presence... no checking for readline/history.h... no checking readline/readline.h usability... no checking readline/readline.h presence... no checking for readline/readline.h... no checking for rl_callback_read_char in -lreadline... no checking for main in -lncurses... no checking for main in -ltermcap... no checking for main in -ltermlib... no checking for rl_callback_read_char in -lreadline... no checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available I have attached its log file with this mail. Please help me. Earliest reply will be appreciated. -- * Regards* ** ** *HARVIR SINGH http://www.harvir007.webs.com* * P. Scientist-C ** NCMRWF NOIDA INDIA *** __ 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] [Plea to the R Gods] Theoretical and Empirical CDFs
http://r.789695.n4.nabble.com/file/n3567636/ecdfs.jpg ecdfs.jpg http://r.789695.n4.nabble.com/file/n3567636/ecdf_curve.gif ecdf_curve.gif Hello, I have generated a plot of two empirical CDFs (attachment 1). As a result, they are stepwise when plotted. The following code was used: plot(ecdf(mut), do.points=FALSE, verticals=TRUE, xlim=range(mut, non), col=red) plot(ecdf(non), do.points=FALSE, verticals=TRUE, add=TRUE, col=blue) But what I need instead are smooth curves, similar to ones that are generated from a theoretical cdf (attachment 2). I have looked at so many threads; one suggestion to someone else was to use library(fitdistplot) and look for distributions that may fit (e.g. weibull). But I could really use guidance before spending additional time on this. Thank you! -TW -- View this message in context: http://r.789695.n4.nabble.com/Plea-to-the-R-Gods-Theoretical-and-Empirical-CDFs-tp3567636p3567636.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.
Re: [R] subsetting with condition
Thank you all, tried all options and it gives me exactly what I needed! Many many thanks again) to Bert, oh, I see, yes, next time I will do that. Kristina -- View this message in context: http://r.789695.n4.nabble.com/subsetting-with-condition-tp3567193p3567645.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] Random Selection of numbers
Hello, I am attempting to randomly select a data of equal length from my dataset. My dataset is of equal length each ranging from 1 to 16 rows. Since they are of equal length, I can form a matrix of equal length and rows or concatenate them into a data of 16n x 2 matrix where n is number of samples. I have reproduced small part of the data below. Now the problem is how to select as many samples of the same length (i.e. 16 rows) as possible from the two dataset below. If the first is taken as X1 and the second as X2, manually selecting from the 4th row of X1 to 3rd row of X2 gives a data of length 16, from 5th row of X1 to 4th row of X2 gives a data of length 16, etc. This implies choosing any row from X1 and counting 15 rows down from that to get 16 rows. I can then concatenate these new samples to the original sample and sort them out to do my work. Doing this random selection manually when my dataset becomes larger may not be good. I will be obliged should anyone suggests how I can do this in R. Thank you Best regards Ogbos 1 703116 2 243714 3 297060 4 307697 5 296588 6 255266 7 297116 8 291530 9 239259 10 239126 11 212396 12 202471 13 227833 14 212977 15 207408 16 228564 1 230414 2 15372 3 19647 4 29523 5 26234 6 34766 7 16738 8 25215 9 20757 10 31250 11 27993 12 24441 13 19853 14 20751 15 7658 16 5934 [[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] allowing individual level correlations to differ by cluster in lme in R
Dear R-listers, I am fitting bivariate mixed models for cost-effectiveness data of cluster randomized trials using lme in R. So I have individuals nested within clusters. My response variable is a vector with bivariate response (individual level costs and effects) stacked into a single column. The covariates in my models are a constant and a treatment term. They are response-specific, e.g. a constant for cost (cons.1) and one for effect (cons.2) , a treatment term for cost (treat.1) and one for effect (treat.2). The syntax I used is this: lme(yl~ -1+cons.1+treat.1+cons.2+treat.2, random=~-1+cons.1+cons.2|cidl, weights=varIdent(form=~1|cons.1), corr=corCompSymm(form=~1|cidl/indl), data=datalong) where cidl = cluster id, indl = individual id and datalong = data (also data had been stacked before model fitting) I have been trying to extend this model to allow individual level standard deviations and correlations to differ by cluster. In my data, there is evidence that SDs for costs and effects and correlations between costs and effects differ by cluster. I have worked out the code to account for the former but not both (see code below). lme(yl~ -1+cons.1+treat.1+cons.2+treat.2, random=~-1+cons.1+cons.2|cidl, weights=varIdent(form=~1|resp.cidl), corr=corCompSymm(form=~1|cidl/indl), data=datalong, control=lmc2) # SANN: 20k iterations where resp.cidl = response-specific cluster id, lmc2 = a lmcControl object specifying SANN as optimisation method among other settings I would like to find out if there is a way to allow for the correlations to differ by cluster via the corr option. Any suggestion or pointer would be greatly appreciated. Many thanks in advance. Best wishes, Edmond +++ Edmond Ng, MSc CStat CSci Lecturer in Medical Statistics Department of Health Services Research and Policy, Faculty of Public Health and Policy London School of Hygiene and Tropical Medicine, 15-17 Tavistock Place, London WC1H 9SH, UK Tel: +44 (0)20 7927 2366 (direct line: ext 2065) Fax: +44 (0)20 7927 2701 Website: http://www.lshtm.ac.uk/hsru +++ [[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] need help for R Installation in AIX 5.3
1) Please ask about R installation on the R-devel list: as the posting guide says Questions likely to prompt discussion unintelligible to non-programmers should go to to R-devel. 2) This is covered quite explicitly in the 'R Installation and Administration Manual'. Search for 'readline' there, and also make sure you have studied the section on installation on AIX (which also mentions this). 3) You always need to mention the version of R you are trying to install. On Thu, 2 Jun 2011, Harvir Singh wrote: Dear Sir/ Madam, I am trying to install R in my AIX-5.3 machine but its giving some error during configuration as given below: checking how to hardcode library paths into programs... immediate checking for cos in -lm... yes checking for sin in -lm... yes checking for dlopen in -ldl... yes checking readline/history.h usability... no checking readline/history.h presence... no checking for readline/history.h... no checking readline/readline.h usability... no checking readline/readline.h presence... no checking for readline/readline.h... no checking for rl_callback_read_char in -lreadline... no checking for main in -lncurses... no checking for main in -ltermcap... no checking for main in -ltermlib... no checking for rl_callback_read_char in -lreadline... no checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available I have attached its log file with this mail. Please help me. Earliest reply will be appreciated. -- * Regards* ** ** *HARVIR SINGH http://www.harvir007.webs.com* * P. Scientist-C ** NCMRWF NOIDA INDIA *** -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] based on mean and std
Dear all, I have a few gaussian distributions with known (mean and sd). How can I plot in R easily the cdf of them? In matlab there is a guid where you can give the values and have the plots ready. Is anything like that in R? Best Regards Alex __ 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] Metafor: Differences between two categories of a moderator
Well, that's a good question. It actually applies to many different contexts (not just meta-analysis). Think of the ANOVA F-test and post-hoc/planned contrasts. It's essentially the same situation. And if you would ask 10 different statisticians about this, you may get 11 different answers. My suggestion would be this: If you have no particular hypotheses in mind and are just screening for group differences, then adjust. If you have a priori hypotheses, then test them without adjustment (and in that case, you may even ignore the omnibus test). Best, -- Wolfgang Viechtbauer Department of Psychiatry and Neuropsychology School for Mental Health and Neuroscience Maastricht University, P.O. Box 616 6200 MD Maastricht, The Netherlands Tel: +31 (43) 368-5248 Fax: +31 (43) 368-8689 Web: http://www.wvbauer.com From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Holger Steinmetz [holger.steinm...@web.de] Sent: Wednesday, June 01, 2011 10:10 AM To: r-help@r-project.org Subject: Re: [R] Metafor: Differences between two categories of a moderator Hi Wolfgang that's good news. One further small follow-up question: When I conduct multiple comparisons via the relevel-command: should I adjust the p-value? Thanks in advance, Holger -- View this message in context: http://r.789695.n4.nabble.com/Metafor-Differences-between-two-categories-of-a-moderator-tp3562778p3565210.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.
Re: [R] based on mean and std
You can plot explicitly over a range of x; for example x-seq(10, 15, 0.1) #for mean 12.5, sd 0.6 plot(x, pnorm(x, 12.5, 0.6), type=l, ylim=c(0,1) Or you can try the default plot for a univariate function (see ?curve) plot(function(x) pnorm(x, 12.5, 0.6), xlim=c(10,15)) #Note use of the function definition to include explicit mean and sd S Ellison -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: 02 June 2011 12:06 To: R-help@r-project.org Subject: [R] based on mean and std Dear all, I have a few gaussian distributions with known (mean and sd). How can I plot in R easily the cdf of them? In matlab there is a guid where you can give the values and have the plots ready. Is anything like that in R? Best Regards Alex __ 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. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] based on mean and std
You could try: f - function(x){pnorm(x,mean=10,sd=20)} curve(f,from=-10,to=30) Or: x - seq(-10,30,len=101) y - pnorm(x,mean=10,sd=20) plot(x,y,type=l) -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky On 06/02/2011 07:05 AM, Alaios wrote: Dear all, I have a few gaussian distributions with known (mean and sd). How can I plot in R easily the cdf of them? In matlab there is a guid where you can give the values and have the plots ready. Is anything like that in R? Best Regards Alex __ 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] Text Summarization
What is wrong with lsa? You could contact author of that package if it is close and discuss better options if no one here can help. your latest def just reiterate summarization but that you want complrtr sentences. if you can site specific algor or impl and go to a sig list may be more help Sent from my Verizon Wireless BlackBerry -Original Message- From: Ravishankar Rajagopalan viora...@gmail.com Date: Thu, 2 Jun 2011 16:29:59 To: Mike Marchywkamarchy...@hotmail.com Cc: r-help@r-project.org Subject: Re: [R] Text Summarization Hi Mike, Thanks for your inputs. Well, this is not really a research topic :) There are software already available to do text summarization. I was just wondering whether we could do it in R itself. The document you sent is what I exactly referred to before I sent my first email. Below Table 1 in that paper, they have defined Summarization as summarization of important concepts in a text. Typically these are highfrequency terms. As I mentioned in my first post, I don't see summarization as just a bag of high frequency words. It is usually summary containing meaningful sentences. Also, there is no reference to summarization after that in the document. It doesn't refer to any R package/command to do what I am looking for :( Thanks again for your help. Regards, Ravishankar Rajagopalan On Wed, Jun 1, 2011 at 4:49 PM, Mike Marchywka marchy...@hotmail.comwrote: Date: Wed, 1 Jun 2011 10:01:14 +0530 Subject: Re: [R] Text Summarization From: viora...@gmail.com To: marchy...@hotmail.com CC: r-help@r-project.org Mike, This is what I am looking for. http://en.wikipedia.org/wiki/Automatic_summarization I want to obtain a summary of a huge document as meaningful sentences. I do not want a bag of words as the output. I have 1000's of documents each one running to 3-4 pages. I plan to use R to do clustering/classification of these documents. Instead of working with the original document, I think it would be better to work with a summary of the documents since this would avoid memory issues. Well, it seems to be a bit of a research topic so I presume you are looking for starting points rather than specific final solution. I did manage to do a google search ( for which I feel quite accopmlished as getting a browser to work any more is quite a chore, firefox on hotmail is very slow and IE seems to not like to download googlecode pdf LOL), http://www.google.com/search?hl=enq=%2B%22CRAN%22+%22computational+linguistics%22+%22document+summarization%22 The first hit I get is something called Text Mining Infrastrcture in R( to which I can not easily post a link since the link in goog hit is redirect through goog and browser downloads and opens temp file...) For clustering or classification you may not care too much about semantics, word frequncies may work etc. I guess this term could be use too, http://en.wikipedia.org/wiki/Latent_semantic_analysis Fridolin Wild (November 23, 2005). An Open Source LSA Package for R. CRAN. Retrieved 2006-11-20. Thank you. Ravi On Tue, May 31, 2011 at 10:02 PM, Mike Marchywka wrote: Date: Tue, 31 May 2011 03:25:56 -0700 From: viora...@gmail.com To: r-help@r-project.org Subject: [R] Text Summarization Is there a text mining/ NLP package in R that could do text summarization? For example, take a huge text as input and provide a summary of the text. In package tm, summarization is defined more as high frequency terms which is not what I want. I actually want a summary of what is present in the huge volume of text. Cliff's notes? Can you define it more precisely? There are some computational linguistics packages IIRC. Any help on a R package would be helpful. Thank you. Ravi -- View this message in context: http://r.789695.n4.nabble.com/Text-Summarization-tp3562735p3562735.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.htmlhttp://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] [Plea to the R Gods] Theoretical and Empirical CDFs
On 06/02/2011 02:18 AM, teriri wrote: I have generated a plot of two empirical CDFs (attachment 1). As a result, they are stepwise when plotted. ... But what I need instead are smooth curves, similar to ones that are generated from a theoretical cdf (attachment 2). To obtain a smooth curve, you would need to estimate the density, which, from a statistical standpoint, is a vastly different problem. Once you have a density, however, you could integrate it to obtain the cdf: x - rnorm(10) fit - density(x) plot(fit$x[-1],diff(fit$x)*cumsum(fit$y)[-1],type=l) ## For comparison: plot(ecdf(x),add=TRUE,do.points=FALSE,verticals=TRUE) Please be aware, however, that density estimation is a complicated topic with an extensive literature. -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky __ 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] (no subject)
Error in lda.default(x, grouping, ...) : variables 1 3 5 8 10 15 17 20 27 29 34 appear to be constant within groups what this sentence means?? [[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] re-write plot function for ggplot
I have been browsing the pages about ggplot and it really doesn't deal with such problems as far as I can see. -- View this message in context: http://r.789695.n4.nabble.com/re-write-plot-function-for-ggplot-tp3565868p3568025.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] Export a function from RCPP in R of type double
Hello to everyone I have written a small c++ function of type double function(double,double); and i want to export it in R using RCPP. After some trials i have realized that the only way i could do it working is to declare the function as void function (double x, double y, double result) and pass the result with RCPP Can you please tell me if this is the only way out? And if this is the case how I can implement a function with is recurence property eg a Factorial funtion int factorial (int a){ a=factorial(a-1);} tnks in advance for your help -- View this message in context: http://r.789695.n4.nabble.com/Export-a-function-from-RCPP-in-R-of-type-double-tp3567793p3567793.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.
Re: [R] BiodiversityR GUI on macosx
János Korponai korponai.janos at nyuduvizig.hu writes: Dear List! I installed R and quite a few packages I use. When I try to start BiodiversityR the library loads without any problems but GUI do not start. Rcmdr loads without any problems. I am using R 2.13.0 64 bit. Downgrade to R 2.12.2 works. Doesn't work here (Ubuntu 2.13.0) either. It looks like the problem may be some change either in R Commander (the Rcmdr package on which the GUI is built) or in R 2.13.0 such that require(Rcmdr) does not pop up the GUI automatically. Your best bet would probably be to contact the maintainers of the package [maintainer(BiodiversityR)] for help, who may in turn need to work with John Fox (author of Rcmdr). Ben Bolker __ 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] ylab spacing in resizePanels in latticeExtra
Indeed, ylab position is not connected to the panel size / position. You would have to place them manually... ## scaling factors on panels h - c(5,3,4) update(ABCur, ylab = list(c(AAA, BBB, CCC), rot=0, y = (cumsum(h) - h/2) / sum(h) )) Cheers Felix On 2 June 2011 13:59, Richard M. Heiberger r...@temple.edu wrote: I would like the ylab in the second, resized graph to be centered on the actual positions of the panels of the second graph, not on the positions appropriate for the first graph. How can that be specified. Toggle the two graphs to see that the ylab is identically spaced in both, even though the panels are differently sized. Thanks, Rich windows.options(record=TRUE) ## We need to compare two graphs. This is the correct statement for windows. require(lattice) require(latticeExtra) A - barchart(matrix(1:10,5,2)) B - barchart(matrix(1:6,3,2)) C - barchart(matrix(1:8,4,2)) ABC - c(A, B, C, x.same=TRUE, layout=c(1,3)) ABCu - update(ABC, ylab=list(c(AAA, BBB, CCC), rot=0)) update(ABCu, main=ylab is centered on each of the panels) ABCur - resizePanels(ABCu, h=c(5,3,4)) update(ABCur, main=ylab is centered on previous panel positions.) [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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] Latin Hypercube Sampling with a condition
Duarte Viana viana.sptd at gmail.com writes: Hello all, I am trying to do a Latin Hypercube Sampling (LHS) to a 5-parameter design matrix. I start as follows: library(lhs) p1-randomLHS(1000, 5) If I check the distribution of each parameter (column), they are perfectly uniformly distributed (as expected).For example, hist(p1[,1]) Now the hard (maybe strange) question. I want the combination of the first three parameters to sum up to 1 (which obviously do not) s-p1[,1]+p1[,2]+p1[,3] s==1 It occurred to me to divide each of these parameters with the sum (vector s above). However the uniform distribution is lost (example for parameter 1 - first column): par1.transf-p1[,1]/s hist(par1.transf) So, is there a way to maintain the random LHS (with uniformly distributed parameters) so that the refered condition is fulfilled? Any suggestions would be much welcome. Thanks, Duarte Duarte, In my experience with Latin hypercube samples, most people draw the sample on a uniform hypercube and then transform the uniform cube to have new distributions on the margins. The transformed distributions are not necessarily uniform. It is possible to draw a Latin hypercube with correlated margins and I hope to add that to my package in the future. I have also done transforms such that the transformed marginal distributions are correlated (as you have in your example). I have not seen a correlated set of uniform marginal distributions such that the margins sum to one, however. I'll make a quick example argument that explains the difficulty... In two dimensions, you could draw this which is uniform and correlated. x - seq(0.05, 0.95, length=10) y - 1-x all.equal(x+y, rep(1, length(x))) hist(x) hist(y) But in three dimensions, it is hard to maintain uniformity because large samples on the first uniform margin overweight the small samples on the other margins. x - seq(0.05, 0.95, length=10) y - runif(length(x), 0, 1-x) z - 1-x-y hist(x) hist(y) hist(z) If you could explain why you want to maintain the uniformity on the margins, I might be able to suggest something different. Rob __ 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] mChoice prb in rms
Dear all, I´m trying to get a output table for age and the summary of a and b, stratified by epo as follows using summary.formula h-data.frame(a=sample(c(A,NA),100,replace=T),b=sample(c(B,NA),100,replace=T),age=rnorm(100,50,25),epo=sample(c(Y,N),100,T)) library(rms) summary.formula(epo~age+mChoice(a,b,label=test),method=reverse,data=h,na.rm=TRUE,test=T) Descriptive Statistics by epo +-+---+---++ | |N |Y | Test | | |(N=51) |(N=49) |Statistic | +-+---+---++ |age | 43.8/53.5/74.6| 30.8/48.8/69.3|F=1.68 d.f.=1,98 P=0.198| +-+---+---++ |test : NA| 0% (0)| 0% (0)|| +-+---+---++ |A| 0% (0)| 0% (0)|| +-+---+---++ |B| 0% (0)| 0% (0)|| +-+---+---++ Digging deeper I find that summary(mChoice(h$a,h$b)) h$a 4 unique combinations Frequencies of Numbers of Choices Per Observation nchoices 1 2 30 70 Pairwise Frequencies (Diagonal Contains Marginal Frequencies) 0 x 0 matrix Frequencies of All Combinations NA A;B NA;A NA;B 30 24 23 23 Somehow this doesnt carry over into the summary.formula output... Also, running example(mChoice) reproduces this whereby the 0% categories are also shown. Any ideas? //M __ 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] Reparamaterization for threshold values for ordinal regression
I'm writing a function for ordinal regression for an ad hoc situation. To estimate threshold parameters (4 levels), I applied reparameterization method to avoid using linear constraint suggested by C. Croux. This is working fine, but I have a problem finding varaince for the estimated parameters because it repamaterize as follows : r1 = b1, r2 = b1+b2^2 r3=b1+b2^2+b3^2. It ensures ordering the constraints , but I don't know how to get variances for r2 and r3 . Is ther e any other method? Kyong [[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] Latin Hypercube Sampling with a condition
I am not sure, but this thread from a couple of months ago might be relevant (and useful): https://stat.ethz.ch/pipermail/r-help/2011-March/273423.html Ravi. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of Rob Carnell [carne...@battelle.org] Sent: Thursday, June 02, 2011 8:30 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Latin Hypercube Sampling with a condition Duarte Viana viana.sptd at gmail.com writes: Hello all, I am trying to do a Latin Hypercube Sampling (LHS) to a 5-parameter design matrix. I start as follows: library(lhs) p1-randomLHS(1000, 5) If I check the distribution of each parameter (column), they are perfectly uniformly distributed (as expected).For example, hist(p1[,1]) Now the hard (maybe strange) question. I want the combination of the first three parameters to sum up to 1 (which obviously do not) s-p1[,1]+p1[,2]+p1[,3] s==1 It occurred to me to divide each of these parameters with the sum (vector s above). However the uniform distribution is lost (example for parameter 1 - first column): par1.transf-p1[,1]/s hist(par1.transf) So, is there a way to maintain the random LHS (with uniformly distributed parameters) so that the refered condition is fulfilled? Any suggestions would be much welcome. Thanks, Duarte Duarte, In my experience with Latin hypercube samples, most people draw the sample on a uniform hypercube and then transform the uniform cube to have new distributions on the margins. The transformed distributions are not necessarily uniform. It is possible to draw a Latin hypercube with correlated margins and I hope to add that to my package in the future. I have also done transforms such that the transformed marginal distributions are correlated (as you have in your example). I have not seen a correlated set of uniform marginal distributions such that the margins sum to one, however. I'll make a quick example argument that explains the difficulty... In two dimensions, you could draw this which is uniform and correlated. x - seq(0.05, 0.95, length=10) y - 1-x all.equal(x+y, rep(1, length(x))) hist(x) hist(y) But in three dimensions, it is hard to maintain uniformity because large samples on the first uniform margin overweight the small samples on the other margins. x - seq(0.05, 0.95, length=10) y - runif(length(x), 0, 1-x) z - 1-x-y hist(x) hist(y) hist(z) If you could explain why you want to maintain the uniformity on the margins, I might be able to suggest something different. Rob __ 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] Random Selection of numbers
On Thu, Jun 02, 2011 at 09:56:51AM +0200, ogbos okike wrote: Hello, I am attempting to randomly select a data of equal length from my dataset. My dataset is of equal length each ranging from 1 to 16 rows. Since they are of equal length, I can form a matrix of equal length and rows or concatenate them into a data of 16n x 2 matrix where n is number of samples. I have reproduced small part of the data below. Now the problem is how to select as many samples of the same length (i.e. 16 rows) as possible from the two dataset below. If the first is taken as X1 and the second as X2, manually selecting from the 4th row of X1 to 3rd row of X2 gives a data of length 16, from 5th row of X1 to 4th row of X2 gives a data of length 16, etc. This implies choosing any row from X1 and counting 15 rows down from that to get 16 rows. I can then concatenate these new samples to the original sample and sort them out to do my work. Doing this random selection manually when my dataset becomes larger may not be good. I will be obliged should anyone suggests how I can do this in R. Hello. Let me put your data as an R command for simplicity. x - c(703116, 243714, 297060, 307697, 296588, 255266, 297116, 291530, 239259, 239126, 212396, 202471, 227833, 212977, 207408, 228564, 230414, 15372, 19647, 29523, 26234, 34766, 16738, 25215, 20757, 31250, 27993, 24441, 19853, 20751, 7658, 5934) a - cbind(rep(1:16, times=2), x) If i is the starting index, is the following, what you ask for? i - 4 a[i:(i+15), ] x [1,] 4 307697 [2,] 5 296588 [3,] 6 255266 [4,] 7 297116 [5,] 8 291530 [6,] 9 239259 [7,] 10 239126 [8,] 11 212396 [9,] 12 202471 [10,] 13 227833 [11,] 14 212977 [12,] 15 207408 [13,] 16 228564 [14,] 1 230414 [15,] 2 15372 [16,] 3 19647 The index i may be chosen at random for example as i - sample(1:16, 1) This allows to get 16 different samples or, perhaps, 17 if we can start at the first row of the second datset. I am not sure, whether you can consider also other types of subsets to increase the number of different samples. For example, the following selects 16 rows at random a[sort(sample(1:32, 16)), ] Hope this helps. Petr Savicky. __ 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] Latin Hypercube Sampling with a condition
Thanks Rob and Ravi for the replies. Let me try to explain my problem. I am trying to make a kind of sensitivity analysis where I have 5 parameters (the margins of the Latin hypercube), 3 of them are proportions that should sum to one. My idea is to obtain uniform combinations of the 3 proportion-parameters with the other two parameters. The uniformity should be maintained in order to guarantee that each parameter (out of 5) have its own range of values equally represented (for model output analyses). Theoretically the 3 proportion-parameters might be regarded as one in which the configuration of the proportions that sum to one vary. I think I can visualize it like a set of permutations, more or less like in the example below: 0.1 - 0.1 - 0.8 0.1 - 0.2 - 0.7 0.1 - 0.3 - 0.6 . . . 0.1 - 0.1 - 0.8 0.2 - 0.1 - 0.7 0.3 - 0.1 - 0.6 . . . 0.8 - 0.1 - 0.1 0.7 - 0.2 - 0.1 0.6 - 0.3 - 0.1 . . . and so on, until all possible combinations are represented (and doing it with more values) and then combined with the other two parameters as to form a Latin hypercube. The solutions given in the thread sent by Ravi work fine for random generation of the 3 proportion-parameters, but it is hard to make a Latin hypercube out of that with two more parameters. Cheers, Duarte __ 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] shading in overlap between two ranges
I have 2 datafiles 'target' and 'observed' as shown below (I will gladly email these 2 small files to whomever). X25. And X75. Indicate the value of 25th and 75th-percentile of the target ('what should be') and the observed ('what is'). The i.value is simply the month. target Xi.valueX25. X75. 1 one.month 1 10.845225 17.87237 2 one.month 2 12.235813 19.74490 3 one.month 3 14.611749 23.44810 4 one.month 4 17.529332 28.09647 5 one.month 5 19.458738 30.56936 6 one.month 6 15.264505 28.29333 7 one.month 7 12.370369 23.35455 8 one.month 8 12.471224 21.82794 9 one.month 9 9.716685 17.28762 10 one.month 10 6.470568 12.49830 11 one.month 11 6.180560 14.24961 12 one.month 12 9.673738 15.79208 observed X i.value X25. X75. 1 one.month 1 19.81000 27.63500 2 one.month 2 23.64062 30.09125 3 one.month 3 26.04865 35.99104 4 one.month 4 32.02625 41.50958 5 one.month 5 34.74479 47.75958 6 one.month 6 37.48885 46.56448 7 one.month 7 30.06740 40.10146 8 one.month 8 26.14917 39.49458 9 one.month 9 14.12521 32.39406 10 one.month 10 11.04125 23.55479 11 one.month 11 13.14917 23.56833 12 one.month 12 17.17938 27.02458 The following plots 4 lines on one graph. The area between the two red lines represents the target 'zone', and the area between the two black lines is the observed 'zone'. with(target, plot(X25.~i.value,ylim=c(0,55),type='l',col='red')) par(new=T) with(target, plot(X75.~i.value,ylim=c(0,55),type='l',col='red')) par(new=T) with(observed, plot(X25.~i.value,ylim=c(0,55),type='l')) par(new=T) with(observed, plot(X75.~i.value,ylim=c(0,55),type='l')) par(new=F) Ideally, the target and the observed should overlap in every month - they don't. The desire is to visually accentuate the amount of overlap by shading in the area where these two zones overlap. How would you do that? Note, that in some of these characterizations, the overlap wanders in and out [I already have routines that calculate the percent of overlap, but I have been requested to find a way to shade the overlap.] __ 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] Removing rows of zeros from a matrix
Hi, Can someone tell me how to remove rows of zeros from a matrix? For example if I have the following matrix, 0 0 0 1 2 8 0 0 4 56 I should end up with 0 1 2 8 4 56 -- Thanks, Jim. [[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] Export a function from RCPP in R of type double
On 2 June 2011 at 01:27, arvanitis wrote: | I have written a small c++ function of type double function(double,double); | and i want to export it in R using RCPP. After some trials i have realized Rcpp uses the .Call() interface which imposes 'SEXP function(SEXP, SEXP, ...); Please see 'Writing R Extensions' manual for details on this, and the Rcpp documentation (maybe starting with Rcpp-introduction.pdf) for more on Rcpp. Rcpp-specific questions should go to the rcpp-devel mailing list. Regards, Dirk | that the only way i could do it working is to declare the function as void | function (double x, double y, double result) and pass the result with RCPP | Can you please tell me if this is the only way out? | And if this is the case how I can implement a function with is recurence | property eg a Factorial funtion | int factorial (int a){ a=factorial(a-1);} | | tnks in advance for your help | | -- | View this message in context: http://r.789695.n4.nabble.com/Export-a-function-from-RCPP-in-R-of-type-double-tp3567793p3567793.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. -- Gauss once played himself in a zero-sum game and won $50. -- #11 at http://www.gaussfacts.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] Removing rows of zeros from a matrix
Assuming the matrix is named X: X[which(rowSums(X) 0),] should work. Also, this list is a text-only list. As you are using gmail, sending text only messages is very easy, and may clear confusion in future posts. HTH, Jon On Thu, Jun 2, 2011 at 11:23 AM, Jim Silverton jim.silver...@gmail.com wrote: Hi, Can someone tell me how to remove rows of zeros from a matrix? For example if I have the following matrix, 0 0 0 1 2 8 0 0 4 56 I should end up with 0 1 2 8 4 56 -- Thanks, Jim. [[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. -- === Jon Daily Technician === #!/usr/bin/env outside # It's great, trust me. __ 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] Removing rows of zeros from a matrix
On Thu, Jun 02, 2011 at 11:23:28AM -0400, Jim Silverton wrote: Hi, Can someone tell me how to remove rows of zeros from a matrix? For example if I have the following matrix, 0 0 0 1 2 8 0 0 4 56 I should end up with 0 1 2 8 4 56 Hi. Try the following a - matrix(c(0, 0, 2, 0, 4, 0, 1, 8, 0, 56), ncol=2) a[rowSums(a != 0) != 0, ] Hope this helps. Petr Savicky. __ 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] Nuisance parameters
Dear R-experts, Please, excuse me for disturbing... I tried to find the answer to my question in archives without any result... I assume, this is going to look like a stupid question... I have dataset of different brain structures within two groups of subjects. But unfortunately these groups are not matched by age and gender. Would you be so kind to suggest me how (using which formula) can I compare two groups by factor ³diagnosis² considering ³age² and ³gender as nuisance variables? --- Best Regards, Alex [[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] an efficient way to calculate correlation matrix
Dear all, I have a problem. I have m variables each of which has n observations. I want to calculate pairwise correlation among the m variables and store the values in a m x m matrix. It is extremely slow to use nested 'for' loops if m and n are large. Is there any efficient alternative to do this? Many thanks for your suggestions!! Bill __ 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] [Plea to the R Gods] Theoretical and Empirical CDFs
On Jun 2, 2011, at 2:18 AM, teriri wrote: http://r.789695.n4.nabble.com/file/n3567636/ecdfs.jpg ecdfs.jpg http://r.789695.n4.nabble.com/file/n3567636/ecdf_curve.gif ecdf_curve.gif Hello, I have generated a plot of two empirical CDFs (attachment 1). As a result, they are stepwise when plotted. The following code was used: plot(ecdf(mut), do.points=FALSE, verticals=TRUE, xlim=range(mut, non), col=red) plot(ecdf(non), do.points=FALSE, verticals=TRUE, add=TRUE, col=blue) But what I need instead are smooth curves, similar to ones that are generated from a theoretical cdf (attachment 2). I have looked at so many threads; one suggestion to someone else was to use library(fitdistplot) and look for distributions that may fit (e.g. weibull). But I could really use guidance before spending additional time on this. Two threads up in the answer to the question based on mean and std you might find Ellison's answer useful. You and ter...@gmail.com in the same class? -- David Winsemius, MD West Hartford, CT __ 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] predict with eha package
Hello list, and thank you in advance. I'm unable to generate predicted values when specifying newdata using phreg and aftreg models in the eha package, but I do not have the same problem with a proportional hazards model from coxph. Without the newdata argument the predicted values are returned, but with newdata=model.dataframe coxph is fine but both aftreg and phreg models return an Error in predict.coxph(f.ph.eha, newdata = mort, type = lp) : Data is not the same size as it was in the original fit message. Since I ultimately want a parametric model and the real data is left truncated and right censored, I think the aftreg function in the eha package is what I must use. Following is my sample code, without the output. #~ All models generated successfully - f.ph - coxph(Surv(enter, exit, event) ~ ses, data = mort) f.ph.eha - phreg(Surv(enter, exit, event) ~ ses, data = mort) f.aft - aftreg(Surv(enter, exit, event) ~ ses, data = mort) #~ All fits generated successfully --- f.ph.fit - predict(f.ph, type='lp') f.ph.eha.fit - predict(f.ph.eha, type='lp') f.aft.fit - predict(f.aft, type='lp') #~ First fit generated successfully, others output error f.ph.fit - predict(f.ph, newdata=mort, type='lp') f.ph.eha.fit - predict(f.ph.eha, newdata=mort, type='lp') f.aft.fit - predict(f.aft, newdata=mort, type='lp') Mike __ 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 panel fine control
thank you so much for the very detailed indications which turned out to be a real help in ponting me to the right direction; referring back to my previous questions there is something still open: 2- I'm in trouble with the point labels because I would like to rotate them by an angle of 90 degrees (and I did not find mention of anything like angle or rot to accomplish this task) panel.text(x, y, lab = mydata$name, cex = 0.6, pos=3, offset=0.5, here something to rotate labels) 3- I was referring to the error bar of each point (standard error of points); I think this could be accomplished by arrows but the following line is giving me an error panel.arrows(x=tv.avg-tv.erst, y=ped.avg-ped.erst, x1=tv.avg+tv.erst, y1=ped.avg+ped.erst, angle=90, code=3) thanks again for your great help in bootstrapping me to the lattice features maxbre -- View this message in context: http://r.789695.n4.nabble.com/lattice-panel-fine-control-tp3566347p3568424.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] ARM package for R 2.10.1
Dear all... I am looking for the zip file of an old version of the ARM package compatible for R 2.10.1 version. When I try to charge the ARM package I get the following message package 'arm' was built under R version 2.13.0 . I can not update R to 2.13.0 as I always get this error the setup files are corrupted please obtain a new copy of the program. If you have an old version of the zip file of ARM and LME4 packages that I can use with R 2.10.1, please, send it to jmdpul...@yahoo.es or send me the file where I can find them. Thanks for the attention -- View this message in context: http://r.789695.n4.nabble.com/ARM-package-for-R-2-10-1-tp3568473p3568473.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] Line histogram for a matrix
Hi guys! I'm new to R, but I was wondering if one could plot many histograms into a single graph each having a different color. To make things clear: Suppose you have a matrix of 100 rows and 10 columns. I'm interested in plotting the histogram for each row, but it should not appear as bars but rather as lines connecting the points of the frequencies. Now, I want to do this for the 100 rows and make all histogram lines appear with different colors into the same graph. The graph should look something like: http://robjhyndman.com/Rfiles/animation/frmale191.jpg http://robjhyndman.com/Rfiles/animation/frmale191.jpg but instead of those values should be more like histogram shape. How can you do it??? Thanks!!! -- View this message in context: http://r.789695.n4.nabble.com/Line-histogram-for-a-matrix-tp3568560p3568560.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] What type of bootstrapping is used in package vars?
Hi, I used the package vars for my project but when the impulse response plots were produced, some of the levels are out of the confidence band. I was wondering what the problem is and also, does anyone know what type of bootstrapping the package is using: is it parametric, case resampling, gaussian, or something else? Thanks a lot, Jesse -- View this message in context: http://r.789695.n4.nabble.com/What-type-of-bootstrapping-is-used-in-package-vars-tp3568683p3568683.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] multicore: collect slow on large objects?
I use package multicore, and it works very well. There is, however, one thing I wonder if I don't do correctly, here is one example: I read ca 5.5 mill records into a dataframe, using read.dta through a one-line function rdam1. It runs nicely in parallel with other activitites. p1 - parallel(rdam1()) ; Then I recover the data frame with collect: am1 - (collect(p1))[[1]] All goes well, but the collecting step takes quite some time, and as the data frame is already in memory, should this be necessary? I experience the same with all parallelized steps resulting in large objects. Is there a way to avoid this, for instance, accessing the object through a pointer? Trond Ydersbond [[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] Counting occurrences in a moving window
Hi list, based on the following data.frame I would like to create a variable that indicates the number of occurrences of A in the 3 years prior to the current year: DF = data.frame(read.table(textConnection( A B 8025 1995 8026 1995 8029 1995 8026 1996 8025 1997 8026 1997 8025 1997 8027 1997 8026 1999 8027 1999 8028 1995 8029 1998 8025 1997 8027 1997 8026 1999 8027 1999 8028 1995 8029 1998),head=TRUE,stringsAsFactors=FALSE)) becomes: AB C 8025 1995 0 8026 1995 0 8029 1995 0 8026 1996 1 8025 1997 1 8026 1997 2 8025 1997 1 8027 1997 0 8026 1999 2 8027 1999 2 8028 1995 0 8029 1998 1 8025 1997 1 8027 1997 0 8026 1999 2 8027 1999 2 8028 1995 0 8029 2000 1 So 8026 in 1997 = 2 because 8026 can be found in 1995 and 1996 which are both within the appropriate window (1996 - 1994). Any ideas? I looked at the rollapply vignette, but couldn't figure out how to apply it to my data. Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Counting-occurrences-in-a-moving-window-tp3568658p3568658.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 in a project
To whom it may concern, I am a new user to R and I need help in my if and for statements as I need a place marker. I would like to convert the following table: Observation | Variable 1 |- 1 | 1 2 | A 3 | 631 Into : Observation| Variable 1 | Variable 1 Flag |--|-- 1 | 1 | NA 2 | NA | A 3 | 631 | NA please note | represents another column. this is for a large data set and I cannot manually go through this: my attempt to this was : l=0 # placeholder m-c() #newvariable 1 v-c() #newvariable flag for (z in tablename1$Variable_1) (if (is.numeric(z) ) m[z:l] l=l+1 else v[z:1] l=l+1 Can you please guide me as to how to approach this problem? Any help would be greatly appreciated. Tarun Manchanda [[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] Using SQLDF to pick values based on word count
I have a data frame in R with the following values. cars autocar cars info what is that donna drive car telephone i need car... I want to select all values which contain 'car', values with three words, and those keywords with car that contain three words. The first part is done with : sqldf(SELECT Keyword FROM dat WHERE Keyword like '%car%') However, I'm not sure how to pick those values with words and those values with three words AND 'car' [[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] shading in overlap between two ranges
Hi: Here's one approach using geom_ribbon() in ggplot2 - the 'overlap' is the change in color where the two ribbons intersect. Using your example data with the same names and the 'one.month' variable removed, library(ggplot2) ggplot() + geom_ribbon(data = target, aes(x = i.value, ymin = X25, ymax = X75, fill = 'Target'), alpha = 0.4) + geom_ribbon(data = observed, aes(x = i.value, ymin = X25, ymax = X75, fill = 'Observed'), alpha = 0.4) + scale_fill_manual(, c('Target' = 'blue', 'Observed' = 'orange')) + opts(legend.position = c(0.88, 0.85), legend.background = theme_rect(colour = 'transparent'), legend.text = theme_text(size = 12)) + labs(x = 'Month', y = 'Value') There is a separate geom_ribbon() for each of target and observed. A factor variable for fill color is generated on the fly with colors specified in scale_fill_manual(). The opts() reposition the legend inside the graphics region (the values represent proportions of the total graphics area in each direction), make the legend background transparent and slightly increase the size of the legend labels (default size = 10 in theme_text). Alpha transparency is used so that the overlap creates a blend of the two colors; without it, one overwrites the other. HTH, Dennis On Thu, Jun 2, 2011 at 8:04 AM, Graves, Gregory ggra...@sfwmd.gov wrote: I have 2 datafiles 'target' and 'observed' as shown below (I will gladly email these 2 small files to whomever). X25. And X75. Indicate the value of 25th and 75th-percentile of the target ('what should be') and the observed ('what is'). The i.value is simply the month. target X i.value X25. X75. 1 one.month 1 10.845225 17.87237 2 one.month 2 12.235813 19.74490 3 one.month 3 14.611749 23.44810 4 one.month 4 17.529332 28.09647 5 one.month 5 19.458738 30.56936 6 one.month 6 15.264505 28.29333 7 one.month 7 12.370369 23.35455 8 one.month 8 12.471224 21.82794 9 one.month 9 9.716685 17.28762 10 one.month 10 6.470568 12.49830 11 one.month 11 6.180560 14.24961 12 one.month 12 9.673738 15.79208 observed X i.value X25. X75. 1 one.month 1 19.81000 27.63500 2 one.month 2 23.64062 30.09125 3 one.month 3 26.04865 35.99104 4 one.month 4 32.02625 41.50958 5 one.month 5 34.74479 47.75958 6 one.month 6 37.48885 46.56448 7 one.month 7 30.06740 40.10146 8 one.month 8 26.14917 39.49458 9 one.month 9 14.12521 32.39406 10 one.month 10 11.04125 23.55479 11 one.month 11 13.14917 23.56833 12 one.month 12 17.17938 27.02458 The following plots 4 lines on one graph. The area between the two red lines represents the target 'zone', and the area between the two black lines is the observed 'zone'. with(target, plot(X25.~i.value,ylim=c(0,55),type='l',col='red')) par(new=T) with(target, plot(X75.~i.value,ylim=c(0,55),type='l',col='red')) par(new=T) with(observed, plot(X25.~i.value,ylim=c(0,55),type='l')) par(new=T) with(observed, plot(X75.~i.value,ylim=c(0,55),type='l')) par(new=F) Ideally, the target and the observed should overlap in every month - they don't. The desire is to visually accentuate the amount of overlap by shading in the area where these two zones overlap. How would you do that? Note, that in some of these characterizations, the overlap wanders in and out [I already have routines that calculate the percent of overlap, but I have been requested to find a way to shade the overlap.] __ 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] an efficient way to calculate correlation matrix
?cor Example: dd - data.frame(x1 = rnorm(40), x2 = rnorm(40), x3 = runif(40, 0, 10)) 'data.frame': 40 obs. of 3 variables: $ x1: num -0.5585 1.3831 -1.7862 0.0572 0.2825 ... $ x2: num -0.5247 -0.8636 -0.0749 0.2399 -0.1592 ... $ x3: num 7.698 5.259 0.918 3.251 5.169 ... cor(dd) x1 x2 x3 x1 1.000 -0.23268659 -0.02915700 x2 -0.2326866 1. -0.07073142 x3 -0.0291570 -0.07073142 1. It will also run on a matrix of numeric variables. Any factor or character variables in the set of variables shipped to cor() will cause an error; for example, head(Oats, 3) Grouped Data: yield ~ nitro | Block Block Variety nitro yield 1 I Victory 0.0 111 2 I Victory 0.2 130 3 I Victory 0.4 157 cor(Oats) Error in cor(Oats) : 'x' must be numeric cor(Oats[, 3:4]) nitro yield nitro 1.000 0.6130266 yield 0.6130266 1.000 HTH, Dennis On Thu, Jun 2, 2011 at 8:48 AM, Bill Hyman billhym...@yahoo.com wrote: Dear all, I have a problem. I have m variables each of which has n observations. I want to calculate pairwise correlation among the m variables and store the values in a m x m matrix. It is extremely slow to use nested 'for' loops if m and n are large. Is there any efficient alternative to do this? Many thanks for your suggestions!! Bill __ 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] Latin Hypercube Sampling with a condition
Duarte Viana viana.sptd at gmail.com writes: Thanks Rob and Ravi for the replies. Let me try to explain my problem. I am trying to make a kind of sensitivity analysis where I have 5 parameters (the margins of the Latin hypercube), 3 of them are proportions that should sum to one. My idea is to obtain uniform combinations of the 3 proportion-parameters with the other two parameters. The uniformity should be maintained in order to guarantee that each parameter (out of 5) have its own range of values equally represented (for model output analyses). Theoretically the 3 proportion-parameters might be regarded as one in which the configuration of the proportions that sum to one vary. I think I can visualize it like a set of permutations, more or less like in the example below: 0.1 - 0.1 - 0.8 0.1 - 0.2 - 0.7 0.1 - 0.3 - 0.6 . . . 0.1 - 0.1 - 0.8 0.2 - 0.1 - 0.7 0.3 - 0.1 - 0.6 . . . 0.8 - 0.1 - 0.1 0.7 - 0.2 - 0.1 0.6 - 0.3 - 0.1 . . . and so on, until all possible combinations are represented (and doing it with more values) and then combined with the other two parameters as to form a Latin hypercube. The solutions given in the thread sent by Ravi work fine for random generation of the 3 proportion-parameters, but it is hard to make a Latin hypercube out of that with two more parameters. Cheers, Duarte Duarte, The commmon practice in your situation is draw the K parameters together as a uniform Latin hypercube on 0-1 and then transform the margins of the hypercube to the desired distributions. Easy Example Parameter 1: normal(1, 2) Parameter 2: normal(3, 4) Parameter 3: uniform(5, 10) require(lhs) N - 1000 x - randomLHS(N, 3) y - x y[,1] - qnorm(x[,1], 1, 2) y[,2] - qnorm(x[,2], 3, 4) y[,3] - qunif(x[,3], 5, 10) par(mfrow=c(2,2)) apply(x, 2, hist) par(mfrow=c(2,2)) apply(y, 2, hist) The transformed distributions maintain their Latin properties, but are in the form of new distributions. In your case, you'd like the first three columns to be transformed into a correlated set that sums to one. Still follow the pattern... x - randomLHS(N, 5) y - x y[,1] - x[,1]/rowSums(x[,1:3]) y[,2] - x[,2]/rowSums(x[,1:3]) y[,3] - x[,3]/rowSums(x[,1:3]) y[,4] - x[,4] y[,5] - x[,5] par(mfrow=c(2,3)) apply(x, 2, hist) par(mfrow=c(2,3)) apply(y, 2, hist) all.equal(rowSums(y[,1:3]), rep(1, nrow(y))) The uniform properties are gone as you can see here... par(mfrow=c(1,1)) pairs(x) paris(y, col=red) But, the Latin properties of the first three margins are maintained as in this smaller example... N - 10 x - randomLHS(N, 5) y - x y[,1] - x[,1]/rowSums(x[,1:3]) y[,2] - x[,2]/rowSums(x[,1:3]) y[,3] - x[,3]/rowSums(x[,1:3]) y[,4] - x[,4] y[,5] - x[,5] pairs(x) pairs(y, col=red) You could also look into a dirichlet type transform as I posted here http://tolstoy.newcastle.edu.au/R/e5/help/08/11/8420.html Rob __ 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] Zero-inflated regression models: predicting no 0s
Thanks for the quick reply, I understand that the predict(zip1A, type = response) command is computing the fitted_means and these are different than the probabilities predict(zip1A, type = prob). Although, according to Martin (2005), the highest probabilities do not simply lead to the true count estimates: to get the true estimate of relative mean abundance from the ZIP one must multiply the estimated relative mean number of individuals at a site by the probability that the relative mean number of individuals at a site is generated through a Poisson distribution. I initially thought that the predicted mean and the observed count could be compared to estimate the fit of the model, but now I am not sure what to think with Martin (2005) statement. Thank you for your help, JM Martin, T.G. et al. (2005) Zero tolerance ecology: improving ecological inference by modelling the source of zero observations, Ecology Letters, Volume 8, Issue 11, pages 1235–1246. -- View this message in context: http://r.789695.n4.nabble.com/Zero-inflated-regression-models-predicting-no-0s-tp3564807p3568865.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] generically forward low-level graphic parametres in function
Hello, following problem: i have a written my own function to draw some sophisticated graphic, which after manipulating data somewhere contains a plot comand function - function(x) { ... plot(xy) } to tidy up my final graphs, it would be very handy to be able forward all low-level graphic parameters set in function to plot i.e. function(x, cex=0.5) calls plot (xy, cex=0.5) is there a way to do this? thanks a lot, lukas kohl department of chemical ecology university of vienna __ 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 in a project
Hello, three commands might do the job (NOTE: df=your data frame, obser=Observation, var1=Variable 1 [TYPE: string], var1flag=Variable 1 flag [TYPE: string]) 1. df$var1flag-NA 2. df$var1flag[ is.na(as.numeric(df$var1)) ]-df$var1[ is.na(as.numeric(df$var1)) ] 3. df$var1-as.numeric(df$var1) {Please note: Var1 must be type string at the beginning. Otherwise this would not work (you cannot have an A in a numeric column...)] After this, 'df' gives: df obser var1 var1flag 1 1 1000 NA 2 2 NAA 3 3 631 NA Is this what You are looking for? HTH, Kimmo 02.06.2011 18:28, Tarun Manchanda wrote: To whom it may concern, I am a new user to R and I need help in my if and for statements as I need a place marker. I would like to convert the following table: Observation | Variable 1 |- 1 | 1 2 | A 3 | 631 Into : Observation| Variable 1 | Variable 1 Flag |--|-- 1 | 1 | NA 2 | NA | A 3 | 631 | NA please note | represents another column. __ 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] confusion matrix error
Hi, this is my R-script I need to make a confusion matrix but the last row return me an error require(mixOmics) require(SDMTools) file - C:\\data.txt d - read.table(file, header=T, row.names = NULL) X - as.matrix(d[,2:11]) Y - as.factor(d[,1]) i - 1 samp - sample(1:3, nrow(X), replace = TRUE) # Creation of a list of the same size as X test - which(samp == i) # Search which column in samp has a value of 1 train - setdiff(1:nrow(X), test) # Keeping the column that are not in test #PLS-DA plsda.train - plsda(X[train, ], Y[train], ncomp = 10) test.predict - predict(plsda.train, X[test, ], method = class.dist) confusion.matrix(test.predict, Y[-train]) Error in confusion.matrix(test.predict, Y[-train]) : this requires the same number of observed predicted values I have no idea why it don't work Thank you for help -- View this message in context: http://r.789695.n4.nabble.com/confusion-matrix-error-tp3568913p3568913.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.
Re: [R] ARM package for R 2.10.1
I would recommend trying to fix the installation of R 2.13.0 rather than trying to obtain old packages. Try downloading the installer again from a different mirror. On Thu, Jun 2, 2011 at 10:33 AM, jmdpulido jmdpul...@yahoo.es wrote: Dear all... I am looking for the zip file of an old version of the ARM package compatible for R 2.10.1 version. When I try to charge the ARM package I get the following message package 'arm' was built under R version 2.13.0 . I can not update R to 2.13.0 as I always get this error the setup files are corrupted please obtain a new copy of the program. If you have an old version of the zip file of ARM and LME4 packages that I can use with R 2.10.1, please, send it to jmdpul...@yahoo.es or send me the file where I can find them. Thanks for the attention -- View this message in context: http://r.789695.n4.nabble.com/ARM-package-for-R-2-10-1-tp3568473p3568473.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. -- === Jon Daily Technician === #!/usr/bin/env outside # It's great, trust me. __ 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] generically forward low-level graphic parametres in function
try using `...` function - function(x, ...) { #do stuff plot(xy, ...) } On Thu, Jun 2, 2011 at 1:26 PM, eldor ado rat.c...@gmail.com wrote: Hello, following problem: i have a written my own function to draw some sophisticated graphic, which after manipulating data somewhere contains a plot comand function - function(x) { ... plot(xy) } to tidy up my final graphs, it would be very handy to be able forward all low-level graphic parameters set in function to plot i.e. function(x, cex=0.5) calls plot (xy, cex=0.5) is there a way to do this? thanks a lot, lukas kohl department of chemical ecology university of vienna __ 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. -- === Jon Daily Technician === #!/usr/bin/env outside # It's great, trust me. __ 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 with package development
Thanks Prof. Ripley and Duncan for your pointers. Noting down your points I have modified my way of building package and have done following so far: 1. In my C: drive I create one working folder naming R_PackageBuild 2. In R console I have written following codes: setwd(c:/R_packageBuild) package.skeleton(trial1,namespace = TRUE, code_files = f:/trial.r) 3. then I opened cmd and wrote following: cd C:\R_PackageBuild Rcmd build –binary trial1 This process halted with following error: Error: unexpected symbol in “tools:::.test_load_package(‘trial1′,….)” Execution halted ERROR: loading failed What I have missed in this process? Can you please help me how to solve this issue? Thanks, PS: I am sorry I missplet 'Program Files'. Thanks Prof. Ripley for this pointer. On Wed, Jun 1, 2011 at 11:41 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Wed, 1 Jun 2011, Nipesh Bajaj wrote: I have been struggling for last one hour but not yet any through. However again I recreate the package.skeleton and run R CMD check trial3 Here are the errors: warning in dir.create(pkgoutdir, mode = 0755): cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', reason . Error in printLog(Log, , text, \n): object 'Log' not found Execution haulted Why I am getting this error? what is that Log. I will really appreciate if somebody please help me to figure out. R CMD check writes a (in your case) trial3.Rcheck directory, and in there in file 00check.log a copy of the log. If it cannot create trial3.Rcheck it cannot write the log. I would be surprised that even on Windows Vista the message was literally reason . but if it was, blame Microsoft for their error messages. But cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', is clear enough. You need to run 'R CMD check' in your user area. In case you did this because that is where you though 'R' was, it is not the correct R.exe. You may need to add c:\Program Files\R\R-2.13.0\bin\i386 (assuming 32-bit R) to your path. However, your use of e.g. 'Program files' suggests you are not accurately transmitting the messages you got. Thanks, On Wed, Jun 1, 2011 at 1:20 AM, Nipesh Bajaj bajaj141...@gmail.com wrote: Actually partly I followed. Here is the more details what I have done so far: 1. Edit the help file skeletons in 'man', possibly combining help files for multiple functions. I have modified with following: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } 2. Edit the exports in 'NAMESPACE', and add necessary imports. Actually I really do not know what I would do here. In the corresponding file, only exportPattern(^[[:alpha:]]+) is there. Therefore I put that unaltered. 3. Put any C/C++/Fortran code in 'src'. I do not have any such code 4. If you have compiled code, add a useDynLib() directive to 'NAMESPACE'. Again I do not know what to do, so ingored this step. 5. Run R CMD build to build the package tarball. * Run R CMD check to check the package tarball. I did not follow this step exactly. What I done is, put 'trial3' folder in R/R-2.13.0bin folder (after above modification), from the R-working folder. Then just run R CMD INSTALL trial3. However previously with this job, I could create package effectively. After updating R to the current version my problem starts. Those are not sufficient? Thanks, On Wed, Jun 1, 2011 at 1:09 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 11-05-31 3:36 PM, Nipesh Bajaj wrote: Dear all, I am having a strage problem while I was trying to build a package. Here is my package skeleton: fn1- Vectorize(function(x,y,z) { return(x + y +z) }, vectorize.args = c(x), SIMPLIFY = TRUE) package.skeleton(trial3,namespace = TRUE) Did you follow the instructions that package.skeleton printed? Duncan Murdoch However when I tun R CMD INSTALL trial3 in CMD, the execution stopped with following message: *** installing help indices ** building package indices... ** testing if install package can be loaded Error: unexpected symbol in tools:::test_load_package(.. Execution haulted ERROR: loading failed. I am using R 2.13.0 in Vista with latest Rtools installed. Can somebody guide me where I have done wrong? Thanks, __ 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
Re: [R] ARM package for R 2.10.1
On Thu, 2 Jun 2011, Jonathan Daily wrote: I would recommend trying to fix the installation of R 2.13.0 rather than trying to obtain old packages. Try downloading the installer again from a different mirror. He has already been given help (3x) to that effect. People who fail to acknowledege any help are asking not to be helped again. But the R 2.10 Windows binary tree is still up at http://cran.r-project.org/bin/windows/contrib/2.10/ and simply using the menus will install the correct versions. On Thu, Jun 2, 2011 at 10:33 AM, jmdpulido jmdpul...@yahoo.es wrote: Dear all... I am looking for the zip file of an old version of the ARM package compatible for R 2.10.1 version. When I try to charge the ARM package I get the following message package 'arm' was built under R version 2.13.0 . I can not update R to 2.13.0 as I always get this error the setup files are corrupted please obtain a new copy of the program. If you have an old version of the zip file of ARM and LME4 packages that I can use with R 2.10.1, please, send it to jmdpul...@yahoo.es or send me the file where I can find them. Thanks for the attention -- View this message in context: http://r.789695.n4.nabble.com/ARM-package-for-R-2-10-1-tp3568473p3568473.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. -- === Jon Daily Technician === #!/usr/bin/env outside # It's great, trust me. __ 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ 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] Latin Hypercube Sampling with a condition
Thanks again Rob for your help. In terms of parameter comparison there won't be a problem. However, if one wants to assume a particular distribution (and not the one given by the imposed condition), for example an uniform distribution to obtain all the possible combinations (all the multidimensional space uniformly filled), then a limitation exists. Perhaps it is not possible to fulfill the three criteria - sum to one, maintain the uniform distribution and maintain the latin hypercube property. Well, I will try to do it the way you proposed. Cheers, Duarte On Thu, Jun 2, 2011 at 7:06 PM, Rob Carnell carne...@battelle.org wrote: Duarte Viana viana.sptd at gmail.com writes: Thanks Rob and Ravi for the replies. Let me try to explain my problem. I am trying to make a kind of sensitivity analysis where I have 5 parameters (the margins of the Latin hypercube), 3 of them are proportions that should sum to one. My idea is to obtain uniform combinations of the 3 proportion-parameters with the other two parameters. The uniformity should be maintained in order to guarantee that each parameter (out of 5) have its own range of values equally represented (for model output analyses). Theoretically the 3 proportion-parameters might be regarded as one in which the configuration of the proportions that sum to one vary. I think I can visualize it like a set of permutations, more or less like in the example below: 0.1 - 0.1 - 0.8 0.1 - 0.2 - 0.7 0.1 - 0.3 - 0.6 . . . 0.1 - 0.1 - 0.8 0.2 - 0.1 - 0.7 0.3 - 0.1 - 0.6 . . . 0.8 - 0.1 - 0.1 0.7 - 0.2 - 0.1 0.6 - 0.3 - 0.1 . . . and so on, until all possible combinations are represented (and doing it with more values) and then combined with the other two parameters as to form a Latin hypercube. The solutions given in the thread sent by Ravi work fine for random generation of the 3 proportion-parameters, but it is hard to make a Latin hypercube out of that with two more parameters. Cheers, Duarte Duarte, The commmon practice in your situation is draw the K parameters together as a uniform Latin hypercube on 0-1 and then transform the margins of the hypercube to the desired distributions. Easy Example Parameter 1: normal(1, 2) Parameter 2: normal(3, 4) Parameter 3: uniform(5, 10) require(lhs) N - 1000 x - randomLHS(N, 3) y - x y[,1] - qnorm(x[,1], 1, 2) y[,2] - qnorm(x[,2], 3, 4) y[,3] - qunif(x[,3], 5, 10) par(mfrow=c(2,2)) apply(x, 2, hist) par(mfrow=c(2,2)) apply(y, 2, hist) The transformed distributions maintain their Latin properties, but are in the form of new distributions. In your case, you'd like the first three columns to be transformed into a correlated set that sums to one. Still follow the pattern... x - randomLHS(N, 5) y - x y[,1] - x[,1]/rowSums(x[,1:3]) y[,2] - x[,2]/rowSums(x[,1:3]) y[,3] - x[,3]/rowSums(x[,1:3]) y[,4] - x[,4] y[,5] - x[,5] par(mfrow=c(2,3)) apply(x, 2, hist) par(mfrow=c(2,3)) apply(y, 2, hist) all.equal(rowSums(y[,1:3]), rep(1, nrow(y))) The uniform properties are gone as you can see here... par(mfrow=c(1,1)) pairs(x) paris(y, col=red) But, the Latin properties of the first three margins are maintained as in this smaller example... N - 10 x - randomLHS(N, 5) y - x y[,1] - x[,1]/rowSums(x[,1:3]) y[,2] - x[,2]/rowSums(x[,1:3]) y[,3] - x[,3]/rowSums(x[,1:3]) y[,4] - x[,4] y[,5] - x[,5] pairs(x) pairs(y, col=red) You could also look into a dirichlet type transform as I posted here http://tolstoy.newcastle.edu.au/R/e5/help/08/11/8420.html Rob __ 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 with package development
On 02/06/2011 2:03 PM, Nipesh Bajaj wrote: Thanks Prof. Ripley and Duncan for your pointers. Noting down your points I have modified my way of building package and have done following so far: 1. In my C: drive I create one working folder naming R_PackageBuild 2. In R console I have written following codes: setwd(c:/R_packageBuild) package.skeleton(trial1,namespace = TRUE, code_files = f:/trial.r) 3. then I opened cmd and wrote following: cd C:\R_PackageBuild Rcmd build –binary trial1 This process halted with following error: Error: unexpected symbol in “tools:::.test_load_package(‘trial1′,….)” Execution halted ERROR: loading failed What I have missed in this process? Can you please help me how to solve this issue? You haven't done the manual changes required between steps 2 and 3. package.skeleton() creates the skeleton of a package; you run it once as you are starting development, the do a lot of manual updates, described on the ?package.skeleton help page, and in the ‘Read-and-delete-me’ file. Once those are done, step 3 should succeed. Duncan Murdoch Thanks, PS: I am sorry I missplet 'Program Files'. Thanks Prof. Ripley for this pointer. On Wed, Jun 1, 2011 at 11:41 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Wed, 1 Jun 2011, Nipesh Bajaj wrote: I have been struggling for last one hour but not yet any through. However again I recreate the package.skeleton and run R CMD check trial3 Here are the errors: warning in dir.create(pkgoutdir, mode = 0755): cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', reason . Error in printLog(Log, , text, \n): object 'Log' not found Execution haulted Why I am getting this error? what is that Log. I will really appreciate if somebody please help me to figure out. R CMD check writes a (in your case) trial3.Rcheck directory, and in there in file 00check.log a copy of the log. If it cannot create trial3.Rcheck it cannot write the log. I would be surprised that even on Windows Vista the message was literally reason . but if it was, blame Microsoft for their error messages. But cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', is clear enough. You need to run 'R CMD check' in your user area. In case you did this because that is where you though 'R' was, it is not the correct R.exe. You may need to add c:\Program Files\R\R-2.13.0\bin\i386 (assuming 32-bit R) to your path. However, your use of e.g. 'Program files' suggests you are not accurately transmitting the messages you got. Thanks, On Wed, Jun 1, 2011 at 1:20 AM, Nipesh Bajajbajaj141...@gmail.com wrote: Actually partly I followed. Here is the more details what I have done so far: 1. Edit the help file skeletons in 'man', possibly combining help files for multiple functions. I have modified with following: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } 2. Edit the exports in 'NAMESPACE', and add necessary imports. Actually I really do not know what I would do here. In the corresponding file, only exportPattern(^[[:alpha:]]+) is there. Therefore I put that unaltered. 3. Put any C/C++/Fortran code in 'src'. I do not have any such code 4. If you have compiled code, add a useDynLib() directive to 'NAMESPACE'. Again I do not know what to do, so ingored this step. 5. Run R CMD build to build the package tarball. * Run R CMD check to check the package tarball. I did not follow this step exactly. What I done is, put 'trial3' folder in R/R-2.13.0bin folder (after above modification), from the R-working folder. Then just run R CMD INSTALL trial3. However previously with this job, I could create package effectively. After updating R to the current version my problem starts. Those are not sufficient? Thanks, On Wed, Jun 1, 2011 at 1:09 AM, Duncan Murdochmurdoch.dun...@gmail.com wrote: On 11-05-31 3:36 PM, Nipesh Bajaj wrote: Dear all, I am having a strage problem while I was trying to build a package. Here is my package skeleton: fn1- Vectorize(function(x,y,z) { return(x + y +z) }, vectorize.args = c(x), SIMPLIFY = TRUE) package.skeleton(trial3,namespace = TRUE) Did you follow the instructions that package.skeleton printed? Duncan Murdoch However when I tun R CMD INSTALL trial3 in CMD, the execution stopped with following message: *** installing help indices ** building package indices... ** testing if install package can be loaded Error: unexpected symbol in tools:::test_load_package(.. Execution haulted ERROR: loading failed. I am using R 2.13.0 in Vista with latest Rtools installed. Can somebody guide
Re: [R] Problem with package development
What else I need to do? In the Read-and-delete-me file following steps are asked to perform: * Edit the help file skeletons in 'man', possibly combining help files for multiple functions. * Edit the exports in 'NAMESPACE', and add necessary imports. * Put any C/C++/Fortran code in 'src'. * If you have compiled code, add a useDynLib() directive to 'NAMESPACE'. * Run R CMD build to build the package tarball. * Run R CMD check to check the package tarball. I editied the help page for fn1() function (as I already communicated in previous mail) as follows: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } And regarding th Namespace file, this time I put package.skeleton(trial1,namespace = FALSE, code_files = f:/trial.r) I do not have any C/C++ code so I ignored 3rd step. then Read-and-delete-me file asking me to build the package, so in cmd, I run following: cd C:\R_PackageBuild Rcmd build –binary trial1 What I am missing in this entire process? Do you please point me? Thanks, On Thu, Jun 2, 2011 at 11:40 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 02/06/2011 2:03 PM, Nipesh Bajaj wrote: Thanks Prof. Ripley and Duncan for your pointers. Noting down your points I have modified my way of building package and have done following so far: 1. In my C: drive I create one working folder naming R_PackageBuild 2. In R console I have written following codes: setwd(c:/R_packageBuild) package.skeleton(trial1,namespace = TRUE, code_files = f:/trial.r) 3. then I opened cmd and wrote following: cd C:\R_PackageBuild Rcmd build –binary trial1 This process halted with following error: Error: unexpected symbol in “tools:::.test_load_package(‘trial1′,….)” Execution halted ERROR: loading failed What I have missed in this process? Can you please help me how to solve this issue? You haven't done the manual changes required between steps 2 and 3. package.skeleton() creates the skeleton of a package; you run it once as you are starting development, the do a lot of manual updates, described on the ?package.skeleton help page, and in the ‘Read-and-delete-me’ file. Once those are done, step 3 should succeed. Duncan Murdoch Thanks, PS: I am sorry I missplet 'Program Files'. Thanks Prof. Ripley for this pointer. On Wed, Jun 1, 2011 at 11:41 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Wed, 1 Jun 2011, Nipesh Bajaj wrote: I have been struggling for last one hour but not yet any through. However again I recreate the package.skeleton and run R CMD check trial3 Here are the errors: warning in dir.create(pkgoutdir, mode = 0755): cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', reason . Error in printLog(Log, , text, \n): object 'Log' not found Execution haulted Why I am getting this error? what is that Log. I will really appreciate if somebody please help me to figure out. R CMD check writes a (in your case) trial3.Rcheck directory, and in there in file 00check.log a copy of the log. If it cannot create trial3.Rcheck it cannot write the log. I would be surprised that even on Windows Vista the message was literally reason . but if it was, blame Microsoft for their error messages. But cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', is clear enough. You need to run 'R CMD check' in your user area. In case you did this because that is where you though 'R' was, it is not the correct R.exe. You may need to add c:\Program Files\R\R-2.13.0\bin\i386 (assuming 32-bit R) to your path. However, your use of e.g. 'Program files' suggests you are not accurately transmitting the messages you got. Thanks, On Wed, Jun 1, 2011 at 1:20 AM, Nipesh Bajajbajaj141...@gmail.com wrote: Actually partly I followed. Here is the more details what I have done so far: 1. Edit the help file skeletons in 'man', possibly combining help files for multiple functions. I have modified with following: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } 2. Edit the exports in 'NAMESPACE', and add necessary imports. Actually I really do not know what I would do here. In the corresponding file, only exportPattern(^[[:alpha:]]+) is there. Therefore I put that unaltered. 3. Put any C/C++/Fortran code in 'src'. I do not have any such code 4. If you have compiled code, add a useDynLib() directive to 'NAMESPACE'. Again I do not know what to do, so ingored this step. 5. Run R CMD build to build the package
Re: [R] Line histogram for a matrix
On Jun 2, 2011, at 11:04 AM, Sakti wrote: Hi guys! I'm new to R, but I was wondering if one could plot many histograms into a single graph each having a different color. To make things clear: Suppose you have a matrix of 100 rows and 10 columns. I'm interested in plotting the histogram for each row, but it should not appear as bars but rather as lines connecting the points of the frequencies. Now, I want to do this for the 100 rows and make all histogram lines appear with different colors into the same graph. You should look at the matplot function. The graph should look something like: http://robjhyndman.com/Rfiles/animation/frmale191.jpg http://robjhyndman.com/Rfiles/animation/frmale191.jpg but instead of those values should be more like histogram shape. How can you do it??? Thanks!!! David Winsemius, MD West Hartford, CT __ 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] plotmath: paste string and expression [from a vector of expressions]
Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars - vector(expression, 2) vars[1] - expression(alpha) vars[2] - expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Foo theta, where theta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. Cheers, Marius __ 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 with Snowball RWeka
Greetings to all, I have a similar issue with Snowball. I am runing R version 2.12.1 (2010-12-16) on windows 7 Here is my script : library(tm) custom.xml - system.file(texts, custom.xml, package = tm) print(readLines(custom.xml), quote = FALSE) myXMLReader - readXML( spec = list( Language = list(node, /document/language), DateTimeStamp = list(node, /document/date), Origin = list(node, /document/source), Description = list(node, /document/subject), Type = list(node, /document/country), Heading = list(node, /document/title), Content = list(node, /document/contenu), Author = list(node, /document/author)), doc = PlainTextDocument()) mySource - function(x, encoding = UTF-8) XMLSource(x, function(tree) XML::xmlRoot(tree)$children, myXMLReader, encoding) corpusmf - Corpus(mySource(custom.xml)) meta(corpusmf[[1]]) meta(corpusmf[[2]]) corpusmf - tm_map(corpusmf, stripWhitespace) corpusmf - tm_map(corpusmf, removeNumbers) corpusmf - tm_map(corpusmf, removePunctuation) corpusmf - tm_map(corpusmf,stemDocument) matrix - TermDocumentMatrix(corpusmf,control=list(weighting =weightBin )) print(matrix) - stemDocument returns an error message : Stemmer 'porter' unknown! Stemmer 'english' unknown! Stemmer 'porter' unknown! Stemmer 'english' unknown! I tried to invoke library(Snowball) before, but it's the same. I found a clue on Weka website http://weka.wikispaces.com/The+snowball+stemmers+don%27t+work,+what+am+I+doing+wrong%3F but I don't understand what I should do with this archives I would be grateful if someone could help on this; Kind regards, -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-Snowball-RWeka-tp3402126p3569089.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] complex search between dataframes
Hi! I am very new to R, I hope someone can help me. I have two dataframes: data1-data.frame(from=c(1,12,16,40,55,81,101),to=c(10,13,23,45,67,99,123)) data2-data.frame(name=c(1,2,3,4,5,6,7,8,9),position=c(2,14,20,50,150,2000,2001,2002,85)) I want to know which of the entries in position of data2 are included between any from and the corresponding to of data1. So in this case I would need to somehow be able to extract 2,20 and 85, corrisponding to the names 1,3 and 9. Thank you very much! Filippo __ 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] Matrix Question
Hi, First of all, I would like to introduce myself as I will probably have many questions over the next few weeks and want to thank you guys in advance for your help. I'm a cancer researcher and I need to learn R to complete a few projects. I have an introductory background in Python. My questions at the moment are based on the following sample input file: *Sample_Input_File* characteristics_ch1.3 Stage: T1N0 Stage: T2N1 Stage: T0N0 Stage: T1N0 Stage: T0N3 characteristics_ch1.3 is a column header in the input excel file. T's represent stage and N's represent degree of disease spreading. I want to create output that looks like this: *Sample_Output_File* T N 1 0 2 1 0 0 1 0 0 3 As it currently stands, my code is the following: rm(list=ls()) source(../../functions.R) uncurated - read.csv(../uncurated/Sample_Input_File_full_pdata.csv,as.is =TRUE,row.names=1) ##initial creation of curated dataframe curated - initialCuratedDF(rownames(uncurated),template.filename=Sample_Template_File.csv) ## ##start the mappings ## ##title - alt_sample_name curated$alt_sample_name - uncurated$title #T tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$T - tmp #N tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$N - tmp write.table(curated, row.names=FALSE, file=../curated/Sample_Output_File_curated_pdata.txt,sep=\t) My question is the following: What code gets me the desired output (replacing the *??*'s above)? I want to: a) Find the integer value one element to the right of T; and b) find the integer value one element to the right of N. I've read the regular expression tutorial for R, but could only figure out how to grab an integer value if it is the only integer value in the row (ie more than one integer value makes this basic regular expression unsuccessful). Thank you very much for any help you can provide. Sincerely, Ben Ganzfried [[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 panel fine control
You did not read the help files carefully enough. The Help for panel.text tells you that it is the same function as ltext. ltext lists a bunch of parameters, srt among them, and refers you to the corresponding base R graphics function, which is text(). ?text then refers you to par for this and other miscellaneous parameters. ?par then tells you that srt gives the string rotation in degrees, the answer to your question. So, yes, it's a bit rough going; but careful attention to the docs DOES get you there. -- Bert On Thu, Jun 2, 2011 at 7:12 AM, maxbre mbres...@arpa.veneto.it wrote: thank you so much for the very detailed indications which turned out to be a real help in ponting me to the right direction; referring back to my previous questions there is something still open: 2- I'm in trouble with the point labels because I would like to rotate them by an angle of 90 degrees (and I did not find mention of anything like angle or rot to accomplish this task) panel.text(x, y, lab = mydata$name, cex = 0.6, pos=3, offset=0.5, here something to rotate labels) 3- I was referring to the error bar of each point (standard error of points); I think this could be accomplished by arrows but the following line is giving me an error panel.arrows(x=tv.avg-tv.erst, y=ped.avg-ped.erst, x1=tv.avg+tv.erst, y1=ped.avg+ped.erst, angle=90, code=3) thanks again for your great help in bootstrapping me to the lattice features maxbre -- View this message in context: http://r.789695.n4.nabble.com/lattice-panel-fine-control-tp3566347p3568424.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. -- Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions. -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics __ 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] Error message while mapping probes with hgu133plus2.db
Hi, eset is an expressionset based on hgu133plus2 platform. Using hgu133plus2.db package, I want to map probes to UniGene cluster IDs. It results in an error message. xx=hgu133plus2UNIGENE uniaf1=xx[[as.character(featureNames(eset))]] Error in .checkKeys(value, Lkeys(x), x@ifnotfound) : value for AFFX-r2-Hs18SrRNA-3_s_at not found Could you please help me figure out what creates the error ? Many thanks Vickie [[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] Problem with package development
I have run R CMD check trial1 and saw an error. This says that: * checking pdf version of manual without hyperrefs or index ... ERROR Re-running with no redirection of stdout/stderr. Hmm... looks like a package Error in texi2dvi(Rd2.tex, pdf = (out_ext == pdf), quiet = FALSE, : pdflatex is not available Error in running tools:: texi2dvi Does this information hwlp you to suggest something? Please let me know what else I can provide. Thanks, On Fri, Jun 3, 2011 at 12:00 AM, Nipesh Bajaj bajaj141...@gmail.com wrote: What else I need to do? In the Read-and-delete-me file following steps are asked to perform: * Edit the help file skeletons in 'man', possibly combining help files for multiple functions. * Edit the exports in 'NAMESPACE', and add necessary imports. * Put any C/C++/Fortran code in 'src'. * If you have compiled code, add a useDynLib() directive to 'NAMESPACE'. * Run R CMD build to build the package tarball. * Run R CMD check to check the package tarball. I editied the help page for fn1() function (as I already communicated in previous mail) as follows: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } And regarding th Namespace file, this time I put package.skeleton(trial1,namespace = FALSE, code_files = f:/trial.r) I do not have any C/C++ code so I ignored 3rd step. then Read-and-delete-me file asking me to build the package, so in cmd, I run following: cd C:\R_PackageBuild Rcmd build –binary trial1 What I am missing in this entire process? Do you please point me? Thanks, On Thu, Jun 2, 2011 at 11:40 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 02/06/2011 2:03 PM, Nipesh Bajaj wrote: Thanks Prof. Ripley and Duncan for your pointers. Noting down your points I have modified my way of building package and have done following so far: 1. In my C: drive I create one working folder naming R_PackageBuild 2. In R console I have written following codes: setwd(c:/R_packageBuild) package.skeleton(trial1,namespace = TRUE, code_files = f:/trial.r) 3. then I opened cmd and wrote following: cd C:\R_PackageBuild Rcmd build –binary trial1 This process halted with following error: Error: unexpected symbol in “tools:::.test_load_package(‘trial1′,….)” Execution halted ERROR: loading failed What I have missed in this process? Can you please help me how to solve this issue? You haven't done the manual changes required between steps 2 and 3. package.skeleton() creates the skeleton of a package; you run it once as you are starting development, the do a lot of manual updates, described on the ?package.skeleton help page, and in the ‘Read-and-delete-me’ file. Once those are done, step 3 should succeed. Duncan Murdoch Thanks, PS: I am sorry I missplet 'Program Files'. Thanks Prof. Ripley for this pointer. On Wed, Jun 1, 2011 at 11:41 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Wed, 1 Jun 2011, Nipesh Bajaj wrote: I have been struggling for last one hour but not yet any through. However again I recreate the package.skeleton and run R CMD check trial3 Here are the errors: warning in dir.create(pkgoutdir, mode = 0755): cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', reason . Error in printLog(Log, , text, \n): object 'Log' not found Execution haulted Why I am getting this error? what is that Log. I will really appreciate if somebody please help me to figure out. R CMD check writes a (in your case) trial3.Rcheck directory, and in there in file 00check.log a copy of the log. If it cannot create trial3.Rcheck it cannot write the log. I would be surprised that even on Windows Vista the message was literally reason . but if it was, blame Microsoft for their error messages. But cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', is clear enough. You need to run 'R CMD check' in your user area. In case you did this because that is where you though 'R' was, it is not the correct R.exe. You may need to add c:\Program Files\R\R-2.13.0\bin\i386 (assuming 32-bit R) to your path. However, your use of e.g. 'Program files' suggests you are not accurately transmitting the messages you got. Thanks, On Wed, Jun 1, 2011 at 1:20 AM, Nipesh Bajajbajaj141...@gmail.com wrote: Actually partly I followed. Here is the more details what I have done so far: 1. Edit the help file skeletons in 'man', possibly combining help files for multiple functions. I have modified with following: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A
Re: [R] Regex Question: return digits after particular letters
On Jun 2, 2011, at 2:54 PM, Ben Ganzfried wrote: Hi, First of all, I would like to introduce myself as I will probably have many questions over the next few weeks and want to thank you guys in advance for your help. I'm a cancer researcher and I need to learn R to complete a few projects. I have an introductory background in Python. My questions at the moment are based on the following sample input file: *Sample_Input_File* characteristics_ch1.3 Stage: T1N0 Stage: T2N1 Stage: T0N0 Stage: T1N0 Stage: T0N3 I haven't quite figured out what your structure really is, and for that you should learn to post the output of dput() on the R object... but see if this helps: stg - c('Stage: T1N0', 'Stage: T2N1', 'Stage: T0N0', 'Stage: T1N0', 'Stage: T0N3') Tstg - sub(.*T(\\d)N., \\1, stg) Tstg #[1] 1 2 0 1 0 Nstg - sub(.*T\\dN(\\d), \\1, stg) Nstg #[1] 0 1 0 0 3 characteristics_ch1.3 is a column header in the input excel file. T's represent stage and N's represent degree of disease spreading. I want to create output that looks like this: *Sample_Output_File* T N 1 0 2 1 0 0 1 0 0 3 As it currently stands, my code is the following: # rm(list=ls()) AND PLEASE DONT POST THAT CODE WITHOUT A COMMENT. I noticed it this time, but it is very aggravating to accidentally wide out hours of work while trying to offer help. source(../../functions.R) uncurated - read.csv(../uncurated/ Sample_Input_File_full_pdata.csv,as.is =TRUE,row.names=1) ##initial creation of curated dataframe curated - initialCuratedDF (rownames(uncurated),template.filename=Sample_Template_File.csv) ## ##start the mappings ## ##title - alt_sample_name curated$alt_sample_name - uncurated$title #T tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$T - tmp So here Tstg is tmp #N tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$N - tmp And Nstg is tmp write.table(curated, row.names=FALSE, file=../curated/Sample_Output_File_curated_pdata.txt,sep=\t) My question is the following: What code gets me the desired output (replacing the *??*'s above)? I want to: a) Find the integer value one element to the right of T; and b) find the integer value one element to the right of N. I've read the regular expression tutorial for R, but could only figure out how to grab an integer value if it is the only integer value in the row (ie more than one integer value makes this basic regular expression unsuccessful). Just surround it with a pattern and use the () , \\n mechanism Thank you very much for any help you can provide. Sincerely, Ben Ganzfried [[alternative HTML version deleted]] David Winsemius, MD West Hartford, CT __ 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] re-write plot function for ggplot
Doesn't deal with what problems? Hadley On Thursday, June 2, 2011, rmje robinmje...@gmail.com wrote: I have been browsing the pages about ggplot and it really doesn't deal with such problems as far as I can see. -- View this message in context: http://r.789695.n4.nabble.com/re-write-plot-function-for-ggplot-tp3565868p3568025.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. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ 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] Paid R Help
Hello R people, I am looking to pay someone to help write some R code. Inputs: Study identifier: ID Number for the study, each ID number is for one study only each block set should only be used for that study. This will require that you store the results from the blocks someplace on the file system. Trait #1: dichotomous rural / urban Trait #2: dichotomous sick / healthy Assignment Ratio: a number between 0 and 1, usually .5 but, for this study it would be .67. Indicating the % of participants to be randomized to the intervention arm. 1-the Assignment Ratio will be the number of participants to be randomized to the control arm. So for example, for each 6 person block, 4 would be assigned to intervention and 2 to control. Four blocks will be in action at any given time one each for each of the following combinations FOR EACH STUDY ID. Rural + sick Rural + healthy urban + sick urban + healthy The status of where we are in each block for each study will need to be stored somewhere. Returned value Study Arm: dichotomous Intervention / Control There might be some code that helps do this in R already. http://rss.acs.unt.edu/Rdoc/library/blockrand/html/blockrand.package.html http://docs.google.com/viewer?a=vq=cache:BnSasjcO0xQJ:personality-project.org/revelle/syllabi/205/block.randomization.pdf+r+block+randomizationhl=engl=uspid=blsrcid=ADGEESj9HQShWGzlfTJZOQQdCyohIcLV8HptDj8JZqsXbzDIZLUM6J3BDe6dpTsw95JcG6QDeiPn The purpose of block randomization is to insure equal distribution the two traits (in this case urban / rural and sick/healthy) across the two study arms. This will be called as each person enrolls in the study. So you will need to store the block data some place per study id. I am happy to pay someone to work on this problem for me. Please contact me off list, if you are willing and able. Thanks, Michael Hess University of Michigan ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues [[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] Plot cdf, pdf
Dear all, do you know any easy way based on a vector input how to plot easily cdf and pdf. I would like to thank you in advance for your help Regards Alex __ 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] Adding a line to a beside=TRUE barplot
Greetings Grateful for any help on this one: In the following demo code, I am trying to get the points in the line to appear over the same x-axis labels as are used by the paired Bars. It appears, however, that R/lattice ignores the x-axis points used by the bars and plots the x points for the line at ½ points. Can you help me tweak this code so that the nth bump in the line appears over the same nth pair of bars? Im open to any options besides lattice/barplot. library(lattice) aa - abs(rnorm(c(1:10)))*5 bb - abs(rnorm(c(1:10)))*5 cc - abs(rnorm(c(1:10)))*5 dd - as.matrix(cbind(aa, bb)) barplot(t(dd), beside=TRUE, ylim=c(0,10)) lines(cc) Many thanks, Galen [[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] plotmath: paste string and expression [from a vector of expressions]
On 02.06.2011 20:43, Marius Hofert wrote: Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars- vector(expression, 2) vars[1]- expression(alpha) vars[2]- expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Footheta, wheretheta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. plot(0, 0, main=expression(Foo ~~ theta)) Uwe Ligges Cheers, Marius __ 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] Removal of elements from nomograms
The rms package includes the nomogram function, which generates a list object that can be passed to plot for graphical production of nomograms. I would like to remove the linear predictor line in the graph, which means (I suspect) removing it from the nomogram output object. I've looked at the nomogram output object, but it is not clear to me if or how it might be edited to remove the linear predictor content. Similarly , I do not see how to coax nomogram() into not producing this output in the first place. As ever, thanks in advance are likely due to Frank Harrell, without whom many things would be much more difficult. __ 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] plotmath: paste string and expression [from a vector of expressions]
Dear Uwe, thanks for your help. Actually, I first thought about writing your solution in the email in order to make clear that it is not the solution I'm looking for :-) My goal is to work with the vector vars of expressions. The example is only a minimal example and for that your solution is perfectly fine, but my original problem is more complicated and there it makes sense to work with a vector of expressions. Do you know a solution to that? I tried many things... the obvious plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) did not work... Cheers, Marius On 2011-06-02, at 22:14 , Uwe Ligges wrote: On 02.06.2011 20:43, Marius Hofert wrote: Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars- vector(expression, 2) vars[1]- expression(alpha) vars[2]- expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Footheta, wheretheta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. plot(0, 0, main=expression(Foo ~~ theta)) Uwe Ligges Cheers, Marius __ 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] Regex Question: return digits after particular letters
Thank you very much for your help. It saved me a lot of time and it worked perfectly. I have a quick follow-up as I'm not sure I understand yet why the code works and where it comes from. For example, in: Tstg - sub(.*T(\\d)N., \\1, tmp) *How exactly does the substitution operation work? *On a high-level, I get that we are taking the values in the vector tmp, and replacing each tmp value with the integer immediately after the T. But more lower-level, how does .*T(\\d)N., \\1 actually get us there? I'll undoubtedly face similar but different situations many times in the future and I want to make sure that I know how to solve them. Thanks again--I really appreciate your kindness. Ben Ganzfried On Thu, Jun 2, 2011 at 3:33 PM, David Winsemius dwinsem...@comcast.netwrote: On Jun 2, 2011, at 2:54 PM, Ben Ganzfried wrote: Hi, First of all, I would like to introduce myself as I will probably have many questions over the next few weeks and want to thank you guys in advance for your help. I'm a cancer researcher and I need to learn R to complete a few projects. I have an introductory background in Python. My questions at the moment are based on the following sample input file: *Sample_Input_File* characteristics_ch1.3 Stage: T1N0 Stage: T2N1 Stage: T0N0 Stage: T1N0 Stage: T0N3 I haven't quite figured out what your structure really is, and for that you should learn to post the output of dput() on the R object... but see if this helps: stg - c('Stage: T1N0', 'Stage: T2N1', 'Stage: T0N0', 'Stage: T1N0', 'Stage: T0N3') Tstg - sub(.*T(\\d)N., \\1, stg) Tstg #[1] 1 2 0 1 0 Nstg - sub(.*T\\dN(\\d), \\1, stg) Nstg #[1] 0 1 0 0 3 characteristics_ch1.3 is a column header in the input excel file. T's represent stage and N's represent degree of disease spreading. I want to create output that looks like this: *Sample_Output_File* T N 1 0 2 1 0 0 1 0 0 3 As it currently stands, my code is the following: # rm(list=ls()) AND PLEASE DONT POST THAT CODE WITHOUT A COMMENT. I noticed it this time, but it is very aggravating to accidentally wide out hours of work while trying to offer help. source(../../functions.R) uncurated - read.csv(../uncurated/Sample_Input_File_full_pdata.csv, as.is =TRUE,row.names=1) ##initial creation of curated dataframe curated - initialCuratedDF(rownames(uncurated),template.filename=Sample_Template_File.csv) ## ##start the mappings ## ##title - alt_sample_name curated$alt_sample_name - uncurated$title #T tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$T - tmp So here Tstg is tmp #N tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$N - tmp And Nstg is tmp write.table(curated, row.names=FALSE, file=../curated/Sample_Output_File_curated_pdata.txt,sep=\t) My question is the following: What code gets me the desired output (replacing the *??*'s above)? I want to: a) Find the integer value one element to the right of T; and b) find the integer value one element to the right of N. I've read the regular expression tutorial for R, but could only figure out how to grab an integer value if it is the only integer value in the row (ie more than one integer value makes this basic regular expression unsuccessful). Just surround it with a pattern and use the () , \\n mechanism Thank you very much for any help you can provide. Sincerely, Ben Ganzfried [[alternative HTML version deleted]] David Winsemius, MD West Hartford, CT [[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] plotmath: paste string and expression [from a vector of expressions]
Hi: This seems to work: vars2 - c(quote(alpha), quote(beta)) # returns a list of mode call plot(0, 0, main = bquote(bold('Foo '~.(vars2[[2]] Expressions are only evaluated once, which means that inner expressions are not evaluated. You need a call object rather than an expression inside of bquote(). HTH, Dennis On Thu, Jun 2, 2011 at 11:43 AM, Marius Hofert m_hof...@web.de wrote: Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars - vector(expression, 2) vars[1] - expression(alpha) vars[2] - expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Foo theta, where theta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. Cheers, Marius __ 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] Regex Question: return digits after particular letters
On Jun 2, 2011, at 4:21 PM, Ben Ganzfried wrote: Thank you very much for your help. It saved me a lot of time and it worked perfectly. I have a quick follow-up as I'm not sure I understand yet why the code works and where it comes from. For example, in: Tstg - sub(.*T(\\d)N., \\1, tmp) How exactly does the substitution operation work? On a high-level, I get that we are taking the values in the vector tmp, and replacing each tmp value with the integer immediately after the T. But more lower-level, how does .*T(\\d)N., \\1 actually get us there? I'll undoubtedly face similar but different situations many times in the future and I want to make sure that I know how to solve them. The parentheses in the first pattern encloses the portion that can be referred to with \\1 in the second argument. Since I only enclosed the \\d (which is a single digit), that's what got substituted for the entire matched pattern. The initial part of the pattern was dotstar == .* which will match anything (or nothing) before the T, but since it wasn't in the parens, it gets dropped. It's actually all described on the regex page, but it helps to work through some examples to get the hang of it. -- David. Thanks again--I really appreciate your kindness. Ben Ganzfried On Thu, Jun 2, 2011 at 3:33 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 2, 2011, at 2:54 PM, Ben Ganzfried wrote: Hi, First of all, I would like to introduce myself as I will probably have many questions over the next few weeks and want to thank you guys in advance for your help. I'm a cancer researcher and I need to learn R to complete a few projects. I have an introductory background in Python. My questions at the moment are based on the following sample input file: *Sample_Input_File* characteristics_ch1.3 Stage: T1N0 Stage: T2N1 Stage: T0N0 Stage: T1N0 Stage: T0N3 I haven't quite figured out what your structure really is, and for that you should learn to post the output of dput() on the R object... but see if this helps: stg - c('Stage: T1N0', 'Stage: T2N1', 'Stage: T0N0', 'Stage: T1N0', 'Stage: T0N3') Tstg - sub(.*T(\\d)N., \\1, stg) Tstg #[1] 1 2 0 1 0 Nstg - sub(.*T\\dN(\\d), \\1, stg) Nstg #[1] 0 1 0 0 3 characteristics_ch1.3 is a column header in the input excel file. T's represent stage and N's represent degree of disease spreading. I want to create output that looks like this: *Sample_Output_File* T N 1 0 2 1 0 0 1 0 0 3 As it currently stands, my code is the following: # rm(list=ls()) AND PLEASE DONT POST THAT CODE WITHOUT A COMMENT. I noticed it this time, but it is very aggravating to accidentally wide out hours of work while trying to offer help. source(../../functions.R) uncurated - read.csv(../uncurated/ Sample_Input_File_full_pdata.csv,as.is =TRUE,row.names=1) ##initial creation of curated dataframe curated - initialCuratedDF (rownames(uncurated),template.filename=Sample_Template_File.csv) ## ##start the mappings ## ##title - alt_sample_name curated$alt_sample_name - uncurated$title #T tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$T - tmp So here Tstg is tmp #N tmp - uncurated$characteristics_ch1.3 tmp - *??* curated$N - tmp And Nstg is tmp write.table(curated, row.names=FALSE, file=../curated/Sample_Output_File_curated_pdata.txt,sep=\t) My question is the following: What code gets me the desired output (replacing the *??*'s above)? I want to: a) Find the integer value one element to the right of T; and b) find the integer value one element to the right of N. I've read the regular expression tutorial for R, but could only figure out how to grab an integer value if it is the only integer value in the row (ie more than one integer value makes this basic regular expression unsuccessful). Just surround it with a pattern and use the () , \\n mechanism Thank you very much for any help you can provide. Sincerely, Ben Ganzfried [[alternative HTML version deleted]] David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT [[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] print overlaid plots to a pdf file.. - Help please...
Dear Rxperts! Below are relevant lines of code, I am having problems with.. I am not sure if it is a bug in R or OS related or something else... When viewing the pdf file, I notice overlaid plots in a panel of the plot are shifted to the right. The Y-axes and X-labels are not exactly on top of each other. Would highly appreciate your suggestions.. Thanks, Santosh p1a - bwplot(Y~X,notch=T,data=d3,subset=TYPE==3,ylab='',scales=list(relation='free',alternating=1),do.out=F) p2a - stripplot(Y~X,notch=T,data=d3,subset=TYPE==3,as.table=T,ylab='',col='gray50',cex=0.5,jitter.data=T,scales=list(relation='free',alternating=1)) p1b - bwplot(Y~X,notch=T,data=d3,subset=TYPE==4,ylab='',scales=list(relation='free',alternating=1),do.out=F) p2b - stripplot(Y~X,notch=T,data=d3,subset=TYPE==4,as.table=T,ylab='',col='gray50',cex=0.5,jitter.data=T,scales=list(relation='free',alternating=1)) p1c - bwplot(Y~X,notch=T,data=d3,subset=TYPE==5,ylab='',scales=list(relation='free',alternating=1),do.out=F) p2c - stripplot(Y~X,notch=T,data=d3,subset=TYPE==5,as.table=T,col='gray50',cex=0.5,jitter.data=T,scales=list(relation='free',alternating=1)) pdf(paste(file.pdf,sep=''),h=4,w=11) print(p2a,split=c(1,1,2,1),more=T);print(p1a,split=c(1,1,2,1),more=T) print(p2b,split=c(2,1,2,1),more=T);print(p1b,split=c(2,1,2,1),more=T) dev.off() [[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] plotmath: paste string and expression [from a vector of expressions]
On Jun 2, 2011, at 4:19 PM, Marius Hofert wrote: Dear Uwe, thanks for your help. Actually, I first thought about writing your solution in the email in order to make clear that it is not the solution I'm looking for :-) My goal is to work with the vector vars of expressions. The example is only a minimal example and for that your solution is perfectly fine, but my original problem is more complicated and there it makes sense to work with a vector of expressions. Do you know a solution to that? I tried many things... the obvious plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) did not work... vars - vector(expression, 2) vars[[1]] - quote(alpha) vars[[2]] - quote(beta) plot(0, 0, main= bquote( paste(Foo , .(vars[[2]] )) ) ) -- DAvid. Cheers, Marius On 2011-06-02, at 22:14 , Uwe Ligges wrote: On 02.06.2011 20:43, Marius Hofert wrote: Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars- vector(expression, 2) vars[1]- expression(alpha) vars[2]- expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Footheta, wheretheta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. plot(0, 0, main=expression(Foo ~~ theta)) Uwe Ligges Cheers, Marius __ 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. David Winsemius, MD West Hartford, CT __ 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] Paid R Help
On Jun 2, 2011, at 2:41 PM, Hess, Michael wrote: Hello R people, I am looking to pay someone to help write some R code. Inputs: Study identifier: ID Number for the study, each ID number is for one study only each block set should only be used for that study. This will require that you store the results from the blocks someplace on the file system. Trait #1: dichotomous rural / urban Trait #2: dichotomous sick / healthy Assignment Ratio: a number between 0 and 1, usually .5 but, for this study it would be .67. Indicating the % of participants to be randomized to the intervention arm. 1-the Assignment Ratio will be the number of participants to be randomized to the control arm. So for example, for each 6 person block, 4 would be assigned to intervention and 2 to control. Four blocks will be in action at any given time one each for each of the following combinations FOR EACH STUDY ID. Rural + sick Rural + healthy urban + sick urban + healthy The status of where we are in each block for each study will need to be stored somewhere. Returned value Study Arm: dichotomous Intervention / Control There might be some code that helps do this in R already. http://rss.acs.unt.edu/Rdoc/library/blockrand/html/blockrand.package.html http://docs.google.com/viewer?a=vq=cache:BnSasjcO0xQJ:personality-project.org/revelle/syllabi/205/block.randomization.pdf+r+block+randomizationhl=engl=uspid=blsrcid=ADGEESj9HQShWGzlfTJZOQQdCyohIcLV8HptDj8JZqsXbzDIZLUM6J3BDe6dpTsw95JcG6QDeiPn The purpose of block randomization is to insure equal distribution the two traits (in this case urban / rural and sick/healthy) across the two study arms. This will be called as each person enrolls in the study. So you will need to store the block data some place per study id. I am happy to pay someone to work on this problem for me. Please contact me off list, if you are willing and able. Thanks, Michael Hess University of Michigan Michael, The means to do this is pretty straightforward using the blockrand() function in the package of the same name, as you reference above. You essentially have a stratified randomization, based upon two dichotomous factors. You are then doing a 2:1 randomization to the two arms in the study, within each of the four strata. Using blockrand(): # Set the RNG seed so that you can reproduce the sequence again in the future set.seed(1) # Generate 18 randomizations in one of the four strata, such that there will be # 3 blocks, each of size 6, with 4 Intervention and 2 Control subjects in each block # The actual block size used will be num.levels * block.sizes (6 * 1) Blocks1 - blockrand(18, num.levels = 6, levels = rep(c(I, C), c(4, 2)), stratum = Rural + Sick, block.sizes = 1) Blocks1 id stratum block.id block.size treatment 1 1 Rural + Sick1 6 I 2 2 Rural + Sick1 6 C 3 3 Rural + Sick1 6 I 4 4 Rural + Sick1 6 I 5 5 Rural + Sick1 6 I 6 6 Rural + Sick1 6 C 7 7 Rural + Sick2 6 I 8 8 Rural + Sick2 6 I 9 9 Rural + Sick2 6 C 10 10 Rural + Sick2 6 C 11 11 Rural + Sick2 6 I 12 12 Rural + Sick2 6 I 13 13 Rural + Sick3 6 I 14 14 Rural + Sick3 6 I 15 15 Rural + Sick3 6 C 16 16 Rural + Sick3 6 I 17 17 Rural + Sick3 6 C 18 18 Rural + Sick3 6 I It is then up to whatever data management system you are using to properly use the blocks in each stratum correctly, based upon the two characteristics that you are using for stratification. Just modify the 'stratum' value for each of the other 3 strata and be sure to change the RNG seed before each run so that each subsequent strata has a different sequence. You DO want to keep track of the RNG seed used before each run of blockrand(), so that you can reproduce the sequencing again in the future, if required. HTH, Marc Schwartz __ 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] Removal of elements from nomograms
The documentation includes this: nomogram(fit, ..., lp=FALSE) Frank Rob James-2 wrote: The rms package includes the nomogram function, which generates a list object that can be passed to plot for graphical production of nomograms. I would like to remove the linear predictor line in the graph, which means (I suspect) removing it from the nomogram output object. I've looked at the nomogram output object, but it is not clear to me if or how it might be edited to remove the linear predictor content. Similarly , I do not see how to coax nomogram() into not producing this output in the first place. As ever, thanks in advance are likely due to Frank Harrell, without whom many things would be much more difficult. __ 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. - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Removal-of-elements-from-nomograms-tp3569301p3569364.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.
Re: [R] Removal of elements from nomograms
On Jun 2, 2011, at 4:19 PM, Rob James wrote: The rms package includes the nomogram function, which generates a list object that can be passed to plot for graphical production of nomograms. I would like to remove the linear predictor line in the graph, which means (I suspect) removing it from the nomogram output object. I've looked at the nomogram output object, but it is not clear to me if or how it might be edited to remove the linear predictor content. Similarly , I do not see how to coax nomogram() into not producing this output in the first place. Setting the lp element to NULL would remove it from the object, but ... why? The plot and print functions depend on it, so your goals need a better elaboration. If you want to suppress plotting of the lp then looking at the code it appears that the plot.nomogram function uses the info attributes and a bit of experimentation shows that this surgery allows plotting of a nomogram without the Linear Predictor line: attr(nom, info)$lp - FALSE plot(nom, xfrac=.45) At least with the first example in the help(nomogram) page it does not seem to do violence to the result. And looking again at the help page, I see it is the fourth argument, so you could have just done it in the nomogram call with nomogram( . , lp=FALSE). As ever, thanks in advance are likely due to Frank Harrell, without whom many things would be much more difficult. But he cannot sit at our shoulders and read the help page to us it would seem. -- David Winsemius, MD West Hartford, CT __ 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] shading in overlap between two ranges
(1) For crying out loud don't muck about with par(new=TRUE) like that. Use points() and lines() (and other plot functions) to add graphical constructs to existing plots. (And use TRUE not T --- it's a lot safer.) (2) In general for shading in regions between two lines on a plot, use polygon(). cheers, Rolf Turner On 03/06/11 03:04, Graves, Gregory wrote: I have 2 datafiles 'target' and 'observed' as shown below (I will gladly email these 2 small files to whomever). X25. And X75. Indicate the value of 25th and 75th-percentile of the target ('what should be') and the observed ('what is'). The i.value is simply the month. target Xi.valueX25. X75. 1 one.month 1 10.845225 17.87237 2 one.month 2 12.235813 19.74490 3 one.month 3 14.611749 23.44810 4 one.month 4 17.529332 28.09647 5 one.month 5 19.458738 30.56936 6 one.month 6 15.264505 28.29333 7 one.month 7 12.370369 23.35455 8 one.month 8 12.471224 21.82794 9 one.month 9 9.716685 17.28762 10 one.month 10 6.470568 12.49830 11 one.month 11 6.180560 14.24961 12 one.month 12 9.673738 15.79208 observed X i.value X25. X75. 1 one.month 1 19.81000 27.63500 2 one.month 2 23.64062 30.09125 3 one.month 3 26.04865 35.99104 4 one.month 4 32.02625 41.50958 5 one.month 5 34.74479 47.75958 6 one.month 6 37.48885 46.56448 7 one.month 7 30.06740 40.10146 8 one.month 8 26.14917 39.49458 9 one.month 9 14.12521 32.39406 10 one.month 10 11.04125 23.55479 11 one.month 11 13.14917 23.56833 12 one.month 12 17.17938 27.02458 The following plots 4 lines on one graph. The area between the two red lines represents the target 'zone', and the area between the two black lines is the observed 'zone'. with(target, plot(X25.~i.value,ylim=c(0,55),type='l',col='red')) par(new=T) with(target, plot(X75.~i.value,ylim=c(0,55),type='l',col='red')) par(new=T) with(observed, plot(X25.~i.value,ylim=c(0,55),type='l')) par(new=T) with(observed, plot(X75.~i.value,ylim=c(0,55),type='l')) par(new=F) Ideally, the target and the observed should overlap in every month - they don't. The desire is to visually accentuate the amount of overlap by shading in the area where these two zones overlap. How would you do that? Note, that in some of these characterizations, the overlap wanders in and out [I already have routines that calculate the percent of overlap, but I have been requested to find a way to shade the overlap.] __ 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] Use line break at scrip but avoid line break on graphics
Hello list, I have plots with long strings in main=, ylab= or xlab=. So, in I my script I use break long lines to avoid lines hiden on my monitor and in sweave document pages. I use graphics like this plot(1, main= ) but I would like a plot result like this plot(1, main= ) I remember once I saw a meta character like \n that avoid this breack line plot(1, main=\(?) ) Does someone know that? Thanks. Walmes == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 == [[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] plotmath: paste string and expression [from a vector of expressions]
Dear Dennis, Dear Uwe, Dear David, many thanks for helping. Dennis and David, your solutions seemed perfectly fine, but when I applied it to my original problem, it did not show a title. Below is a (longer) minimal example (the first part is from the help page of bbmle). Is this a bug in bbmle? Hmmm... library(bbmle) x - 0:10 y - c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8) d - data.frame(x,y) ## in general it is best practice to use the `data' argument, ## but variables can also be drawn from the global environment LL - function(ymax=15, xhalf=6) -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) ## uses default parameters of LL (fit - mle2(LL)) ml - mle2(LL, fixed=list(xhalf=6)) mlp - profile(ml) vars - c(quote(theta), quote(beta)) plot(mlp, main=bquote(bold(Foo~.(vars[[2]] Cheers, Marius On 2011-06-02, at 22:23 , Dennis Murphy wrote: Hi: This seems to work: vars2 - c(quote(alpha), quote(beta)) # returns a list of mode call plot(0, 0, main = bquote(bold('Foo '~.(vars2[[2]] Expressions are only evaluated once, which means that inner expressions are not evaluated. You need a call object rather than an expression inside of bquote(). HTH, Dennis On Thu, Jun 2, 2011 at 11:43 AM, Marius Hofert m_hof...@web.de wrote: Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars - vector(expression, 2) vars[1] - expression(alpha) vars[2] - expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Foo theta, where theta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. Cheers, Marius __ 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] plotmath: paste string and expression [from a vectorof expressions]
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marius Hofert Sent: Thursday, June 02, 2011 1:20 PM To: Uwe Ligges Cc: Help R Subject: Re: [R] plotmath: paste string and expression [from a vectorof expressions] Dear Uwe, thanks for your help. Actually, I first thought about writing your solution in the email in order to make clear that it is not the solution I'm looking for :-) My goal is to work with the vector vars of expressions. The example is only a minimal example and for that your solution is perfectly fine, but my original problem is more complicated and there it makes sense to work with a vector of expressions. Do you know a solution to that? I tried many things... the obvious plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) did not work... Use VAR=vars[[2]] (double brackets) there. You can see the difference if you look at the output of your call to substitute. [[ gives you an element of the expression and [ gives you an expression containing an element: substitute(bold(Foo ~~ VAR), list(VAR=vars[[2]]) ) bold(Foo ~ ~beta) substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) ) bold(Foo ~ ~expression(beta)) The same holds for the bquote() solution that David W. suggested. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Cheers, Marius On 2011-06-02, at 22:14 , Uwe Ligges wrote: On 02.06.2011 20:43, Marius Hofert wrote: Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars- vector(expression, 2) vars[1]- expression(alpha) vars[2]- expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Footheta, wheretheta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. plot(0, 0, main=expression(Foo ~~ theta)) Uwe Ligges Cheers, Marius __ 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-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 with package development
I hope you're successful because I'm having issues as well building a simple package on windows. maybe when you're finished you can share back a step by step guide. On Thu, Jun 2, 2011 at 12:21 PM, Nipesh Bajaj bajaj141...@gmail.com wrote: I have run R CMD check trial1 and saw an error. This says that: * checking pdf version of manual without hyperrefs or index ... ERROR Re-running with no redirection of stdout/stderr. Hmm... looks like a package Error in texi2dvi(Rd2.tex, pdf = (out_ext == pdf), quiet = FALSE, : pdflatex is not available Error in running tools:: texi2dvi Does this information hwlp you to suggest something? Please let me know what else I can provide. Thanks, On Fri, Jun 3, 2011 at 12:00 AM, Nipesh Bajaj bajaj141...@gmail.com wrote: What else I need to do? In the Read-and-delete-me file following steps are asked to perform: * Edit the help file skeletons in 'man', possibly combining help files for multiple functions. * Edit the exports in 'NAMESPACE', and add necessary imports. * Put any C/C++/Fortran code in 'src'. * If you have compiled code, add a useDynLib() directive to 'NAMESPACE'. * Run R CMD build to build the package tarball. * Run R CMD check to check the package tarball. I editied the help page for fn1() function (as I already communicated in previous mail) as follows: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } And regarding th Namespace file, this time I put package.skeleton(trial1,namespace = FALSE, code_files = f:/trial.r) I do not have any C/C++ code so I ignored 3rd step. then Read-and-delete-me file asking me to build the package, so in cmd, I run following: cd C:\R_PackageBuild Rcmd build âbinary trial1 What I am missing in this entire process? Do you please point me? Thanks, On Thu, Jun 2, 2011 at 11:40 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 02/06/2011 2:03 PM, Nipesh Bajaj wrote: Thanks Prof. Ripley and Duncan for your pointers. Noting down your points I have modified my way of building package and have done following so far: 1. In my C: drive I create one working folder naming R_PackageBuild 2. In R console I have written following codes: setwd(c:/R_packageBuild) package.skeleton(trial1,namespace = TRUE, code_files = f:/trial.r) 3. then I opened cmd and wrote following: cd C:\R_PackageBuild Rcmd build âbinary trial1 This process halted with following error: Error: unexpected symbol in âtools:::.test_load_package(âtrial1â²,â¦.)â Execution halted ERROR: loading failed What I have missed in this process? Can you please help me how to solve this issue? You haven't done the manual changes required between steps 2 and 3. package.skeleton() creates the skeleton of a package; you run it once as you are starting development, the do a lot of manual updates, described on the ?package.skeleton help page, and in the âRead-and-delete-meâ file. Once those are done, step 3 should succeed. Duncan Murdoch Thanks, PS: I am sorry I missplet 'Program Files'. Thanks Prof. Ripley for this pointer. On Wed, Jun 1, 2011 at 11:41 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Wed, 1 Jun 2011, Nipesh Bajaj wrote: I have been struggling for last one hour but not yet any through. However again I recreate the package.skeleton and run R CMD check trial3 Here are the errors: warning in dir.create(pkgoutdir, mode = 0755): cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', reason . Error in printLog(Log, , text, \n): object 'Log' not found Execution haulted Why I am getting this error? what is that Log. I will really appreciate if somebody please help me to figure out. R CMD check writes a (in your case) trial3.Rcheck directory, and in there in file 00check.log a copy of the log. If it cannot create trial3.Rcheck it cannot write the log. I would be surprised that even on Windows Vista the message was literally reason . but if it was, blame Microsoft for their error messages. But cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', is clear enough. You need to run 'R CMD check' in your user area. In case you did this because that is where you though 'R' was, it is not the correct R.exe. You may need to add c:\Program Files\R\R-2.13.0\bin\i386 (assuming 32-bit R) to your path. However, your use of e.g. 'Program files' suggests you are not accurately transmitting the messages you got. Thanks, On Wed, Jun 1, 2011 at 1:20 AM, Nipesh
Re: [R] complex search between dataframes
On Jun 2, 2011, at 1:42 PM, Filippo Beleggia wrote: Hi! I am very new to R, I hope someone can help me. I have two dataframes: data1-data.frame(from=c(1,12,16,40,55,81,101),to=c(10,13,23,45,67,99,123)) data2-data.frame(name=c(1,2,3,4,5,6,7,8,9),position=c(2,14,20,50,150,2000,2001,2002,85)) I want to know which of the entries in position of data2 are included between any from and the corresponding to of data1. So in this case I would need to somehow be able to extract 2,20 and 85, corrisponding to the names 1,3 and 9. Thank you very much! Filippo See ?findInterval Coerce data1 into a matrix, so that the interval boundaries are in increasing order by columns, which is then actually used by findInterval as a vector (eg. c(1, 10, 12, ...)): t(data1) [,1] [,2] [,3] [,4] [,5] [,6] [,7] from1 12 16 40 55 81 101 to 10 13 23 45 67 99 123 findInterval() will return the interval indices for each data2$position value within the sorted intervals. Since your actual intervals are discontinuous, you only want the values that fit in the odd intervals, which is where the use of %in% seq(1, 13, 2) comes in. Prior to that, findInterval() returns: findInterval(data2$position, t(data1)) [1] 1 4 5 8 14 14 14 14 11 With it: findInterval(data2$position, t(data1)) %in% seq(1, 13, 2) [1] TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE Now you can use the TRUE values to index data2$name: data2$name[findInterval(data2$position, t(data1)) %in% seq(1, 13, 2)] [1] 1 3 9 or data2$position: data2$position[findInterval(data2$position, t(data1)) %in% seq(1, 13, 2)] [1] 2 20 85 HTH, Marc Schwartz __ 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 with package development
Still I am struggling to get some inputs from the experts here :( Definitely We can shere our experiences once I am done (really, it seems to me very hard nut to crack!) I strongly feel that related documentations should be more Statistician-friendly, than some Engg. guys Thanks, On Fri, Jun 3, 2011 at 2:55 AM, steven mosher mosherste...@gmail.com wrote: I hope you're successful because I'm having issues as well building a simple package on windows. maybe when you're finished you can share back a step by step guide. On Thu, Jun 2, 2011 at 12:21 PM, Nipesh Bajaj bajaj141...@gmail.com wrote: I have run R CMD check trial1 and saw an error. This says that: * checking pdf version of manual without hyperrefs or index ... ERROR Re-running with no redirection of stdout/stderr. Hmm... looks like a package Error in texi2dvi(Rd2.tex, pdf = (out_ext == pdf), quiet = FALSE, : pdflatex is not available Error in running tools:: texi2dvi Does this information hwlp you to suggest something? Please let me know what else I can provide. Thanks, On Fri, Jun 3, 2011 at 12:00 AM, Nipesh Bajaj bajaj141...@gmail.com wrote: What else I need to do? In the Read-and-delete-me file following steps are asked to perform: * Edit the help file skeletons in 'man', possibly combining help files for multiple functions. * Edit the exports in 'NAMESPACE', and add necessary imports. * Put any C/C++/Fortran code in 'src'. * If you have compiled code, add a useDynLib() directive to 'NAMESPACE'. * Run R CMD build to build the package tarball. * Run R CMD check to check the package tarball. I editied the help page for fn1() function (as I already communicated in previous mail) as follows: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } And regarding th Namespace file, this time I put package.skeleton(trial1,namespace = FALSE, code_files = f:/trial.r) I do not have any C/C++ code so I ignored 3rd step. then Read-and-delete-me file asking me to build the package, so in cmd, I run following: cd C:\R_PackageBuild Rcmd build –binary trial1 What I am missing in this entire process? Do you please point me? Thanks, On Thu, Jun 2, 2011 at 11:40 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 02/06/2011 2:03 PM, Nipesh Bajaj wrote: Thanks Prof. Ripley and Duncan for your pointers. Noting down your points I have modified my way of building package and have done following so far: 1. In my C: drive I create one working folder naming R_PackageBuild 2. In R console I have written following codes: setwd(c:/R_packageBuild) package.skeleton(trial1,namespace = TRUE, code_files = f:/trial.r) 3. then I opened cmd and wrote following: cd C:\R_PackageBuild Rcmd build –binary trial1 This process halted with following error: Error: unexpected symbol in “tools:::.test_load_package(‘trial1′,….)” Execution halted ERROR: loading failed What I have missed in this process? Can you please help me how to solve this issue? You haven't done the manual changes required between steps 2 and 3. package.skeleton() creates the skeleton of a package; you run it once as you are starting development, the do a lot of manual updates, described on the ?package.skeleton help page, and in the ‘Read-and-delete-me’ file. Once those are done, step 3 should succeed. Duncan Murdoch Thanks, PS: I am sorry I missplet 'Program Files'. Thanks Prof. Ripley for this pointer. On Wed, Jun 1, 2011 at 11:41 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Wed, 1 Jun 2011, Nipesh Bajaj wrote: I have been struggling for last one hour but not yet any through. However again I recreate the package.skeleton and run R CMD check trial3 Here are the errors: warning in dir.create(pkgoutdir, mode = 0755): cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', reason . Error in printLog(Log, , text, \n): object 'Log' not found Execution haulted Why I am getting this error? what is that Log. I will really appreciate if somebody please help me to figure out. R CMD check writes a (in your case) trial3.Rcheck directory, and in there in file 00check.log a copy of the log. If it cannot create trial3.Rcheck it cannot write the log. I would be surprised that even on Windows Vista the message was literally reason . but if it was, blame Microsoft for their error messages. But cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', is clear enough. You need to run 'R CMD check' in your user area. In case you did this because that is where you though 'R' was, it
Re: [R] Use line break at scrip but avoid line break on graphics
On 03/06/11 09:03, Walmes Zeviani wrote: Hello list, I have plots with long strings in main=, ylab= or xlab=. So, in I my script I use break long lines to avoid lines hiden on my monitor and in sweave document pages. I use graphics like this plot(1, main= ) but I would like a plot result like this plot(1, main= ) I remember once I saw a meta character like \n that avoid this breack line plot(1, main=\(?) ) Does someone know that? I think that plot(1,main=paste(, )) might do what you want. cheers, Rolf Turner __ 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 with package development
I don't use windows, but this error message you report: Error in texi2dvi(Rd2.tex, pdf = (out_ext == pdf), quiet = FALSE, : pdflatex is not available Error in running tools:: texi2dvi strongly indicates that you need to install pdflatex, don't you think? If you don't have non-R code (c or fortran) you can probably get away without having the MinGW compiler tools, but you do need the rest of the things listed in the admin manual as required for building packages: http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset In addition, googling for building R packages on Windows turns up very many detailed guides for going through the process, including discussions of what additional software you need and how to install it. Sarah On Thu, Jun 2, 2011 at 6:03 PM, Nipesh Bajaj bajaj141...@gmail.com wrote: Still I am struggling to get some inputs from the experts here :( Definitely We can shere our experiences once I am done (really, it seems to me very hard nut to crack!) I strongly feel that related documentations should be more Statistician-friendly, than some Engg. guys Thanks, On Fri, Jun 3, 2011 at 2:55 AM, steven mosher mosherste...@gmail.com wrote: I hope you're successful because I'm having issues as well building a simple package on windows. maybe when you're finished you can share back a step by step guide. On Thu, Jun 2, 2011 at 12:21 PM, Nipesh Bajaj bajaj141...@gmail.com wrote: I have run R CMD check trial1 and saw an error. This says that: * checking pdf version of manual without hyperrefs or index ... ERROR Re-running with no redirection of stdout/stderr. Hmm... looks like a package Error in texi2dvi(Rd2.tex, pdf = (out_ext == pdf), quiet = FALSE, : pdflatex is not available Error in running tools:: texi2dvi Does this information hwlp you to suggest something? Please let me know what else I can provide. Thanks, -- Sarah Goslee http://www.functionaldiversity.org __ 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] Use line break at scrip but avoid line break on graphics
On Thu, Jun 2, 2011 at 3:13 PM, Rolf Turner rolf.tur...@xtra.co.nz wrote: On 03/06/11 09:03, Walmes Zeviani wrote: Hello list, I have plots with long strings in main=, ylab= or xlab=. So, in I my script I use break long lines to avoid lines hiden on my monitor and in sweave document pages. I use graphics like this plot(1, main= ) but I would like a plot result like this plot(1, main= ) I remember once I saw a meta character like \n that avoid this breack line plot(1, main=\(?) ) Does someone know that? I think that plot(1,main=paste(, )) might do what you want. I think he needs plot(1,main=paste(\n, , sep = )) or simply plot(1, main=\n) Peter __ 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] plotmath: paste string and expression [from a vector of expressions]
On Jun 2, 2011, at 5:07 PM, Marius Hofert wrote: Dear Dennis, Dear Uwe, Dear David, many thanks for helping. Dennis and David, your solutions seemed perfectly fine, but when I applied it to my original problem, it did not show a title. Below is a (longer) minimal example (the first part is from the help page of bbmle). Is this a bug in bbmle? Hmmm... library(bbmle) x - 0:10 y - c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8) d - data.frame(x,y) ## in general it is best practice to use the `data' argument, ## but variables can also be drawn from the global environment LL - function(ymax=15, xhalf=6) -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) ## uses default parameters of LL (fit - mle2(LL)) ml - mle2(LL, fixed=list(xhalf=6)) mlp - profile(ml) vars - c(quote(theta), quote(beta)) plot(mlp, main=bquote(bold(Foo~.(vars[[2]] I do not have experience with that package but my guess is that the plot.mle2 (or whatever its name might be... ) function does something different. class(mlp) returns profile.mle2. Looking at the documentation you see that it is using S4 methods and using Methods() one sees that there is a 'plot' method for 'profile.mle2' objects. That's about as far as I go. whine-mode on Navigating S4 methods is an arcane art into which I have not initiated myself. Unlike S3 methods where you just type the function name and it's easy to figure out what the names will be, there are several levels of specification and the help pages for Methods' are not, ... helpful to one who approaches it without more experience than I have. The help page regarding acceptable expressions to pass to main arguments is not particularly helpful, either. I would advise asking the package author or maintainer. Before anyone berates me for insufficient effort at self-learning, I swear that my copy of Chambers (2008) arrived this week. I do think it would be helpful to have a worked example near the top of examples on help(Methods) that shows HOW_TO get at the functional machinery for a plot method when one knows the class of an object. After some further experimentation I have a theory that the 'main' argument will not accept a language object but that one can coerce to an expression object and succeed. (Didn't I go through this once before? Maybe this was what Hadley was trying to teach me about a month ago.) whine-mode off # -Answer plot(mlp, main=as.expression(bquote(bold(Foo~.(vars[[2]]) )) ) ) # --- back your regularly scheduled programming --- -- DAvid. Cheers, Marius On 2011-06-02, at 22:23 , Dennis Murphy wrote: Hi: This seems to work: vars2 - c(quote(alpha), quote(beta)) # returns a list of mode call plot(0, 0, main = bquote(bold('Foo '~.(vars2[[2]] Expressions are only evaluated once, which means that inner expressions are not evaluated. You need a call object rather than an expression inside of bquote(). HTH, Dennis On Thu, Jun 2, 2011 at 11:43 AM, Marius Hofert m_hof...@web.de wrote: Dear all, I have a vector of expressions and would like to paste some string to it before using it in a plot: vars - vector(expression, 2) vars[1] - expression(alpha) vars[2] - expression(beta) plot(0, 0, main=substitute(bold(Foo ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be Foo theta, where theta is the greek letter. I tried some constructions with bquote but that wasn't successful... I also looked in the mailing list but couldn't find anything helpful [I am sure I overlooked something]. Cheers, Marius __ 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, MD West Hartford, CT __ 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] Use line break at scrip but avoid line break on graphics
On Jun 2, 2011, at 6:13 PM, Rolf Turner wrote: On 03/06/11 09:03, Walmes Zeviani wrote: Hello list, I have plots with long strings in main=, ylab= or xlab=. So, in I my script I use break long lines to avoid lines hiden on my monitor and in sweave document pages. I use graphics like this plot(1, main= ) but I would like a plot result like this plot(1, main= ) I remember once I saw a meta character like \n that avoid this breack line plot(1, main=\(?) ) Does someone know that? I think that plot(1,main=paste(, )) Look, Ma, no quotes! Er, well, maybe one quote. plot(1, main=quote(~ ) ) -- David Winsemius, MD West Hartford, CT __ 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] lattice + plotmath: how to get a variable in bold face?
Dear all, How can I get a bold 1000 in the title? I would like to use a variable (as opposed to putting in 1000 directly). library(lattice) N - 1000 xyplot(0~0, xlab.top=list(label=as.expression(bquote(bold(foo ~ .(N) ~ bar))), font=2, cex=1.2)) ## = font=2 is ignored (of course) Cheers, Marius __ 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 + plotmath: how to get a variable in bold face?
On 2011-06-02 15:50, Marius Hofert wrote: Dear all, How can I get a bold 1000 in the title? I would like to use a variable (as opposed to putting in 1000 directly). library(lattice) N- 1000 xyplot(0~0, xlab.top=list(label=as.expression(bquote(bold(foo ~ .(N) ~ bar))), font=2, cex=1.2)) ## = font=2 is ignored (of course) You could add N - as.character(N) before your call to xyplot. Peter Ehlers Cheers, Marius __ 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 with package development
Hi, On Thu, Jun 2, 2011 at 11:30 AM, Nipesh Bajaj bajaj141...@gmail.com wrote: I editied the help page for fn1() function (as I already communicated in previous mail) as follows: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. What makes you think this qualifies as editing? Please read the Writing R Extensions manual thoroughly. If you had, you would see that what you have written will clearly not work (though I would think this intuitively obvious if you have ever read documentation for R...what function is simply documented, A function.?). Here is a link to the manual: http://cran.r-project.org/doc/manuals/R-exts.html it actually provides a wealth of information and when I was writing my first package, I kept it open and constantly referred to it as I was writing documentation, naming files, creating the DESCRIPTION file, etc. The other resource that helped me tremendously was Dr. Chambers book Software for Data Analysis. You might also consider downloading the source code for a package (I just used the SoDA package) so you have an example of how someone who knows what they are doing writes a package. I feel pretty strongly that: I strongly feel that related documentations should be more Statistician-friendly, than some Engg. guys is quite an unfair statement given all the time and effort R core has put not only into writing R, but making manuals and documentation that, while complex at times, are extremely thorough to the point that I, as a psychologist, with no training in computer science, engineering, or statistics, was able to blunder my way along just by carefully going through their work. Best of luck to you, Josh } \arguments{ A function. } \value{ A function. } \author{ \bold{Me} \cr \email{m...@me.com} } And regarding th Namespace file, this time I put package.skeleton(trial1,namespace = FALSE, code_files = f:/trial.r) I do not have any C/C++ code so I ignored 3rd step. then Read-and-delete-me file asking me to build the package, so in cmd, I run following: cd C:\R_PackageBuild Rcmd build –binary trial1 What I am missing in this entire process? Do you please point me? Thanks, On Thu, Jun 2, 2011 at 11:40 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 02/06/2011 2:03 PM, Nipesh Bajaj wrote: Thanks Prof. Ripley and Duncan for your pointers. Noting down your points I have modified my way of building package and have done following so far: 1. In my C: drive I create one working folder naming R_PackageBuild 2. In R console I have written following codes: setwd(c:/R_packageBuild) package.skeleton(trial1,namespace = TRUE, code_files = f:/trial.r) 3. then I opened cmd and wrote following: cd C:\R_PackageBuild Rcmd build –binary trial1 This process halted with following error: Error: unexpected symbol in “tools:::.test_load_package(‘trial1′,….)” Execution halted ERROR: loading failed What I have missed in this process? Can you please help me how to solve this issue? You haven't done the manual changes required between steps 2 and 3. package.skeleton() creates the skeleton of a package; you run it once as you are starting development, the do a lot of manual updates, described on the ?package.skeleton help page, and in the ‘Read-and-delete-me’ file. Once those are done, step 3 should succeed. Duncan Murdoch Thanks, PS: I am sorry I missplet 'Program Files'. Thanks Prof. Ripley for this pointer. On Wed, Jun 1, 2011 at 11:41 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Wed, 1 Jun 2011, Nipesh Bajaj wrote: I have been struggling for last one hour but not yet any through. However again I recreate the package.skeleton and run R CMD check trial3 Here are the errors: warning in dir.create(pkgoutdir, mode = 0755): cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', reason . Error in printLog(Log, , text, \n): object 'Log' not found Execution haulted Why I am getting this error? what is that Log. I will really appreciate if somebody please help me to figure out. R CMD check writes a (in your case) trial3.Rcheck directory, and in there in file 00check.log a copy of the log. If it cannot create trial3.Rcheck it cannot write the log. I would be surprised that even on Windows Vista the message was literally reason . but if it was, blame Microsoft for their error messages. But cannot create dir 'c:\Program files\R\R-2.13.0\bin\trial3.Rcheck', is clear enough. You need to run 'R CMD check' in your user area. In case you did this because that is where you though 'R' was, it is not the correct R.exe. You may need to add c:\Program Files\R\R-2.13.0\bin\i386 (assuming 32-bit R) to your path. However, your use of e.g. 'Program files' suggests you are not accurately transmitting the
Re: [R] Use line break at scrip but avoid line break on graphics
On 03/06/11 10:16, Peter Langfelder wrote: On Thu, Jun 2, 2011 at 3:13 PM, Rolf Turnerrolf.tur...@xtra.co.nz wrote: On 03/06/11 09:03, Walmes Zeviani wrote: Hello list, I have plots with long strings in main=, ylab= or xlab=. So, in I my script I use break long lines to avoid lines hiden on my monitor and in sweave document pages. I use graphics like this plot(1, main= ) but I would like a plot result like this plot(1, main= ) I remember once I saw a meta character like \n that avoid this breack line plot(1, main=\(?) ) Does someone know that? I think that plot(1,main=paste(, )) might do what you want. I think he needs plot(1,main=paste(\n, , sep = )) or simply plot(1, main=\n) Absolutely not! Did you *read* the OP's question? He wants to break the line in the code --- for readable code presumably --- but ***not*** in the output! Your advice is the antithesis of what is required. cheers, Rolf Turner __ 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] Use line break at scrip but avoid line break on graphics
Absolutely not! Did you *read* the OP's question? He wants to break the line in the code --- for readable code presumably --- but ***not*** in the output! Your advice is the antithesis of what is required. cheers, Rolf Turner I stand corrected, indeed I missed the crucial part of the OP's post. Peter __ 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 with package development
On 03/06/11 11:33, Joshua Wiley wrote: Hi, On Thu, Jun 2, 2011 at 11:30 AM, Nipesh Bajajbajaj141...@gmail.com wrote: I editied the help page for fn1() function (as I already communicated in previous mail) as follows: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. What makes you think this qualifies as editing? Please read the Writing R Extensions manual thoroughly. If you had, you would see that what you have written will clearly not work (though I would think this intuitively obvious if you have ever read documentation for R...what function is simply documented, A function.?). SNIP Huh? What on earth are you on about? This is just a toy example to get things working and in such instances a title such as ``A function'' is perfectly acceptable. It looks to me like the OP's editing was done adequately, and is *not* the source of the OP's problems. Sarah Goslee has already pointed out what at least one of the sources of his problems is. cheers, Rolf Turner __ 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 with package development
On Thu, Jun 2, 2011 at 4:49 PM, Rolf Turner rolf.tur...@xtra.co.nz wrote: On 03/06/11 11:33, Joshua Wiley wrote: Hi, On Thu, Jun 2, 2011 at 11:30 AM, Nipesh Bajajbajaj141...@gmail.com wrote: I editied the help page for fn1() function (as I already communicated in previous mail) as follows: \name{fn1} \alias{fn1} \title{ A function. } \description{ A function. } \usage{ A function. What makes you think this qualifies as editing? Please read the Writing R Extensions manual thoroughly. If you had, you would see that what you have written will clearly not work (though I would think this intuitively obvious if you have ever read documentation for R...what function is simply documented, A function.?). SNIP Huh? What on earth are you on about? This is just a toy example to get things working and in such instances a title such as ``A function'' is perfectly acceptable. Really? R CMD check screams bloody murder at me: Bad \usage lines found in documentation object 'fn1': A function. Functions with \usage entries need to have the appropriate \alias entries, and all their arguments documented. The \usage entries must correspond to syntactically valid R code. See the chapter 'Writing R documentation files' in the 'Writing R Extensions' manual. It looks to me like the OP's editing was done adequately, and is *not* the source of the OP's problems. Sarah Goslee has already pointed out what at least one of the sources of his problems is. cheers, Rolf Turner -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] Problem with package development
Okay, that might have been a little strong. screams bloody murder is a warning, not technically an error, and does not occur when simply running R CMD build. That said, the OP did mention using R CMD check and pdflatex is not an issue when only building anyway. Still, it is not the cause of the earlier problems and I was probably overly harsh and I give my sincerest apology. Josh __ 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 with package development
On 03/06/11 12:16, Joshua Wiley wrote: Okay, that might have been a little strong. screams bloody murder is a warning, not technically an error, and does not occur when simply running R CMD build. That said, the OP did mention using R CMD check and pdflatex is not an issue when only building anyway. Still, it is not the cause of the earlier problems and I was probably overly harsh and I give my sincerest apology. Apology accepted, from my corner of the forest anyhow. cheers, Rolf __ 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.