Re: [R] R suitability for development project
On 03/09/12 14:15, Eric Langley wrote: Hello All, Eric Langley here with my first post to this list. I am looking to determine if R is suitable for a development project I am working on and if so possibly finding someone proficient in R that would be interested in doing the coding. Is there monetary reward involved? Or are you just counting on people's good nature? I would like to preface my inquiry that while I am not a programmer I can communicate in a dialog my objectives. An array of rank ordered data looks like this: Item-Rank First Second Third Fourth Totals Item1 6 8 0 0 14 Item2 7 5 2 0 14 Item3 1 1 11 1 14 Item4 0 0 1 1314 Totals14 1414 14 The required output of R will be two fold; 1, a numerical score for each of the Items (1-4) from highest to lowest and lowest to highest on a scale of 0-99 that is statistically accurate. For this example the scores would be Item1 highest number down to Item4 with the lowest number. In reverse Item4 would be the highest number down to Item1 the lowest number. For the Highest like this; Item1=94, Item2=88, Item3=48, Item4=2 (just guessing here on the scores...:) 2, a graphical output of the data based on the scores in three special graphs with a middle line at '0' and increasing numbers to the left AND right. The graphs plot the Highest ranked Items, the Lowest Ranked items and a combination of the two. Sample graphs are here: http://community.abeo.us/sample-graphs/ Looking forward to hearing if R will be able to accomplish this. This reminds me of fortune(driveway) from the fortunes package. 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] fitting lognormal censored data
You should keep your replies on the R-help list by always cc-ing to that list. As you were asked to do in a previous thread you started. As I demonstrated in a previous reply, the R function optim() is perfectly capable of minimizing or maximizing your likelihood function. Your attempts at using the Newton method for finding a maximum will only work if the starting point is (very) close to the solution. In addition using Newton to solve gradient(f) = 0 to find a minimum/maximum is not the best way to go about this. There is no guarantee that the Hessian at the initial point is positive definite (for a minimum). You will be better off using functions like optim() or nlminb() I do not know much about the EM algorithm and I cannot judge whether what you are trying to do is correct or sensible. For speeding up EM iterations you could have a look the SQUAREM packages. I feel that you should consult an expert on this method. The code you have provided is not complete in the sense that you must be using packages such as numDeriv but I cannot see any library statements. From the limited experiments I have done with your code I get the impression that there is something wrong with the way parameter theta is used/implemented. Berend On 01-09-2012, at 14:11, Salma Wafi wrote: Dear Berend, Thanks alot for your response and help. really your help is very appreciated. Sorry if my code was unreadable and I hope you give me excuse in this , since I am new R user and there is no one in my area know about R. Dear, I am trying to estimate my parameters by calculating derivatives of loglikelihood function and using Newton raphson method because I need to estimate another parameter, which will be added to my likelihood function, and the information that I have about this parameter are partially missing. so I want to estimate the parameters using MLE via EM algorithm, which is composed of two steps; an Expectation (E) step which computes the expectation of the log likelihood function using the observed data set followed by a maximization (M) step which computes the parameters that maximize the expected log likelihood function found in the E-step. Then, I need to get estimators using Newton raphson method at one step and then use them to compute the E step, and so on ! till convergence has been met. But because I face overestimation problem, I tried to realize my mistake by estimating only MLE of lognormal censored data. Furthermore, I tried to write my code as what you suggest , using grad and hessian of log likelihood function and use them to calculate the Newton rapson method but also I faced some problem in this, where there is no convergence in my estimations . Dear, do you think the reason of this can be because of hessian matrix is not positive point? And in this case how we can avoid it?. Dear, I am sorry to disturb you. Really, I work individually and lost more than 3 months trying to solve this problem. The following are, my trying to calculate Newton raphson using the grad and hessian of log likelihood instead of the derivatives and my original code that I am trying to estimate the parameters mu, s and theta using MLE via EM algorithm. ### caculating Newton Rahson using grad and hessian of log likelihood cur=curd=cen=cens=array(1,100) Cur=RealCur=realcensoring=realcured=array(1,20) ExpCure=Bias=RealCure=array(1,21) dat1-data.frame(time=rlnorm( 100,2,0.8),Censored=rbinom(100,1,0.9),Cured=rbinom(100,1,.3)) dat2-dat1[order(dat1[,1]),] # order the data # for (i in 1:10) { dat2$Cured[i+90]=0 #Long term survivors/10 individuals# dat2$Censored[i+90]=0 dat2$time[i+90]=dat2$time[90] } cens-c(dat2$Censored) #censored status # curd-c(dat2$Cured)#cured status # tim-c(dat2$time) #lifetimes # L1-length(cens) #number of censored# for (j in 1:L1) { if ((cens[j]==1)(curd[j]==0)) {(cen[j]=1)(cur[j]=1)} else {(cen[j]=cens[j])(cur[j]=curd[j])} } ### My Data only with uncensored and right censored data=data.frame(Ti=dat1$time,Censored=cen) ### Seperating the data for simply using optim and Newton Raphson ## dat2-c(split(data[1:2],data$Censored==1)) # Split the data(cen/uncen) # tun-c((dat2$'TRUE')$Ti) # Life times data set for uncensored # tcen-c((dat2$'FALSE')$Ti) # Life times data set for censored # outm=outs=array() loglikelihood function ml= function(par){mu=par[1] s=par[2] +sum(dlnorm(tun,mu,s,log=TRUE))+sum(log(1-plnorm(tcen,mu,s)))} #
[R] Call for contribution: the RDataMining package - an R package for data mining
Join the RDataMining project to build a comprehensive R package for data mining http://www.rdatamining.com/package We have started the RDataMining project on R-Forge to build an R package for data mining. The package will provide various functionalities for data mining, with contributions from many R users. If you have developed or will implement any data mining algorithms in R, please participate in the project to make your work available to R users worldwide. Background == Although there are many R packages for various data mining functionalities, there are many more new algorithms designed and published every year, without any R implementations for them. It is far beyond the capability of a single team, even several teams, to build packages for oncoming new data mining algorithms. On the other hand, many R users developed their own implementations of new data mining algorithms, but unfortunately, used for their own work only, without sharing with other R users. The reason could be that they donot know or donot have time to build packages to share their code, or they might think that it is not worth building a package with only one or two functions. Objective = To forester the development of data mining capability in R and facilitate sharing of data mining codes/functions/algorithms among R users, we started this project on R-Forge to collaboratively build an R package for data mining, with contributions from many R users, including ourselves. How it works = The project works in a way similar to an edited book. We, as organizers, send out call for participation and solicit R users to join this project and contribute their implemented functions and algorithms. The contributed functions will build up and make a package. Function authors will be responsible for the development, maintenance and documentation of their contributed functions. We will put all functions together as one package and also make a manual for the package. Function authors will be acknowledged as authors of corresponding functions in help documentation and manual of the package. We, as the organizers of the package, will be shown as the manager/maintainer of the whole package. It's free to join or quit the project at any time, and authors can withdraw their contributed functions at any time. Links = The RDataMining package and project: http://www.rdatamining.com/package The RDataMining project on R-Forge: http://package.rdatamining.com or http://r-forge.r-project.org/projects/rdatamining/ Contact === Yanchang Zhao yanchang at rdatamining.com Join the RDataMining Project, and we will work together to build a comprehensive R package for data mining. Regards Yanchang Zhao PhD, Data Miner Email: yanchangz...@gmail.com RDataMining Website:http://www.rdatamining.com RDataMining Package: http://www.rdatamining.com/package RDataMining on Twitter: http://twitter.com/RDataMining Group on LinkedIn: http://group.rdatamining.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] Common elements in columns
Hi Arun, it's exactly what I wanted. Thanks a lot, Hi, May be this might help: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) df1$C1[df1$C1%in%df2$C1[df2$C1%in%df3$C1[df3$C1%in%df4$C1]]] #[1] G E H J A.K. - Original Message - From: Silvano Cesar da Costa silv...@uel.br To: r-help@r-project.org Cc: Sent: Sunday, September 2, 2012 7:05 PM Subject: [R] Common elements in columns Hi, I have 4 files with 1 individuals in each file and 10 columns each. One of the columns, say C1, may have elements in common with the other columns C1 of other files. If I have only 2 files, I can do this check with the command: data1[data1 %in% data2] data2[data2 %in% data1] How do I check which common elements in the columns of C1 4 files? Thanks, - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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. - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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] select specific rows from regression output
Hello everyone, I have a data set that contains characteristics of 25,000 patients of 92 different hospitals. I have run a regression to capture the probability these patients will have a complication after a certain operation. Now, I actually want to predict the probability per patient, using the outcome of the regression, but I just certain patients involved in the prediction. So, I want to use the estimated parameters of the full regression, but after that, I only want patients with certain characteristics in my prediction matrix. For example, only patients with BMI 25. My regressional formula looks as follows: fit = glmer(response ~ sex+bmi+asa+ (1|center), data=data, family=binomial), and my normal prediction formula: pred=fit@X %*% fit@fixef. I hope someone can help me! Greetings, 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.
Re: [R] Class that wraps Data Frame
Thanks to everyone for all their help. I will investigate more. I am not attached to S4 at all, but it sounds like it might be a good option. I will look into bioconductor for examples. Thanks again, Ramiro From: Martin Morgan [mtmor...@fhcrc.org] Sent: Friday, August 31, 2012 12:33 PM To: Bert Gunter Cc: David Winsemius; r-help@r-project.org; Ramiro Barrantes Subject: Re: [R] Class that wraps Data Frame I guess there are two issues with data.frame. It comes with more than you probably want to support (e.g., list and matrix- like subsetter [, the user expecting to be able to independently modify any column). And it comes with less than you'd like (e.g., support for a 'column' of S4 objects). By making a class that contains ('is a') data.frame, you commit to both limitations. You're probably using data.frame as a way to implement some basic restrictions -- equal-length columns, for instance. But there are additional restrictions, too, columns x, y, z must be present and of type integer, character, numeric respectively. For this scenario one is better off implementing an S4 class (which provides type checking and required columns), a validity method (for enforcing the equal-length constraint), accessors, and sub-setting following the semantic that you'd like to support, e.g., just along the length of the required slots. The richest place for this in Bioconductor is the IRanges package, though it can be a bit daunting from an architecture point of view. A couple of things to point to. One is the DataFrame class, which is like a data.frame but supporting a broader (in particular S4) set of columns and allowing 'metadata' (actually, DataFrame, so recursive) on each column. It is relevant if it is important to maintain S4 classes in a data.frame-like structure. Another is the IRanges class, which in some ways fits your overall use case. It is basically a rectangular data structure, but with required 'columns' (the start and width of the range) and then arbitrary columns the user can add. It's implemented with slots for start and width, and then 'has a' slot containing a DataFrame as 'metadata columns' (the actual implementation is more complicated than this). There are start and width accessors. Sub-setting is always list-like (single-dimensional, along the ranges). Users wanting to access one of 'their' columns use $ or extract the metadata columns (via mcols()) as a DataFrame and then work on that. Maybe it's worth pointing out that the basic definitions are column-oriented, an IRanges instance contains start and width vectors; there is no 'IRange' class. The GRanges class (in the GenomicRanges package) 'has a' IRanges, but adds additional required slots ('seqnames' to reference the names of the chromosome sequences to which the ranges refer, 'strand' to indicate the strand to which the range belongs, etc.). So the pattern here avoids the 'is a' relationship that simple class extension would imply. The IRanges package is at http://bioconductor.org/packages/devel/bioc/html/IRanges.html I've described the 'devel' version of Bioconductor http://bioconductor.org/developers/useDevel/ Martin On 08/31/2012 08:39 AM, Bert Gunter wrote: To add to what David said ... Of course, there are already S3 getters and setters methods for data frames ([.data.frame and [-.data.frame )*. These could clearly be extended -- i.e. the data.frame class could be extended and appropriate S3 methods written. Whether you use S3 or S4 depends on the degree of control, type checking, reuse etc. you want/need. David's suggestion to look at Bioconductor is a good one. Cheers, Bert *If you are unfamiliar with the S3 extract methods, consult the R Language Definition Manual. On Fri, Aug 31, 2012 at 8:14 AM, David Winsemius dwinsem...@comcast.netwrote: On Aug 31, 2012, at 5:57 AM, Ramiro Barrantes wrote: Hello, I have again a good practices/programming theory question regarding data.frames. One of the fundamental objects that I use is the data frame with a particular set of columns that I would fill or get information from, and an entire system would revolve around getting information from or putting information to such data.frame. On a different OOP programming language I would be tempted to create a class that would wrap-around that data.frame and create getters and setters methods that would return whatever information I need. I started doing that using S4. Does anyone have examples of packages that use that approach or any suggestions? It just seems to me that a class/object would be a better idea because it would create a single, hopefully well validated way to access information and edit the fundamental data.frame object, which would be helpful if there are several programmers on the team and/or if some of the data.frame manipulations are not straightforward and are best left encapsulated in a method of a class, and then have
Re: [R] select specific rows from regression output
Hi I am not familiar with glmer but maybe you can try to give to prediction only values with BMI25. As you did not provide data nor any code something like (untested) predict(fit, newdata=olddata[olddata$BMI25,]) Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Alexander Snijders Sent: Monday, September 03, 2012 1:13 PM To: r-help@r-project.org Subject: [R] select specific rows from regression output Hello everyone, I have a data set that contains characteristics of 25,000 patients of 92 different hospitals. I have run a regression to capture the probability these patients will have a complication after a certain operation. Now, I actually want to predict the probability per patient, using the outcome of the regression, but I just certain patients involved in the prediction. So, I want to use the estimated parameters of the full regression, but after that, I only want patients with certain characteristics in my prediction matrix. For example, only patients with BMI 25. My regressional formula looks as follows: fit = glmer(response ~ sex+bmi+asa+ (1|center), data=data, family=binomial), and my normal prediction formula: pred=fit@X %*% fit@fixef. I hope someone can help me! Greetings, 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-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] select specific rows from regression output
Unfortunately, predict can't be applied to an object of class mer... Regards, Alex 2012/9/3 PIKAL Petr petr.pi...@precheza.cz Hi I am not familiar with glmer but maybe you can try to give to prediction only values with BMI25. As you did not provide data nor any code something like (untested) predict(fit, newdata=olddata[olddata$BMI25,]) Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Alexander Snijders Sent: Monday, September 03, 2012 1:13 PM To: r-help@r-project.org Subject: [R] select specific rows from regression output Hello everyone, I have a data set that contains characteristics of 25,000 patients of 92 different hospitals. I have run a regression to capture the probability these patients will have a complication after a certain operation. Now, I actually want to predict the probability per patient, using the outcome of the regression, but I just certain patients involved in the prediction. So, I want to use the estimated parameters of the full regression, but after that, I only want patients with certain characteristics in my prediction matrix. For example, only patients with BMI 25. My regressional formula looks as follows: fit = glmer(response ~ sex+bmi+asa+ (1|center), data=data, family=binomial), and my normal prediction formula: pred=fit@X %*% fit@fixef. I hope someone can help me! Greetings, 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. [[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] Coxph not converging with continuous variable
On 09/03/2012 05:00 AM, r-help-requ...@r-project.org wrote: The coxph function in R is not working for me when I use a continuous predictor in the model. Specifically, it fails to converge, even when bumping up the number of max iterations or setting reasonable initial values. The estimated Hazard ratio from the model is incorrect (verified by an AFT model). I've isolated it to the x1 variable in the example below, which is log-normally distributed. The x1 here has extreme values, but I've been able to reproduce the problem intermittently with less extreme values. It seemed odd that I couldn't find this question asked anywhere, so I'm wondering if I'm just not seeing a mistake I've made. Alex Keil UNC Chapel Hill Congratulations-- it's been a long time since someone managaed to break the iteration code in coxph. I used your example, but simplifed to using n=1000 and a 1 variable model. The quantiles of your x1 variable are round(quantile(xx, c(0, 5:10/10)),2) 0% 50% 60% 70% 80% 90% 100% 0.06 2.67 3.75 5.74 8.93 15.04 98.38 For a coefficient of 1 (close to the real solution) you have one subject with a risk of death that 999 times the average risk (he should die before his next heartbeat) and another with relative risk of 1.99e-40 (an immortal). The key components of a Cox model iteration are, it turns out, weighted means and variances. For this data 99.99929 % of the weight falls on a single observation, i.e., at beta=1 you have an effective sample size of 1. The optimal coefficient is the one that best predicts that single subject's death time. Due to the computational round off error that results, the routine takes a step of size 1.7 from a starting estimate of 1.0 when it should take a stop of size of about .05, then falls into step halving to overcome the mistake. Rinse and repeat. I could possibly make coxph resistant to this data set, but at the cost of a major rewrite and significantly slower performance. Can you convince me that this data set has any relevance? Terry Therneau __ 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] Fwd: I need help with package RANDFORESTGUI
I need help with package RANDFORESTGUI I do this: library(RandForestGUI) RandForestGUI() Error en RandForestGUI() : no se puede cambiar el valor de un vínculo bloqueado para 'tt' Some one can help me? Is it important this menssage? I cant get what i want! Thanks to all!! [[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] how to find the index of points selected from a scatter plot?
I would be very surprised if the x value from locator matched the x value in the data to the precision needed by ==, and what if 2 points have the same x-value but different y-values, you would need to also check the y's. With appropriate rounding this would work, but would just be reinventing the identify function (as Peter pointed out). So if you are happy to reinvent wheels for learning purposes then locator, which, and rounding (or min) could teach a lot. If the simplest most straight forward solution is sought, then use identify instead of locator. On Fri, Aug 31, 2012 at 5:03 PM, Bert Gunter gunter.ber...@gene.com wrote: ?which ## as in ix - which(x==values) -- Bert On Fri, Aug 31, 2012 at 2:09 PM, Michael comtech@gmail.com wrote: Hi all, I am using locator to select the points from a scatter plot... This is all fine. But the problem is that the locator only returns the axis values of the selected points. Instead, I would like to get the index of these select points... The axis values are real-values so it's a bit hard for me to directly reverse-engineer the index nubmers.. How to do that? Thank you! [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Scatter plot from tapply output, labels of data
Hei, i am trying to plot the means of two variables (d13C and d15N), by 2 grouping factors (Species and Year) that i obtained by the function tapply. I would like to plot with different colours according to the Year and show the Species as data labels. My data looks like this: Species d13Cd13NYear Species114,4 11.5 2009 Species2 ...... Nmean-tapply(d15N,list(Year,Species),mean) Cmean-tapply(d13C,list(Year,Species),mean) ##works fine, returns something like this Species1 Species2 Species3 2009 20.3 13.4 13,5 2011 NA 23.5 14.5 2012 11.3 NA23.4 plot(Cmean,Nmean,col=c(green,red,blue),) #works fine, gives a plot with data points coloured by Year text(Cmean,Nmean,labels=levels(Species),cex=.7,adj=c(-.1,-.6)) #does not work, mixes up the labels, have tried Species-as.factor(Species) and switched tapply(d15N,list(Year,Species),mean) to--tapply(d15N,list(Species,Year),mean) which gives the Years as column names but does not produce a better plot. The I cannot find the error, any idea what i am doing wrong Thanks sooo much -- View this message in context: http://r.789695.n4.nabble.com/Scatter-plot-from-tapply-output-labels-of-data-tp4642077.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] Time Series filter help?
I have a time series data with 1's and 0's. When the last 3 observations are 1 I want to generate a 1 until I have three 0's in a row and then I want it to produce all zeros again. For example if I have 0101010101 for the first part of the time series this would produce all zeros. Then if the data has 111 my function will return 1's until I have three 0's in a row and it would keep producing zeros until I have three 1's in a row again. I have tried many ways to do this but I have not found a way that seems simple. I know I just making this more complex then needed so any help would be great. 2012-05-07 0 2012-05-08 0 2012-05-09 0 2012-05-10 0 2012-05-11 0 2012-05-14 0 2012-05-15 0 2012-05-16 0 2012-05-17 0 2012-05-18 0 2012-05-21 0 2012-05-22 0 2012-05-23 0 2012-05-24 0 2012-05-25 0 2012-05-29 0 2012-05-30 0 2012-05-31 0 2012-06-01 0 2012-06-04 0 2012-06-05 0 2012-06-06 0 2012-06-07 1 2012-06-08 0 2012-06-11 0 2012-06-12 0 2012-06-13 0 2012-06-14 1 2012-06-15 1 2012-06-18 1 2012-06-19 1 2012-06-20 1 2012-06-21 1 2012-06-22 0 2012-06-25 0 2012-06-26 0 2012-06-27 0 2012-06-28 0 2012-06-29 0 2012-07-02 1 2012-07-03 0 2012-07-05 1 2012-07-06 1 2012-07-09 0 2012-07-10 0 2012-07-11 0 2012-07-12 0 2012-07-13 0 2012-07-16 1 2012-07-17 1 2012-07-18 0 2012-07-19 0 2012-07-20 0 2012-07-23 0 2012-07-24 0 2012-07-25 0 2012-07-26 1 2012-07-27 1 2012-07-30 1 2012-07-31 1 2012-08-01 1 2012-08-02 1 2012-08-03 0 2012-08-06 1 2012-08-07 1 2012-08-08 1 2012-08-09 1 2012-08-10 1 2012-08-13 1 2012-08-14 1 2012-08-15 1 2012-08-16 1 2012-08-17 1 2012-08-20 1 2012-08-21 1 2012-08-22 1 2012-08-23 1 2012-08-24 1 2012-08-27 1 2012-08-28 1 2012-08-29 1 [[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] R suitability for development project
Eric Langley wrote: Hello All, Eric Langley here with my first post to this list. I am looking to determine if R is suitable for a development project I am working on and if so possibly finding someone proficient in R that would be interested in doing the coding. I would like to preface my inquiry that while I am not a programmer I can communicate in a dialog my objectives. An array of rank ordered data looks like this: Item-Rank First Second Third Fourth Totals Item1 6 8 0 0 14 Item2 7 5 2 0 14 Item3 1 1 11 1 14 Item4 0 0 1 13 14 Totals 14 14 14 14 The required output of R will be two fold; 1, a numerical score for each of the Items (1-4) from highest to lowest and lowest to highest on a scale of 0-99 that is statistically accurate. For this example the scores would be Item1 highest number down to Item4 with the lowest number. In reverse Item4 would be the highest number down to Item1 the lowest number. For the Highest like this; Item1=94, Item2=88, Item3=48, Item4=2 (just guessing here on the scores...:) 2, a graphical output of the data based on the scores in three special graphs with a middle line at '0' and increasing numbers to the left AND right. The graphs plot the Highest ranked Items, the Lowest Ranked items and a combination of the two. Sample graphs are here: http://community.abeo.us/sample-graphs/ Looking forward to hearing if R will be able to accomplish this. Hi Eric, I would use mean ranks for something like this. You would have to calculate these from your summary array unless you have the raw ranks. ranksumm2meanranks-function(x,nobs) { nitems-dim(x)[1] - 1 meanrankvec-rep(0,nitems) for(rankrow in 1:nitems) { for(rankcol in 1:nitems) meanrankvec[rankrow]- meanrankvec[rankrow]+x[rankrow,rankcol]*rankcol meanrankvec[rankrow]- meanrankvec[rankrow]/x[rankrow,nitems+1] } names(meanrankvec)-rownames(x)[-1] return(meanrankvec) } ranksumm2meanranks(x) Item2Item3Item4 Totals 1.571429 1.642857 2.857143 3.928571 You can obtain the reversed ranks by subtracting the above from the maximum rank score (4), but I don't see why you would want to do this. Your explanation of the plot is not entirely clear. The ranges of the ranks for the items are: Item1 c(1,2) Item2 c(1,3) Item3 c(1,4) Item4 c(3,4) You could plot these as horizontal bars spanning the range of the ranks for each item with a vertical line across each bar showing the value of the mean rank for that item. This would illustrate both the relative position and variability of ranks, something like a boxplot. In case you have incomplete ranks, check the crank package for completion of incomplete ranks. Jim __ 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] fitting lognormal censored data
Dear Berend Thanks for your response. I will write my code and estimate the parameters using functions optim() or nlminb(). For the code that I am trying to build for estimation the parameters using mle via EM ahgorithm, I will rewrite it and reformulated my question about, but before that I need to inquire whether i can control the number of iteration ( maxit) in optim function to get the estimation at each step (maxit =1), (M step) and then use them to compute the expected values of the log likelihood function ( Estep), estimtng using MLE via EM,. Thank you very much. [[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] R suitability for development project
Rolf wrote: Is there monetary reward involved? Or are you just counting on people's good nature? I note: Absolutely, I should have noted that... Rolf wrote: This reminds me of fortune(driveway) from the fortunes package. I note: You mean this one? I think this is kind of like asking “will your Land Rover make it up my driveway?, but I’ll assume the question was asked in all seriousness. —Ista Zahn (in response to a request for replication of some data preprocessing done in SAS) R-help (April 2011) On Mon, Sep 3, 2012 at 2:08 AM, Rolf Turner rolf.tur...@xtra.co.nz wrote: On 03/09/12 14:15, Eric Langley wrote: Hello All, Eric Langley here with my first post to this list. I am looking to determine if R is suitable for a development project I am working on and if so possibly finding someone proficient in R that would be interested in doing the coding. Is there monetary reward involved? Or are you just counting on people's good nature? I would like to preface my inquiry that while I am not a programmer I can communicate in a dialog my objectives. An array of rank ordered data looks like this: Item-Rank First Second Third Fourth Totals Item1 6 8 0 0 14 Item2 7 5 2 0 14 Item3 1 1 11 1 14 Item4 0 0 1 1314 Totals14 1414 14 The required output of R will be two fold; 1, a numerical score for each of the Items (1-4) from highest to lowest and lowest to highest on a scale of 0-99 that is statistically accurate. For this example the scores would be Item1 highest number down to Item4 with the lowest number. In reverse Item4 would be the highest number down to Item1 the lowest number. For the Highest like this; Item1=94, Item2=88, Item3=48, Item4=2 (just guessing here on the scores...:) 2, a graphical output of the data based on the scores in three special graphs with a middle line at '0' and increasing numbers to the left AND right. The graphs plot the Highest ranked Items, the Lowest Ranked items and a combination of the two. Sample graphs are here: http://community.abeo.us/sample-graphs/ Looking forward to hearing if R will be able to accomplish this. This reminds me of fortune(driveway) from the fortunes package. cheers, Rolf Turner -- Eric Langley Founder e...@abeo.us 404-326-5382 __ 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] R suitability for development project
Jim wrote: I would use mean ranks for something like this. You would have to calculate these from your summary array unless you have the raw ranks. I note: Thank you for the detailed answer. I have the raw ranks. For a question they look like this; 1=Item2, 2=Item1, 3=Item3, 4=Item4 Jim wrote: ranksumm2meanranks-function(x,nobs) { nitems-dim(x)[1] - 1 meanrankvec-rep(0,nitems) for(rankrow in 1:nitems) { for(rankcol in 1:nitems) meanrankvec[rankrow]- meanrankvec[rankrow]+x[rankrow,rankcol]*rankcol meanrankvec[rankrow]- meanrankvec[rankrow]/x[rankrow,nitems+1] } names(meanrankvec)-rownames(x)[-1] return(meanrankvec) } ranksumm2meanranks(x) Item2Item3Item4 Totals 1.571429 1.642857 2.857143 3.928571 I note: Is it possible to have the output as an integer where 99 is the highest score? Jim wrote: Your explanation of the plot is not entirely clear. The ranges of the ranks for the items are: Item1 c(1,2) Item2 c(1,3) Item3 c(1,4) Item4 c(3,4) You could plot these as horizontal bars spanning the range of the ranks for each item with a vertical line across each bar showing the value of the mean rank for that item. This would illustrate both the relative position and variability of ranks, something like a boxplot. In case you have incomplete ranks, check the crank package for completion of incomplete ranks. I note: The look I am aiming to achieve (as shown here: http://community.abeo.us/sample-graphs/ ) is a relative position within the middle zero based horizontal axis. The mean is not required. Since all bars are 14 units long the upper and lower values note where the end of each bar should align, either to the right for Highest or to the left for Lowest. The third graph shows both. ~eric On Mon, Sep 3, 2012 at 7:41 AM, Jim Lemon j...@bitwrit.com.au wrote: Eric Langley wrote: An array of rank ordered data looks like this: Item-Rank First Second Third Fourth Totals Item1 6 8 0 0 14 Item2 7 5 2 0 14 Item3 1 1 11 1 14 Item4 0 0 1 13 14 Totals 14 14 14 14 The required output of R will be two fold; 1, a numerical score for each of the Items (1-4) from highest to lowest and lowest to highest on a scale of 0-99 that is statistically accurate. For this example the scores would be Item1 highest number down to Item4 with the lowest number. In reverse Item4 would be the highest number down to Item1 the lowest number. For the Highest like this; Item1=94, Item2=88, Item3=48, Item4=2 (just guessing here on the scores...:) 2, a graphical output of the data based on the scores in three special graphs with a middle line at '0' and increasing numbers to the left AND right. The graphs plot the Highest ranked Items, the Lowest Ranked items and a combination of the two. Sample graphs are here: http://community.abeo.us/sample-graphs/ Looking forward to hearing if R will be able to accomplish this. -- Eric Langley Founder e...@abeo.us 404-326-5382 __ 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] combing list objects
Hi, I am trying to combine a long list but I can't work out how to do it, for example: abun-list(rep(0,5),rep(0,7),rep(0,4),rep(0,10)) nb-c(5,5,1,8) fill.abun - function(x, y) { set - sample(1:length(x), size = y) x[set] - rlnorm(length(set)) return(x) } abun - mapply(fill.abun, abun, nb) abun ## I want all the data in one list or column which I can extract to a dataframe or matrix ## the best I have come up with is: abun2-c(abun[[1]],abun[[2]],abun[[3]],abun[[4]]) ## but I will have a lot more data and so this is not feasible Thanks, Chris -- View this message in context: http://r.789695.n4.nabble.com/combing-list-objects-tp4642071.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] boxplot - bclust
Hello everybody, I have a problem with the commando of boxplot -bclust. http://127.0.0.1:13155/library/e1071/html/boxplot.bclust.html data(iris) bc1 - bclust(iris[,1:4], 3, base.centers=5) Committee Member: 1(1) 2(1) 3(1) 4(1) 5(1) 6(1) 7(1) 8(1) 9(1) 10(1) Computing Hierarchical Clustering boxplot(bc1) Warnmeldungen: 1: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt (Condition has length 1 and only the first element is used) # It's normal? Why? 2: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt 3: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt Thank you for your help. Best regards, Dominic [[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] Horizontal grid in background of barplot
All, I have: x - matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE) rownames(x) - c(Cold or flu,Headache,Backache); colnames(x) - c(Went to doctor,No response,Did nothing,Self-medicated) x - t(x) print(x) barplot(x,beside=TRUE, ylim=c(0,90), xlab=Ailment, ylab=Percent, legend.text=TRUE, args.legend=list(topright,title=Treatment)) abline(h=c(seq(10,90,10))) box() I'd like to get the horizontal lines in the background. Any suggestions? D. -- View this message in context: http://r.789695.n4.nabble.com/Horizontal-grid-in-background-of-barplot-tp4642081.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] combing list objects
Hello, Try ?unlist. unlist(abun) Hope this helps, Rui Barradas Em 03-09-2012 17:06, chris20 escreveu: Hi, I am trying to combine a long list but I can't work out how to do it, for example: abun-list(rep(0,5),rep(0,7),rep(0,4),rep(0,10)) nb-c(5,5,1,8) fill.abun - function(x, y) { set - sample(1:length(x), size = y) x[set] - rlnorm(length(set)) return(x) } abun - mapply(fill.abun, abun, nb) abun ## I want all the data in one list or column which I can extract to a dataframe or matrix ## the best I have come up with is: abun2-c(abun[[1]],abun[[2]],abun[[3]],abun[[4]]) ## but I will have a lot more data and so this is not feasible Thanks, Chris -- View this message in context: http://r.789695.n4.nabble.com/combing-list-objects-tp4642071.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] Horizontal grid in background of barplot
On 2012-09-03 12:12, David Arnold wrote: All, I have: x - matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE) rownames(x) - c(Cold or flu,Headache,Backache); colnames(x) - c(Went to doctor,No response,Did nothing,Self-medicated) x - t(x) print(x) barplot(x,beside=TRUE, ylim=c(0,90), xlab=Ailment, ylab=Percent, legend.text=TRUE, args.legend=list(topright,title=Treatment)) abline(h=c(seq(10,90,10))) box() I'd like to get the horizontal lines in the background. Any suggestions? Just plot the bars twice and add the background colour of the legend region. barplot(x,beside=TRUE, ylim=c(0,90)) abline(h=c(seq(10,90,10))) box() barplot(x,beside=TRUE, xlab=Ailment, ylab=Percent, legend.text=TRUE, args.legend=list(topright,title=Treatment,bg=white), add=TRUE) Peter Ehlers __ 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] [newbie] scripting remote check for R package
https://stat.ethz.ch/pipermail/r-help/2012-September/322985.html e.g., how to replace 'query R for package=package_name' in the following: for RSERVER in 'foo' 'bar' 'baz' ; do ssh ${RSERVER} 'query R for package=package_name' done or is there a better way to script checking for an R package? https://stat.ethz.ch/pipermail/r-help/2012-September/323000.html I would call something like this via ssh [...] Rscript -e 'as.numeric(suppressWarnings(suppressPackageStartupMessages(require(ggplot2' Thanks! but ... While that works great on _my_ linux boxes (on which I installed R), on the cluster where I need to run this (where I do *not* have root) me@foo:~ $ which Rscript /usr/bin/which: no Rscript in (/home/me/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin) me@foo:~ $ find /share -name 'Rscript' | wc -l 0 me@foo:~ $ which R alias R='/share/linux86_64/bin/R' /share/linux86_64/bin/R So I'm wondering: 1 Is there a way to do `Rscript -e` with plain, commandline R? 2 What should my admin have done to install both Rscript and R? (Alternatively, what should I tell my admin to do in order to make both Rscript and R available?) 3 Is there any reason to install R without Rscript? (Alternatively, when I ask my admin to install Rscript, is there any objection I should anticipate?) thanks again, Tom Roche tom_ro...@pobox.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] boxplot - bclust
On 2012-09-03 08:34, Dominic Roye wrote: Hello everybody, I have a problem with the commando of boxplot -bclust. http://127.0.0.1:13155/library/e1071/html/boxplot.bclust.html data(iris) bc1 - bclust(iris[,1:4], 3, base.centers=5) Committee Member: 1(1) 2(1) 3(1) 4(1) 5(1) 6(1) 7(1) 8(1) 9(1) 10(1) Computing Hierarchical Clustering boxplot(bc1) Warnmeldungen: 1: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt (Condition has length 1 and only the first element is used) # It's normal? Why? 2: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt 3: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt These are warnings and I think that you can safely ignore them. It looks like the code should replace the line if (x$datamean) with something like if (!is.null(x$datamean)) Peter Ehlers Thank you for your help. Best regards, Dominic [[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] Time Series filter help?
Hello, Try the following, where 'dat' is your data.frame. dat - read.table(text= 2012-05-07 0 2012-05-08 0 2012-05-09 0 [...etc...] 2012-08-27 1 2012-08-28 1 2012-08-29 1 , stringsAsFactors = FALSE) r - rle(dat[[2]]) csum - cumsum(r$lengths 3) spl - sapply(split(r$values, csum), `[`, 1) dat$New - rep(spl, tapply(r$lengths, csum, sum)) Hope this helps, Rui Barradas Em 03-09-2012 19:46, Douglas Karabasz escreveu: I have a time series data with 1's and 0's. When the last 3 observations are 1 I want to generate a 1 until I have three 0's in a row and then I want it to produce all zeros again. For example if I have 0101010101 for the first part of the time series this would produce all zeros. Then if the data has 111 my function will return 1's until I have three 0's in a row and it would keep producing zeros until I have three 1's in a row again. I have tried many ways to do this but I have not found a way that seems simple. I know I just making this more complex then needed so any help would be great. 2012-05-07 0 2012-05-08 0 2012-05-09 0 2012-05-10 0 2012-05-11 0 2012-05-14 0 2012-05-15 0 2012-05-16 0 2012-05-17 0 2012-05-18 0 2012-05-21 0 2012-05-22 0 2012-05-23 0 2012-05-24 0 2012-05-25 0 2012-05-29 0 2012-05-30 0 2012-05-31 0 2012-06-01 0 2012-06-04 0 2012-06-05 0 2012-06-06 0 2012-06-07 1 2012-06-08 0 2012-06-11 0 2012-06-12 0 2012-06-13 0 2012-06-14 1 2012-06-15 1 2012-06-18 1 2012-06-19 1 2012-06-20 1 2012-06-21 1 2012-06-22 0 2012-06-25 0 2012-06-26 0 2012-06-27 0 2012-06-28 0 2012-06-29 0 2012-07-02 1 2012-07-03 0 2012-07-05 1 2012-07-06 1 2012-07-09 0 2012-07-10 0 2012-07-11 0 2012-07-12 0 2012-07-13 0 2012-07-16 1 2012-07-17 1 2012-07-18 0 2012-07-19 0 2012-07-20 0 2012-07-23 0 2012-07-24 0 2012-07-25 0 2012-07-26 1 2012-07-27 1 2012-07-30 1 2012-07-31 1 2012-08-01 1 2012-08-02 1 2012-08-03 0 2012-08-06 1 2012-08-07 1 2012-08-08 1 2012-08-09 1 2012-08-10 1 2012-08-13 1 2012-08-14 1 2012-08-15 1 2012-08-16 1 2012-08-17 1 2012-08-20 1 2012-08-21 1 2012-08-22 1 2012-08-23 1 2012-08-24 1 2012-08-27 1 2012-08-28 1 2012-08-29 1 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to find the index of points selected from a scatter plot?
All good points. -- Bert On Mon, Sep 3, 2012 at 12:07 PM, Greg Snow 538...@gmail.com wrote: I would be very surprised if the x value from locator matched the x value in the data to the precision needed by ==, and what if 2 points have the same x-value but different y-values, you would need to also check the y's. With appropriate rounding this would work, but would just be reinventing the identify function (as Peter pointed out). So if you are happy to reinvent wheels for learning purposes then locator, which, and rounding (or min) could teach a lot. If the simplest most straight forward solution is sought, then use identify instead of locator. On Fri, Aug 31, 2012 at 5:03 PM, Bert Gunter gunter.ber...@gene.com wrote: ?which ## as in ix - which(x==values) -- Bert On Fri, Aug 31, 2012 at 2:09 PM, Michael comtech@gmail.com wrote: Hi all, I am using locator to select the points from a scatter plot... This is all fine. But the problem is that the locator only returns the axis values of the selected points. Instead, I would like to get the index of these select points... The axis values are real-values so it's a bit hard for me to directly reverse-engineer the index nubmers.. How to do that? Thank you! [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Common elements in columns
Another way of solving the problem: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) x - list(df1$C1, df2$C1, df3$C1, df4$C1) Reduce(intersect, x) [1] G E H J On Mon, Sep 3, 2012 at 7:01 AM, Silvano Cesar da Costa silv...@uel.br wrote: Hi Arun, it's exactly what I wanted. Thanks a lot, Hi, May be this might help: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) df1$C1[df1$C1%in%df2$C1[df2$C1%in%df3$C1[df3$C1%in%df4$C1]]] #[1] G E H J A.K. - Original Message - From: Silvano Cesar da Costa silv...@uel.br To: r-help@r-project.org Cc: Sent: Sunday, September 2, 2012 7:05 PM Subject: [R] Common elements in columns Hi, I have 4 files with 1 individuals in each file and 10 columns each. One of the columns, say C1, may have elements in common with the other columns C1 of other files. If I have only 2 files, I can do this check with the command: data1[data1 %in% data2] data2[data2 %in% data1] How do I check which common elements in the columns of C1 4 files? Thanks, - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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. - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ 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 points to a point pattern
Hello all: Is there any way to add points to a point pattern, while keeping a given minimum distance amongst this new points and the pre-existing points? Thanks, Frederico [[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] adding points to a point pattern
Perhaps. What does this have to do with R? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Frederico Mestre mestre.freder...@gmail.com wrote: Hello all: Is there any way to add points to a point pattern, while keeping a given minimum distance amongst this new points and the pre-existing points? Thanks, Frederico [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RES: adding points to a point pattern
Hello, I'm trying to make a function in R in which I need to do this. Frederico -Mensagem original- De: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Enviada em: terça-feira, 4 de Setembro de 2012 01:30 Para: Frederico Mestre; r-help@r-project.org Assunto: Re: [R] adding points to a point pattern Perhaps. What does this have to do with R? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Frederico Mestre mestre.freder...@gmail.com wrote: Hello all: Is there any way to add points to a point pattern, while keeping a given minimum distance amongst this new points and the pre-existing points? Thanks, Frederico [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RES: adding points to a point pattern
Hello, Yes, I'm using spatstat. Sorry, I forgot to mention that. Thanks, Frederico -Mensagem original- De: Rolf Turner [mailto:rolf.tur...@xtra.co.nz] Enviada em: terça-feira, 4 de Setembro de 2012 02:04 Para: Frederico Mestre Cc: r-help@r-project.org; adrian.badde...@csiro.au Assunto: Re: [R] adding points to a point pattern On 04/09/12 11:58, Frederico Mestre wrote: Hello all: Is there any way to add points to a point pattern, while keeping a given minimum distance amongst this new points and the pre-existing points? Presumably this is a question about the spatstat package. If so, the answer is yes. At least two ways: (1) Using rmh() --- need to specify beta (the chemical activity parameter). E.g. # Generate a test pattern to which to add points. set.seed(42) X - rSSI(0.05,100) # Add points. M - rmhmodel(cif=hardcore,par=list(beta=300,hc=0.05)) Y - rmh(M,start=list(x.start=X),expand=1,control=list(x.cond=as.data.frame(X))) plot(Y,main=Pattern with points added via rmh) plot(X,add=TRUE,chars=20,cols=red) print(min(nndist(Y))) (2) Using rSSI() --- need to specify the *total number* of points desired. E.g. # Add points to the same test pattern, in a different way. Z - rSSI(0.05,npoints(X)+42,x.init=X) plot(Z,main=Pattern with points added via rSSI) plot(X,add=TRUE,chars=20,cols=red) print(min(nndist(Z))) HTH 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] [newbie] scripting remote check for R package
https://stat.ethz.ch/pipermail/r-help/2012-September/322985.html for RSERVER in 'foo' 'bar' 'baz' ; do ssh ${RSERVER} 'query R for package=package_name' done or is there a better way to script checking for an R package? https://stat.ethz.ch/pipermail/r-help/2012-September/323000.html I would call something like this via ssh [...] Rscript -e 'as.numeric(suppressWarnings(suppressPackageStartupMessages(require(ggplot2' https://stat.ethz.ch/pipermail/r-help/2012-September/323024.html Thanks! but [the] cluster where I need to run this (where I do *not* have root) [lacks Rscript.] So I'm wondering: 1 Is there a way to do `Rscript -e` with plain, commandline R? I learned how to use `R CMD BATCH`. It's definitely more painful than `Rscript -e`, but at least the following works: EXEC_DIR='/share/linux86_64/bin' # on foo, at least # EXEC_NAME='Rscript' EXEC_NAME='R' EXEC_PATH=${EXEC_DIR}/${EXEC_NAME} BATCH_INPUT_PATH=./junk.r # presumably in home dir BATCH_OUTPUT_PATH=./junk.r.out # ditto for RSERVER in 'foo' 'bar' 'baz' ; do echo -e ${RSERVER}: # The following 3 commands attempted to debug a # separate but related problem; about which, see # http://serverfault.com/questions/424027/ssh-foo-command-not-loading-remote-aliases # ssh ${RSERVER} ${EXEC_NAME} --version | head -n 1 # ssh ${RSERVER} grep -nHe 'bashrc' ~/.bash_profile # ssh ${RSERVER} grep -nHe '\W${EXEC_NAME}\W' ~/.bashrc ssh ${RSERVER} ${EXEC_PATH} --version | head -n 1 ssh ${RSERVER} echo -e 'as.numeric(suppressWarnings(suppressPackageStartupMessages(require(M3\n' ${BATCH_INPUT_PATH} ssh ${RSERVER} rm ${BATCH_OUTPUT_PATH} ssh ${RSERVER} ls -al ${BATCH_INPUT_PATH} ssh ${RSERVER} cat ${BATCH_INPUT_PATH} ssh ${RSERVER} ${EXEC_PATH} CMD BATCH --slave --no-timing ${BATCH_INPUT_PATH} ${BATCH_OUTPUT_PATH} ssh ${RSERVER} ls -al ${BATCH_OUTPUT_PATH} ssh ${RSERVER} head -n 1 ${BATCH_OUTPUT_PATH} echo # newline done Given the pain, I'd still like to know: 2 What should my admin have done to install both Rscript and R? (Alternatively, what should I tell my admin to do in order to make both Rscript and R available?) 3 Is there any reason to install R without Rscript? (Alternatively, when I ask my admin to install Rscript, is there any objection I should anticipate?) your assistance is appreciated, Tom Roche tom_ro...@pobox.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] Skew Normal CDF using psn (package sn)
Dear R-users, I have been using the code below in order to verify how the CDF of a skew-normal distribution was calculated: library(sn) s=seq(-30,30,by=0.1) a-matrix(nrow=length(s),ncol=5) lambda=1 for(i in 1:length(s)){ a[i,1]=pnorm(s[i],mean=0,sd=1); a[i,2]=T.Owen(s[i],lambda); a[i,3]=a[i,5]-2*a[i,6]; a[i,4]=pnorm(s[i])-2*T.Owen(s[i],lambda); a[i,5]=psn(s[i],shape=lambda); } From the literature I was expecting the column 3, 4 and 5 to give me the exact same results but it actually doesn't. There seem to be some approximations for small values of x. Does anyone know where does this come from? Any help would be greatly appreciated, Cheers, Boris [[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] RES: adding points to a point pattern
Then why don't you follow the posting guide and provide an R sample data set and R sample result? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Frederico Mestre mestre.freder...@gmail.com wrote: Hello, I'm trying to make a function in R in which I need to do this. Frederico -Mensagem original- De: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Enviada em: terça-feira, 4 de Setembro de 2012 01:30 Para: Frederico Mestre; r-help@r-project.org Assunto: Re: [R] adding points to a point pattern Perhaps. What does this have to do with R? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Frederico Mestre mestre.freder...@gmail.com wrote: Hello all: Is there any way to add points to a point pattern, while keeping a given minimum distance amongst this new points and the pre-existing points? Thanks, Frederico [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Adding summary title to table
All, I have: x - matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE) rownames(x) - c(Cold or flu,Headache,Backache); colnames(x) - c(Went to doctor,No response,Did nothing,Self-medicated) x - t(x) print(x) 1. I'd like to add the title Nutritional Status above the column names when displayed with print(x). 2. I'd like to add the title Academic Performance to the left of the row names when displayed with print(x). Any thoughts? David. -- View this message in context: http://r.789695.n4.nabble.com/Adding-summary-title-to-table-tp4642094.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] Common elements in columns
Hi Jim. It was a very elegant way of solving the problem. Thank you, Another way of solving the problem: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) x - list(df1$C1, df2$C1, df3$C1, df4$C1) Reduce(intersect, x) [1] G E H J On Mon, Sep 3, 2012 at 7:01 AM, Silvano Cesar da Costa silv...@uel.br wrote: Hi Arun, it's exactly what I wanted. Thanks a lot, Hi, May be this might help: set.seed(1) df1-data.frame(C1=sample(LETTERS[1:25],20,replace=FALSE),value=sample(50,20,replace=FALSE)) set.seed(15) df2-data.frame(C1=sample(LETTERS[1:25],15,replace=FALSE),C2=1:15) set.seed(3) df3-data.frame(C1=sample(LETTERS[1:10],10,replace=FALSE),B1=rnorm(10,3)) set.seed(5) df4-data.frame(C1=sample(LETTERS[1:15],10,replace=FALSE),A2=rnorm(10,15)) df1$C1[df1$C1%in%df2$C1[df2$C1%in%df3$C1[df3$C1%in%df4$C1]]] #[1] G E H J A.K. - Original Message - From: Silvano Cesar da Costa silv...@uel.br To: r-help@r-project.org Cc: Sent: Sunday, September 2, 2012 7:05 PM Subject: [R] Common elements in columns Hi, I have 4 files with 1 individuals in each file and 10 columns each. One of the columns, say C1, may have elements in common with the other columns C1 of other files. If I have only 2 files, I can do this check with the command: data1[data1 %in% data2] data2[data2 %in% data1] How do I check which common elements in the columns of C1 4 files? Thanks, - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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. - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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] RES: adding points to a point pattern
I had no trouble in figuring out what he wanted. cheers, Rolf Turner On 04/09/12 14:26, Jeff Newmiller wrote: Then why don't you follow the posting guide and provide an R sample data set and R sample result? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Frederico Mestre mestre.freder...@gmail.com wrote: Hello, I'm trying to make a function in R in which I need to do this. Frederico -Mensagem original- De: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Enviada em: terça-feira, 4 de Setembro de 2012 01:30 Para: Frederico Mestre; r-help@r-project.org Assunto: Re: [R] adding points to a point pattern Perhaps. What does this have to do with R? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Frederico Mestre mestre.freder...@gmail.com wrote: Hello all: Is there any way to add points to a point pattern, while keeping a given minimum distance amongst this new points and the pre-existing points? Thanks, Frederico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding points to a point pattern
On 04/09/12 11:58, Frederico Mestre wrote: Hello all: Is there any way to add points to a point pattern, while keeping a given minimum distance amongst this new points and the pre-existing points? Presumably this is a question about the spatstat package. If so, the answer is yes. At least two ways: (1) Using rmh() --- need to specify beta (the chemical activity parameter). E.g. # Generate a test pattern to which to add points. set.seed(42) X - rSSI(0.05,100) # Add points. M - rmhmodel(cif=hardcore,par=list(beta=300,hc=0.05)) Y - rmh(M,start=list(x.start=X),expand=1,control=list(x.cond=as.data.frame(X))) plot(Y,main=Pattern with points added via rmh) plot(X,add=TRUE,chars=20,cols=red) print(min(nndist(Y))) (2) Using rSSI() --- need to specify the *total number* of points desired. E.g. # Add points to the same test pattern, in a different way. Z - rSSI(0.05,npoints(X)+42,x.init=X) plot(Z,main=Pattern with points added via rSSI) plot(X,add=TRUE,chars=20,cols=red) print(min(nndist(Z))) HTH 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.
[R] Producing a SMA signal when closing price is above the moving average for 3 days
I have loaded price data for GE and then calculated a 50 day simple moving average. Then I have a created a ifelse statement that produce a 1 when GE's closing price is above the simple moving average and a 0 when GE Closing price is below the 50 day simple moving average. However, what I really want to do is to produce a 1 for when the price is above the simple moving average for 3 days and I want it to keep the 1 until the price moves back below the 50 day simple moving average for 3 days then I want to return a 0 until the Price closes above the SMA for 3 days. Thank you, Douglas library(quantmod) getSymbols(GE) # Get Price Data GEsma - SMA(GE$GE.Close, n=50) # Simple Moving Average of the closing price GEsma[is.na(GEsma)] - 50 # Make NA's to 50 so ifelse statement works correctly aboveSMA - ifelse(GE$GE.Close GEsma, 1, 0) # 1 when price is above 50 day moving average # 0 When below moving average chartSeries(GE) # Shows Price chart addSMA(n=50) # adds 50 day moving average to chart __ 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.