Re: [R] GSEA package error
Hello, For clarification, is it 'GSEA' or 'GSCA' package? And from where did you get it? Regards, Pascal Le 29/11/2012 07:59, Seb a écrit : Dear R gurus I’m trying to use the GSCA package to a series of microarray data (prostate cancer normal vs tumor (29 vs 29 paired)) but I’m running into some problems. I have a matrix (named /data_final/) with 11k rows(genes) and 60 cols (58 samples (29N vs 29T), GO IDs, KEGG IDs). I also have a separate vector GS with the GO IDs mapped to genes (no duplicate genes but multiple IDs per gene like in col 59) However when I try to run: /singleDC(data_final, group=c(1:29,30,58), GSdefList = GS, nperm = 3, permDI=TRUE)/ I get an error/ “unused argument(s) (permDI=TRUE)”/ When I run it without that argument it runs indefinitely even if I use only 100 rows data_final[1:100,]. Furthermore when I block the computation I get the error: /Error in `[.data.frame`(fixed.gs.data, , (csum.group[i-1] + 1):csum.group[i]) : Undefined colums selected/ If you could give me some ideas on how to have it working that would be extremely useful! Seb -- View this message in context: http://r.789695.n4.nabble.com/GSEA-package-error-tp4651223.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] in Rd documentation, line breaks in code blocks?
Have it for now ... \preformatted{ .. } does the job. On Wed, Nov 28, 2012 at 9:21 PM, Ulrich Staudinger ustaudin...@gmail.com wrote: Hi everyone, following the gentle advice from this list, I write a package description Rd file. I have a section in there. In this section, I have a subsection. In this subsection, I want to have a code fragment. This code fragment should include several commands, spanning several lines. Example: == \name{aqr-package} \alias{aqr-package} \alias{aqr} \docType{package} \title{Package level introduction} \description{description goes here.} \section{sec1}{ some text. \subsection{subsec1}{ some text. \code{ require(aqr) require(quantmod) # fetch them via quantmod getSymbols(c(MSFT, SAP)) ... } } } == The problem is, everything in \code{} gets printed into one line. If I add \cr at the end of every line in \code, it gets broken properly, but a warning says Tag \cr is invalid in a \code block What's the right way to include code (same problem with verbatim) in a subsection? Thanks Ulrich -- Ulrich Staudinger http://www.activequant.org Connect online: https://www.xing.com/profile/Ulrich_Staudinger -- Ulrich Staudinger http://www.activequant.org Connect online: https://www.xing.com/profile/Ulrich_Staudinger __ 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] Can you turn a string into a (working) symbol?
On Wed, Nov 28, 2012 at 3:06 AM, andrewH ahoer...@rprogress.org wrote: Dear Michael – This is _very_ interesting and I want to play around with the functions you suggest. I had no idea it was so easy to define assignment operators. However, one question: even after reading the “get” documentation and doing a bunch of mousing around for the expressions “pos” and “the search path”, I am not sure what function the numeral 1 in these expression serves. Why do I want to look in the global environment rather than the current environment? I also can not find anything that explains what the default “pos = -1” does. Thanks for responding! andrewH Hi Andrew, Including context for those of us who don't read via Nabble is always much appreciated. I don't have time today to hit this with a hammer till it works, but IIRC pos = -1 means current evaluation frame. See, e.g., http://stackoverflow.com/questions/12492226/r-environments-and-function-call-stacks http://stackoverflow.com/questions/7903414/how-are-environments-enclosures-and-frames-related http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/ for some hints on getting all that jazz to work right. MW __ 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] Windows 8 stability
On 12-11-28 5:00 PM, Nelson Chen wrote: My version of R (2.15.2), 64 bit version, has been crashing sporadically running under newly upgraded Windows 8. I suspect it may be some sort of memory allocation issue. Does anyone know of ways one can diagnose and fix this problem? Thanks. How to diagnose: Make the crash repeatable, then simplify it to the smallest possible example. Depending on the type of crash, it might help to run R within gdb; it can report on the location of some kinds of crash. How to fix depends on where the bug is. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fwd: Re: choose folder interactively
Thanks Philippe for your answer! It doesn't work for me, but I guess I have something wrong with Tcl/Tk. Ivan -- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282 Biogéosciences 6 Boulevard Gabriel 21000 Dijon, FRANCE +33(0)3.80.39.63.06 ivan.calan...@u-bourgogne.fr http://biogeosciences.u-bourgogne.fr/calandra Message original Sujet: Re: [R] choose folder interactively Date : Thu, 29 Nov 2012 09:49:44 +0100 De :Philippe Grosjean philippe.grosj...@umons.ac.be Répondre à :philippe.grosj...@umons.ac.be Organisation : UMONS - EcoNum Pour : ivan.calan...@u-bourgogne.fr Dear Ivan, I cannot post to R-help currently. This is something interesting for you. Could you echo to R-Help and R-SIG-Mac too, please? You will find a native Mac OS X directory selection dialog box in svDialogs. Install the package (you also need to install svGUI) and see ?dlgDir. It works both in R.app and in R run in the terminal. There is just a little time lag when you call of of svDialogs's dialog boxes the first time. It works the same on Windows and even on Linux/Unix, providing you have installed zenity there (search Goggle, installed bty default on Ubuntu, for instance). In case the required GUI elements are not found on a particular system, the function falls back automatically on a textual version at the terminal. So, it should work everytime! Don't forget to extract the result from the 'res' element... Something like: mydir - dlgDir()$res Best, Philippe Grosjean ..¡})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 28/11/12 13:39, Ivan Calandra wrote: Dear users, I am looking for a function to choose a folder interactively, just like file.choose() but for a folder. I have found tcltk::tk_choose.dir() but R hangs when I try to do anything and I have to force exit. I've tried to reinstall tcltk with install.packages(), but package ‘tcltk’ is not available (for R version 2.15.2) even though it's already installed on my computer (it comes with 'base', doesn't it?). From a Google Search, I have also found choose.dir(), but it looks like this function doesn't exist anymore since ages. Any idea? Thanks in advance, Ivan sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-apple-darwin9.8.0/i386 (32-bit) locale: [1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base __ 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] [R-pkgs] New package gdimap
Dear list, A new package gdimap titled Generalized Diffusion Magnetic Resonance Imaging is now available on CRAN. Best wishes, Adelino [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] Plot with residuals in mgcv
Hi Silje, Thanks for this. I guess RUTE is a numeric variable in this model and hence only has one associated random coefficient? This then causes a problem when calling predict.gam as part of processing 'residuals=T'. I've fixed the problem for the next release, but did you really want a single random slope for RUTE, or should it really have been declared as a factor variable? btw gamma doesn't do anything with ML and REML smoothness selection (it's only used in prediction error criteria smoothness selection to increase the penalization per effective degrees of freedom). best, Simon On 28/11/12 13:02, silje skår wrote: Hi, I am using the mgcv package (version 1.7-22.) running the model works fine, but when I want to have a plot with residuals I get an error. fit29-gam(IV~s(G3)+s(V3)+factor(AAR)+s(D3)+s(RUTE,bs=re),data=subsf,gamma=1.4,method=ML) plot(fit29,residuals=T) Error in X[, first:last] %*% object$coefficients[first:last] : non-conformable arguments does some one know what this error means? the subsf matrix is 35x27. Silje [[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] Problem with Stationary Bootstrap
Hello, You should post to the list, not just send your questions to me. If you Cc the list the odds of getting more and better answers are bigger. As for your question, 1. You forgot a variable X1, like this your code doesn't run. In what follows I assume it's also a runif(40, 0, 20). 2. Some simplifications in your code could be made. I've left the original instructions, commented out, and the corrections below them. 3. When you say that the bias and the se's are very small what do you mean exactly? What kind of values are you expecting and what are the results you're getting? fun - function(A) { model - lm(Y ~ X1 + X2, data = A) e - resid(model) mylag - function(e, d = 1) { n - length(e) c(rep(NA, d), e)[1:n] } n - length(e) e1 - mylag(e) modele - lm(e ~ e1 - 1) rho - coef(modele) reps - 20 for (i in 1:reps) { n - length(e) x1star - c(X1[1] * (1 - rho), X1[2:n] - rho * X1[1:(n - 1)]) x2star - c(X2[1] * (1 - rho), X2[2:n] - rho * X2[1:(n - 1)]) ystar - c(Y[1] * (1 - rho), Y[2:n] - rho * Y[1:(n - 1)]) #cr - (1 - rho) #cr[1:n] - cr cr - rep(1- rho, n) #W - 1 #W[1:n] - W W - rep(1, n) W[1] = (1 - rho^2)/((1 - rho)^2) #W - c(W[1], W[2:n]) Model - lm(ystar ~ cr + x1star + x2star - 1, weights = W) bstar - coef(Model) #B0 - (bstar[[1]][[1]]) #B1 - bstar[[2]][[1]] #B2 - bstar[[3]][[1]] #Yhat - B0 + B1 * X1 + B2 * X2 #u - Y - Yhat u - resid(Model) myu - function(u, d = 1) { n - length(u) c(rep(NA, d), u)[1:n] } u1 - myu(u) modelu - lm(u ~ u1 - 1) Rho - coef(modelu) if (abs(Rho) 1) break diff - abs(Rho - rho) if (diff 1e-05) break else rho - Rho } return(coef(Model)) } l - runif(40, 0, 20) X1 - X2 - runif(40, 0, 20) U - rnorm(1, 0, 2) for (k in 2:40) { U[k] = 0.9 * U[k - 1] + rnorm(1, 0, 1) } Y - l + 2 * X1 + 5 * X2 + U A - data.frame(X1 = X1, X2 = X2, Y = Y) result - boot::tsboot(A, statistic = fun, R = 1000, l = nrow(A), sim = geom, orig.t = TRUE) result Call: boot::tsboot(tseries = A, statistic = fun, R = 1000, l = nrow(A), sim = geom, orig.t = TRUE) Bootstrap Statistics : original biasstd. error t1* 12.563106 0.12260192 0.34212328 t2* 6.980546 -0.01316851 0.03659207 WARNING: All values of t3* are NA Are these results ok? Rui Barradas Em 29-11-2012 04:34, Hock Ann Lim escreveu: Dear Dr. Rui Barradas, I have this following R programming code to stationary bootstrap the Cochrane-Orcutt Prais Winsten iterative method to obtain the parameter estimates. I think there must be some problems in my programming as the bias and the std. error shown in the output are very small. Due to my little knowledge in R, I'm not able to rectify the problems. Hope you can help to point out the mistakes for me. X1-runif(40,0,20) X2-runif(40,0,20) U-rnorm(1,0,2) for (k in 2:40){ U[k]=0.9*U[k-1]+rnorm(1,0,1)} Y-1+2*X1+5*X2+U A - data.frame(X1 = X1,X2=X2, Y = Y) fun - function(A){ model-lm(Y~X1+X2,data=A) e-resid(model) mylag-function(e,d=1) { n-length(e) c(rep(NA,d),e)[1:n] } n-length(e) e1-mylag(e) modele-lm(e~e1-1) rho-coef(modele) reps-20 for(i in 1:reps){ n-length(e) x1star-c(X1[1]*(1-rho),X1[2:n]-rho*X1[1:(n-1)]) x2star-c(X2[1]*(1-rho),X2[2:n]-rho*X2[1:(n-1)]) ystar-c(Y[1]*(1-rho),Y[2:n]-rho*Y[1:(n-1)]) cr-(1-rho) cr[1:n]-cr W-1 W[1:n]-W W[1]=(1-rho^2)/((1-rho)^2) W-c(W[1],W[2:n]) Model-lm(ystar~cr+x1star+x2star-1,weights=W) bstar-coef(Model) B0-(bstar[[1]][[1]]) B1-bstar[[2]][[1]] B2-bstar[[3]][[1]] Yhat-B0+B1*X1+B2*X2 u-Y-Yhat myu-function(u,d=1) { n-length(u) c(rep(NA,d),u)[1:n] } u1-myu(u) modelu-lm(u~u1-1) Rho-coef(modelu) if(abs(Rho)1) break diff-abs(Rho-rho) if(diff0.1) break else rho-Rho } return(coef(Model)) } result - boot::tsboot(A, statistic=fun, R = 1000, l=nrow(a),sim = geom, orig.t = TRUE) result Thank you. Regards, Lim Hock Ann From: Rui Barradas ruipbarra...@sapo.pt To: Hock Ann Lim lim...@yahoo.com Cc: R-Help r-help@r-project.org Sent: Tuesday, September 18, 2012 12:03 AM Subject: Re: [R] Problem with Stationary Bootstrap Hello, The problem is your function calling itself until there's no more stack memory left. Besides, your function doesn't make any sense. You pass an argument 'fit' then do not used it but change it's value then return itself. Corrected: set.seed(1) X - runif(10, 0, 10) Y - 2 + 3*X a - data.frame(X = X, Y = Y) fun - function(a){ fit - lm(Y ~ X, data=a) return(coef(fit)) } result - boot::tsboot(a, statistic = fun, R = 10, sim = geom, l = 10, orig.t = TRUE) Hope this helps, Rui Barradas Em 17-09-2012 14:42, Hock Ann Lim escreveu: Dear R experts, I'm running the following stationary
Re: [R] error, R commends cannot show the expected output
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example John Kane Kingston ON Canada -Original Message- From: dtustud...@hotmail.com Sent: Wed, 28 Nov 2012 18:38:46 -0700 To: michael.weyla...@gmail.com Subject: Re: [R] error, R commends cannot show the expected output Hi, The problem comes up again. This time, sink() does not work. Any help will be appreciated. Thanks CC: r-help@r-project.org From: michael.weyla...@gmail.com Subject: Re: [R] error, R commends cannot show the expected output Date: Wed, 28 Nov 2012 08:09:38 + To: dtustud...@hotmail.com On Nov 28, 2012, at 4:13 AM, Jack Bryan dtustud...@hotmail.com wrote: Thanks ! I solved it. Don't you mean David did? I run sink() to get the output on command line. No, not really -- you run sink to 'turn off' an earlier call to sink which, in the interactive REPL, returns you to the command line, but could conceivably do something else in differing circumstances. MW Date: Wed, 28 Nov 2012 12:35:39 +0900 From: kri...@ymail.com To: dtustud...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] error, R commends cannot show the expected output Hello, And what do you get? Regards, Pascal Le 28/11/2012 12:25, Jack Bryan a icrit : Hi, I am working on R 2.15.2 on Win. 7. I am trying to run some simple commends. class(SWX.RET) # SWX.RET is a data file that has been loaded. But, I cannot see the expected output. I have deselected buffered output. Still it does not work. Any help will be appreciated. Thanks [[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. [[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. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails __ 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] Order function
This is not a homework help list and it is even less a homework help list when there is no clear statement of the problem. I'd suggest reading something about how R works -there are some very good tutorials and introductions listed on the R site, and then perhaps coming back here if you have a specific question. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example John Kane Kingston ON Canada -Original Message- From: linda_...@hotmail.co.uk Sent: Wed, 28 Nov 2012 08:49:42 -0800 (PST) To: r-help@r-project.org Subject: Re: [R] Order function I have one text file with all the data on there. So 20 rows of data. And 3 columns: numbers 1-20, size, time. I need to create a variable called 'order' as I need to use it for something in the next part. I am very confused as to how to do this. -- View this message in context: http://r.789695.n4.nabble.com/Order-function-tp4651022p4651166.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. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ 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] Confidence intervals for estimates of all independent variables in WLS regression
Hello, Try the following function. ci_lm - function(object, level = 0.95){ summfit - summary(object) beta - summfit$coefficients[, 1] se - summfit$coefficients[, 2] df - summfit$df[1] alpha - 1 - level lower - beta + qt(alpha/2, df = df)*se upper - beta + qt(1 - alpha/2, df = df)*se data.frame(beta, lower, upper) } Hope this helps, Rui Barradas Em 29-11-2012 00:07, Torvon escreveu: I would like to obtain Confidence Intervals for the estimates (unstandardized beta weights) of each predictor in a WLS regression: m1 = lm(x~ x1+x2+x3, weights=W, data=D) SPSS offers that output by default, and I am not able to find a way to do this in R. I read through predict.lm, but I do not find a way to get the CIs for multiple independent variables. Thank you Torvon [[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] Conditional model in R
Kirsten, The overall model is the combination of both models. If you call the parameter estimates from the logistic regression betas and the parameter estimates from the linear regression alpha, you could write the predictive equation something like this (ignoring error terms): cover = (alpha0 + alpha1*nitr + alpha2*shrub) / {1 + exp[-(beta0 + beta1*nitr + beta2*shrub)]} That's not really an R question, though, so perhaps what you really want to know is how to calculate predicted values? If so, you could do something like this. I am assuming that your data is in a data frame called df, with variables cover, nitr, and shrub. # fit a logistic regression to the presence absence data present - cover0 fitL - glm(present ~ nitr + shrub, family=binomial, data=df) # fit a regression to the abundance data, when present fitD - lm(log(cover) ~ nitr + shrub, data=df[present , ]) # calculate predicted values from the combined model pcomb - fitL$fitted * exp(predict(fitD, newdata=df)) Jean Kirsten Martin kmmar...@knights.ucf.edu wrote on 11/28/2012 01:32:43 PM: Hello all, I have a data set where the response variable is the percent cover of a specific plant (represented in cover classes 0,1,2,3,4,5, or 6). This data set has a lot of zeros (plots where the plant was not present). I am trying to model cover class of the plant as a function of both total nitrogen and shrub cover. After quite a bit of research I have come across a conditional approach to modeling data with a lot of zeros (Fletcher et al. 2005, Welsh et al. 1996). In this approach you model the presence/absence data using a logistic regression and then model the presence only data using ordinary (least squares) regression. I have successfully come up with both a logistic model and an ols model with good fits. I am running into trouble combining the two (as outlined in the third step of the Fletcher et al. 2005 paper). Does anyone have any experience or any advice on doing this? How does one come up with an overall model for the data using this approach? Thanks for your help! Kirsten [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error, R commends cannot show the expected output
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jack Bryan Sent: Thursday, November 29, 2012 2:39 AM To: michael.weyla...@gmail.com Cc: r-help@r-project.org Subject: Re: [R] error, R commends cannot show the expected output Hi, The problem comes up again. This time, sink() does not work. Well, sink does not work. And what does work? Any help will be appreciated. Maybe you forgot to switch on teleport and mind reading facilities. We can not see what you do. Regards Petr Thanks CC: r-help@r-project.org From: michael.weyla...@gmail.com Subject: Re: [R] error, R commends cannot show the expected output Date: Wed, 28 Nov 2012 08:09:38 + To: dtustud...@hotmail.com On Nov 28, 2012, at 4:13 AM, Jack Bryan dtustud...@hotmail.com wrote: Thanks ! I solved it. Don't you mean David did? I run sink() to get the output on command line. No, not really -- you run sink to 'turn off' an earlier call to sink which, in the interactive REPL, returns you to the command line, but could conceivably do something else in differing circumstances. MW Date: Wed, 28 Nov 2012 12:35:39 +0900 From: kri...@ymail.com To: dtustud...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] error, R commends cannot show the expected output Hello, And what do you get? Regards, Pascal Le 28/11/2012 12:25, Jack Bryan a écrit : Hi, I am working on R 2.15.2 on Win. 7. I am trying to run some simple commends. class(SWX.RET) # SWX.RET is a data file that has been loaded. But, I cannot see the expected output. I have deselected buffered output. Still it does not work. Any help will be appreciated. Thanks [[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. [[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] Order function
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of maths123 Sent: Wednesday, November 28, 2012 9:11 PM To: r-help@r-project.org Subject: Re: [R] Order function And yes I want the variable 1 to have the identifier 1 etc. order - 1:20 But order is also a function so you shall name it differently. Regards Petr And I need to call this variable order so I can use it to create an anova table. -- View this message in context: http://r.789695.n4.nabble.com/Order- function-tp4651022p4651198.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] Factor function for coded numerical values
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of maths123 Sent: Monday, November 26, 2012 8:25 PM To: r-help@r-project.org Subject: Re: [R] Factor function for coded numerical values The question says that there is an experiement to investigate the effect on breathing rate when doing different types of exercise with wearing more clothes or less clothes (factor A, coded 1,2). The duration of exercise was 10min, 20min, 30min (factor B, coded 1,2,3). Could you give m anymore help? I tried using your R code but I couldn't get it to run. What code? Regards Petr -- View this message in context: http://r.789695.n4.nabble.com/Factor- function-for-coded-numerical-values-tp4650483p4650883.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] some help
Hi Maybe you could use stack(dat) or melt(dat) from reshape package. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of dattel_palme Sent: Monday, November 26, 2012 12:13 PM To: r-help@r-project.org Subject: Re: [R] some help Hey again! I finally, after some work done before, had time to apply the code. The sorting of the table did not work well or maybe something was misunderstood. I have a table with 973 rows and 1329 col (ascii/text file). I want to sort the table that all columns are one under each other so that at the end I have 973*1329 rows and 1 col. The col should be sorted in a way that col 2 is under col 1, col 3 under col 2, col 4 under col 3 etc. I applied this code: dat - read.table(filename, sep=separator, header=TRUE) stacked - do.call(rbind, dat) unlist(dat) ..but putting dim(dat), the number of rows and col was still 973 and 1329. So seemingly it did not work as i wanted. Thanks very much for more help. Stefan -- View this message in context: http://r.789695.n4.nabble.com/some-help- tp4648316p4650828.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] Can R be embedded in html?
Try R package 'brew'? From its package description Description:brew implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server Pages, and Python's psp module. There is also the rApache project and many other useful links mentioned on R Web Interfaces on the R FAQ page. Jagat -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of chawla Sent: Wednesday, November 28, 2012 9:04 AM To: r-help@r-project.org Subject: [R] Can R be embedded in html? Hi I have previously used PHP script in HTML to connect website with the database and do analysis. Is it also possible to execute R scripts within HTML files? Basically I want to create an application where user can input data such as gene list and their expression values, which can be processed by R and result be displayed or made available for download. If there is some guide on how to do this please give the link. Thanks Konika __ 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] splitting a string by space except when contained within quotes
I've been trying to split a space delimited string with double-quotes in R for some time but without success. An example of a string is as follows: /rainfall snowfall Channel storage Rivulet storage/ It's important for us because these are column headings that must match the subsequent data. Here is some code I've been trying: str - 'rainfall snowfall Channel storage Rivulet storage' regex - [^\\s\']+|\([^\]*)\ split - strsplit(str, regex, perl=T) what I would like is [1] rainfall snowfall Channel storage Rivulet storage but what I get is: [1] The vector is the right length (which is encouraging) but of course the strings are empty or contain a single space. Any suggestions? Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/splitting-a-string-by-space-except-when-contained-within-quotes-tp4651286.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] RGtk2 widget font changing
I am developing A Gui using RGtk2 package. I wanted to know how the font attributes of names of widgets like menu bar, text, label etc. are changed. i mean to have menu bar item bold, italic and some specific size etc. Is there a need to create a style using PANGO library??? Krishna -- View this message in context: http://r.789695.n4.nabble.com/RGtk2-widget-font-changing-tp4651268.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] How to handle Chinese character in R plot?
Hi, I m working on R plot with Russian label but on windows (adobe) russian text are not visible. Do i need to install some package to view it. pdf(sample.pdf,width = 6.6 ,height = 4.2,family= URWHelvetica, encoding=KOI8-R) x-c(1,2,3,4,5) y-c(2,3,4,5,6) xlable-c(ручка,книга,часы,ложка,смотреть) plot(x,y,xlab=xlable) dev.off() Regards -- View this message in context: http://r.789695.n4.nabble.com/Re-How-to-handle-Chinese-character-in-R-plot-tp4651262.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] remove NA or 0 values
df - df[-which(is.na(df$Field)), ] - removing rows with NULL fields df - df[-which(df$Field == ), ] - removing rows with empty fields On Wednesday, November 28, 2012 2:23:00 PM UTC+5:30, catalin roibu wrote: Dear R users, I want to remove zero's or NA values after this model. year value1 value2 1854 0 12 1855 0 13 1866 12 16 1877 11 24 year value1 value2 1 12 12 2 11 13 3 16 4 24 Thank you! -- --- Catalin-Constantin ROIBU Forestry engineer, PhD Forestry Faculty of Suceava Str. Universitatii no. 13, Suceava, 720229, Romania office phone +4 0230 52 29 78, ext. 531 mobile phone +4 0745 53 18 01 +4 0766 71 76 58 FAX:+4 0230 52 16 64 silvic.usv.ro [[alternative HTML version deleted]] __ r-h...@r-project.org javascript: mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] deleting data of a given date range.
hey, I have a huge dataset with over 30 rows which contains data about something from 2009-2012. does anyone know how i can delete all the rows which contain data from 2009 and only have data from 2010-2012??? is there a particular function i can use on the date column so that all data from 2009 can be deleted??? -- View this message in context: http://r.789695.n4.nabble.com/deleting-data-of-a-given-date-range-tp4651272.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] Survreg Problem
Hello community, I have a problem with my survreg function in R-Statistics. My created code is the following: library(survival) surv=Surv(IPT_IN_DAYS,Status) survival.data.weibull=survreg(surv~AGE_DAYS+KM_COUNT+LL_PER_DAY+IPT_HIS+IPT_SDEV, data=spss, dist=weibull, scale=2.0) summary(survival.data.weibull) When I run that code following message shows up: In survreg.fit(X, Y, weights, offset, init = init, controlvals = control, : Ran out of iterations and did not converge What can I do to solve this problem? Thank you in advance. Regards, Stefan -- View this message in context: http://r.789695.n4.nabble.com/Survreg-Problem-tp4651271.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] worldmap_region/country problem
Dear R community, I'm trying to graphically illustrate my data with a worlmap. Unfortunately, my data is partly on country basis and partly on regional basis (e.g. certain African countries are aggregated to one region). I am using the package rwoldmap. The data on country basis can be mapped, but our defined regions cannot be identified in R. Therefore, all the countries in these regions are not plotted. Is there a way to define regions (for example 'Rest of East-Europe') and to map a combination of these defined regions and individual countries in one worldmap? Is it possible to not display borderlines between some countries but to show the borders between others? Thank you very much for your help! Anna Fechner PricewaterhouseCoopers Aktiengesellschaft Wirtschaftsprüfungsgesellschaft Vorsitzender des Aufsichtsrates WP StB Dr. Norbert Vogelpoth Vorstandsmitglieder WP StB Prof. Dr. Norbert Winkeljohann · WP StB Dr. Peter Bartels WP StB CPA Markus Burghardt · StB Prof. Dr. Dieter Endres · WP StB Prof. Dr. Georg Kämpfer WP StB Harald Kayser · WP RA StB Dr. Jan Konerding · WP StB Andreas Menke StB Marius Möller · WP StB Martin Scholich Sitz: Frankfurt am Main - Amtsgericht Frankfurt am Main HRB 44845 Mitglied von PricewaterhouseCoopers International, einer Company limited by guarantee registriert in England und Wales __ Diese Information ist ausschliesslich fuer den Adressaten bestimmt und kann vertrauliche oder gesetzlich geschuetzte Informationen enthalten. Wenn Sie nicht der bestimmungsgemaesse Adressat sind, unterrichten Sie bitte den Absender und vernichten Sie diese Mail. Anderen als dem bestimmungsgemaessen Adressaten ist es untersagt, diese E-Mail zu lesen, zu speichern, weiterzuleiten oder ihren Inhalt auf welche Weise auch immer zu verwenden. Wir verwenden aktuelle Virenschutzprogramme. Fuer Schaeden, die dem Empfaenger gleichwohl durch von uns zugesandte mit Viren befallene E-Mails entstehen, schliessen wir jede Haftung aus. * * * * * The information contained in this email is intended only...{{dropped:15}} __ 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] Label axis with strings instead of numbers
I have created a bubble plot in R using the following formula: symbols(Data$Day.Number,Data$Team,circles=Data$Total.amount, inches=0.5, fg=white,bg=red,xlab=Day Number,ylab=Team) The data set is called Data, and I have the columns Day.Number, Team and Total.amount. The data is plotting fine, but where my y axis should have the names of each team, it instead labels 1,2,3,4 How do I edit this to label the axis with the names of the teams instead? Thanks Sean -- View this message in context: http://r.789695.n4.nabble.com/Label-axis-with-strings-instead-of-numbers-tp4651275.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] libary survival
Hello,I would like to know if there is residue analysis after the Cox model and make the adjustment for my random cluster? [[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] comparing two vectors
Hello, I am performing Newton Raphson iteration where the parameter vector which I want to optimize is an *nx1* vector. I am running a while loop which will continue unless a stopping condition is satisfied Now, the stopping condition will have to be such that the parameter vector after two successive iterations are very close to each other,*component wise*. I have tried the* all* function, in which case the number of iterations are enormous. Is there any better way to do this? Thanking all in advance, Soham Chakraborty -- View this message in context: http://r.789695.n4.nabble.com/comparing-two-vectors-tp4651282.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] Error 0ps.factor: level sets of factors are different
Hi, You could do this with ?merge() or ?join() library(plyr) new-data.frame(ID=1:10,height1=NA) combo-data.frame(ID=c(3,7,9,10),height=c(185,NA,158,176)) join(new,combo,type=left)[,-2] #Joining by: ID # ID height #1 1 NA #2 2 NA #3 3 185 #4 4 NA #5 5 NA #6 6 NA #7 7 NA #8 8 NA #9 9 158 #10 10 176 A.K. - Original Message - From: lind35 li...@vcu.edu To: r-help@r-project.org Cc: Sent: Wednesday, November 28, 2012 9:42 PM Subject: [R] Error 0ps.factor: level sets of factors are different I have two data sets: new and combo. Within both data set, each row pertains to a unique individual. The combo data set is a subset of the new data set, meaning that all individuals within combo are within new but not all individuals within new are within combo. Thus, nrow(new) nrow(combo). Each data set has particular columns that represent the same sort of measure (i.e., height, individual ID). However, the new data set does not have the height values. Moreover, some of the height values within combo are blank. I want R to identify a unique individual between data sets and then put the individual's height from the combo data set into the new data set. I would like to do this in a for-loop, but I keep getting errors. ID columns are new[,17] and combo[,11] height columns are new[,14] and combo[,6] for example I try: for (i in 1:nrow(new)) { + temp - combo[which(new[i,17] == combo[,11]),6] + if(length(temp) == 0) {new[i,14] - NA + } else{new[i,14] - combo[which(new[i,17] == combo[,11]),6]} + } I can see how combo[,11] isn't the same as the new[i,17]. How do I tell R to look at the ID value for the i'th row within new, search the 11th column of combo until it finds the matching ID, then place the height from that individual from combo into the appropriate cell of new? And on top of this, do this over and over until it's transferred all of the heights from combo to the appropriate individuals in new? Thanks for the help! -- View this message in context: http://r.789695.n4.nabble.com/Error-0ps-factor-level-sets-of-factors-are-different-tp4651246.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] Conditional model in R
Jean, Thank you! That is exactly the type of information I was looking for! The script for the combined model is what I couldn't seem to come up with on my own. Thank you again for your help! Sincerely, Kirsten -- View this message in context: http://r.789695.n4.nabble.com/Conditional-model-in-R-tp4651188p4651289.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] Simper analysis with Morisita-Horn
Dear ecology fellows, I tried to implement Morisita-Horn distance (instead of Bray that is in the current version) in the code for the Simper analysis in vegan. I would be very grateful if someone can check if the code is right. function (comm, group, ...) { if (any(rowSums(comm, na.rm = TRUE) == 0)) warning(you have empty rows: results may be meaningless) permutations - 0 trace - FALSE comm - as.matrix(comm) comp - t(combn(unique(as.character(group)), 2)) outlist - NULL P - ncol(comm) nobs - nrow(comm) if (length(permutations) == 1) { perm - shuffleSet(nobs, permutations, ...) } else { perm - permutations } if (ncol(perm) != nobs) stop(gettextf('permutations' have %d columns, but data have %d rows, ncol(perm), nobs)) nperm - nrow(perm) if (nperm 0) perm.contr - matrix(nrow = P, ncol = nperm) for (i in 1:nrow(comp)) { group.a - comm[group == comp[i, 1], ] group.b - comm[group == comp[i, 2], ] n.a - nrow(group.a) n.b - nrow(group.b) contr - matrix(ncol = P, nrow = n.a * n.b) for (j in 1:n.b) { for (k in 1:n.a) { ### Morisita-Horn aN - sum(group.a[k, ]) bN - sum(group.b[j, ]) da - sum(group.a[k, ]^2)/aN^2 db - sum(group.b[j, ]^2)/bN^2 top - (group.a[k, ] * group.b[j, ]) contr[(j - 1) * n.a + k, ] - 2 * top/((da + db) * aN * bN) # } } average - colMeans(contr) if (nperm 0) { if (trace) cat(Permuting, paste(comp[i, 1], comp[i, 2], sep = _), \n) contrp - matrix(ncol = P, nrow = n.a * n.b) for (p in 1:nperm) { groupp - group[perm[p, ]] ga - comm[groupp == comp[i, 1], ] gb - comm[groupp == comp[i, 2], ] for (j in 1:n.b) { for (k in 1:n.a) { ### Morisita-Horn aNp - sum(gpa[k, ]) bNp - sum(gpb[j, ]) dap - sum(gpa[k, ]^2)/aNp^2 dbp - sum(gpb[j, ]^2)/bNp^2 topp - (gpa[k, ] * gpb[j, ]) contrp[(j - 1) * n.a + k, ] - 2 * topp/((dap + dbp) * aNp * bNp) # } } perm.contr[, p] - colMeans(contrp) } p - (apply(apply(perm.contr, 2, function(x) x = average), 1, sum) + 1)/(nperm + 1) } else { p - NULL } overall - sum(average) sdi - apply(contr, 2, sd) ratio - average/sdi ava - colMeans(group.a) avb - colMeans(group.b) ord - order(average, decreasing = TRUE) cusum - cumsum(average[ord]/overall) out - list(species = colnames(comm), average = average, overall = overall, sd = sdi, ratio = ratio, ava = ava, avb = avb, ord = ord, cusum = cusum, p = p) outlist[[paste(comp[i, 1], _, comp[i, 2], sep = )]] - out } attr(outlist, permutations) - nperm class(outlist) - simper outlist } -- View this message in context: http://r.789695.n4.nabble.com/Simper-analysis-with-Morisita-Horn-tp4651283.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] GLM Coding Issue
Thank you both for the extensive amount of help! I am sorry it has taken me a bit to respond, but i've been trying to plug away at this. I still have a few questions, if you don't mind giving me some pointers: Here is the fake data again: treatment feeding avoid noavoid (all visits which didnât result in avoidance) Control nofeeding 1 357 Control chum 2 292 Control Satiation 4 186 Proc. Control nofeeding 15 291 Proc. Control chum 25 288 Proc. Control Satiation 17 140 Magnet nofeeding 87 224 Magnet Chum 34 229 Magnet Satiation 46 151 Here is the coding: model1 - glm(cbind(avoid, noavoid) ~ treatment, family=binomial,  data=avoid) summary(model1) glm(formula = cbind(avoid, noavoid )~treatment , family = binomial, data = avoid)  #Predicting avoid, no avoid from just treatment model2 - glm(cbind(avoid, noavoid) ~ feeding, family=binomial, data=avoid) summary(model2)  glm(formula = cbind(avoid, noavoid )~feeding , family = binomial, data = avoid) #Predicting avoid, no avoid from just feeding model3-glm(cbind(avoid,noavoid)~treatment*feeding,family=binomial,data=avoid) summary(model3) glm(formula = cbind(avoid, noavoid )~treatment*feeding , family = binomial, data = avoid) #Predicting avoid,noavoid from the interaction between treatment and feeding However, when I run all the models, I notice that my control data is not incorporated in the output. I just receive my procedural control and magnet data. I cannot figure what is causing this. Secondly, when I run model 3 I am not receiving what I anticipated. I thought I would get the following output data: treatmentmag                 treatmentproc                feedingnofeed                   feedingsat                       treatmentmag:feedingnofeed       treatmentproc:feedingnofeed      treatmentmag:feedingsat         treatmentproc:feedingsat What happened to the following: treatmentcon, feedingchum, treatmentcon:feedingnofeed, treatmentcon:feedingsat, treatmentmag:feedingchum, treatmentproc:feedingchum, treatmentcon:feedingchum ?  I have a strange feeling that the issue is arising from my family=binomial term. Any feedback would be greatly appreciated. Kind Regards, Craig - Original Message - From: Steve Lianoglou mailinglist.honey...@gmail.com To: David Winsemius dwinsem...@comcast.net Cc: Craig P O'Connell coconne...@umassd.edu, r-help@r-project.org Sent: Tuesday, November 27, 2012 11:54:48 PM Subject: Re: [R] GLM Coding Issue Hi, On Tuesday, November 27, 2012, David Winsemius wrote: [snip] blockquote `cbind`-ing doesn't make much sense here. What is your target (y) variable here? are you trying to predict `avoid` or `noavoid` status? Sorry, Steve. It does make sense. See : ?glm  # First paragraph of Details. /blockquote Indeed ... I've tried to,send a follow up email salvaging my bad call with some hopefully useful tidbits, but it matched some headers and is stuck in the mailman queue. It might come through eventually. Don't be sorry, though ... I learned something new :-) Still, I do apologize for the flawed advice re: the cbind-ing thing -Steve -- Steve Lianoglou Graduate Student: Computational Systems Biology  | Memorial Sloan-Kettering Cancer Center  | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact [[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] Calculating Linkage Disequilibrium for Microsatellite Markers?
Function LDkl of package gap. I am also trying to use it. -- View this message in context: http://r.789695.n4.nabble.com/Calculating-Linkage-Disequilibrium-for-Microsatellite-Markers-tp4642701p4651285.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] deleting data of a given date range.
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of siddanth911 Sent: Thursday, November 29, 2012 12:10 PM To: r-help@r-project.org Subject: [R] deleting data of a given date range. hey, I have a huge dataset with over 30 rows which contains data about something from 2009-2012. does anyone know how i can delete all the rows which contain data from 2009 and only have data from 2010-2012??? is there a particular function i can use on the date column so that all data from 2009 can be deleted??? It depends on structure of your data (unstated). If I presume that you have data frame and you have date in some column you can just use standard subsetting new.data - your.data[your.data$Date some.threshold.Date, ] Regards Petr -- View this message in context: http://r.789695.n4.nabble.com/deleting- data-of-a-given-date-range-tp4651272.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] Conditional model in R
Thank you very much, I'll look into that package! Kirsten _ Kirsten Martin Von Holle Lab Department of Biology, BL 405 University of Central Florida Orlando, FL 32816 From: Jagat.K.Sheth [via R] [ml-node+s789695n4651207...@n4.nabble.com] Sent: Wednesday, November 28, 2012 4:07 PM To: Kirsten Martin Subject: Re: Conditional model in R Sounds like a finite mixture model. I haven't read your references but an overall model for such an approach could be f(Y=0; pi, kappa) = 1- pi + pi*f(Y=0|Z=1; kappa) where pi=Pr(Z=1) is the probability of an event, z, and y is the value observed when the event occurs and f is the probability density of Y with parameters kappa. You could try 'fmr' in Jim Lindsey's gnlm package (available at http://www.commanster.eu/rcode.html ) which fits generalized nonlinear regression models with two or three point mixtures using maximum likelihood. -Original Message- From: [hidden email]UrlBlockedError.aspx [mailto:r-help-bounces@r- project.org] On Behalf Of Kirsten Martin Sent: Wednesday, November 28, 2012 1:33 PM To: [hidden email]UrlBlockedError.aspx Subject: [R] Conditional model in R Hello all, I have a data set where the response variable is the percent cover of a specific plant (represented in cover classes 0,1,2,3,4,5, or 6). This data set has a lot of zeros (plots where the plant was not present). I am trying to model cover class of the plant as a function of both total nitrogen and shrub cover. After quite a bit of research I have come across a conditional approach to modeling data with a lot of zeros (Fletcher et al. 2005, Welsh et al. 1996). In this approach you model the presence/absence data using a logistic regression and then model the presence only data using ordinary (least squares) regression. I have successfully come up with both a logistic model and an ols model with good fits. I am running into trouble combining the two (as outlined in the third step of the Fletcher et al. 2005 paper). Does anyone have any experience or any advice on doing this? How does one come up with an overall model for the data using this approach? Thanks for your help! Kirsten -- View this message in context: http://r.789695.n4.nabble.com/Conditional-model-in-R-tp4651188.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email]UrlBlockedError.aspx 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. __ [hidden email]UrlBlockedError.aspx 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. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Conditional-model-in-R-tp4651188p4651207.html To unsubscribe from Conditional model in R, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4651188code=a21tYXJ0aW5Aa25pZ2h0cy51Y2YuZWR1fDQ2NTExODh8LTgwNzYyNDM3Nw==. NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://r.789695.n4.nabble.com/Conditional-model-in-R-tp4651188p4651288.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] splitting a string by space except when contained within quotes
On Thu, Nov 29, 2012 at 9:43 AM, downtowater downtowa...@yahoo.ca wrote: I've been trying to split a space delimited string with double-quotes in R for some time but without success. An example of a string is as follows: /rainfall snowfall Channel storage Rivulet storage/ It's important for us because these are column headings that must match the subsequent data. Here is some code I've been trying: str - 'rainfall snowfall Channel storage Rivulet storage' regex - [^\\s\']+|\([^\]*)\ split - strsplit(str, regex, perl=T) what I would like is [1] rainfall snowfall Channel storage Rivulet storage but what I get is: [1] The vector is the right length (which is encouraging) but of course the strings are empty or contain a single space. Any suggestions? Try this: scan(con - textConnection(str), what = ) Read 4 items [1] rainfallsnowfallChannel storage Rivulet storage close(con) email: ggrothendieck at 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] QQplot
Hi! http://r.789695.n4.nabble.com/file/n4651293/qq.png We are stuck with a problem considering the qqplot of a dataset. We are trying to discover what kind of distribution this is. We already tried to normal, exponential or the logaritmical distribution but none of those are able to solve our problem. Is there someone able to tell us what kind deformation we should try? (I'm sorry for the horrible English but I'm not a native speaker) Thanks! Nathan -- View this message in context: http://r.789695.n4.nabble.com/QQplot-tp4651293.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] Label axis with strings instead of numbers
Hello, See the ?axis function, argument 'labels'. Hope this helps, Rui Barradas Em 29-11-2012 12:20, seanlilley escreveu: I have created a bubble plot in R using the following formula: symbols(Data$Day.Number,Data$Team,circles=Data$Total.amount, inches=0.5, fg=white,bg=red,xlab=Day Number,ylab=Team) The data set is called Data, and I have the columns Day.Number, Team and Total.amount. The data is plotting fine, but where my y axis should have the names of each team, it instead labels 1,2,3,4 How do I edit this to label the axis with the names of the teams instead? Thanks Sean -- View this message in context: http://r.789695.n4.nabble.com/Label-axis-with-strings-instead-of-numbers-tp4651275.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] splitting a string by space except when contained within quotes
Try using scan(quote='', ...), as in the following str - 'rainfall snowfall Channel storage Rivulet storage' scan(text=str, what=, quote='', quiet=TRUE) [1] rainfallsnowfallChannel storage Rivulet storage Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of downtowater Sent: Thursday, November 29, 2012 6:44 AM To: r-help@r-project.org Subject: [R] splitting a string by space except when contained within quotes I've been trying to split a space delimited string with double-quotes in R for some time but without success. An example of a string is as follows: /rainfall snowfall Channel storage Rivulet storage/ It's important for us because these are column headings that must match the subsequent data. Here is some code I've been trying: str - 'rainfall snowfall Channel storage Rivulet storage' regex - [^\\s\']+|\([^\]*)\ split - strsplit(str, regex, perl=T) what I would like is [1] rainfall snowfall Channel storage Rivulet storage but what I get is: [1] The vector is the right length (which is encouraging) but of course the strings are empty or contain a single space. Any suggestions? Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/splitting-a-string-by- space-except-when-contained-within-quotes-tp4651286.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bootstrapped cox regression (rms package)
Hi, I am trying to convert a colleague from using SPSS to R, but am having trouble generating a result that is similar enough to a bootstrapped cox regression analysis that was run in SPSS. I tried unsuccessfully with bootcens, but have had some success with the bootcov function in the rms package, which at least generates confidence intervals similar to what is observed in SPSS. However, the p-values associated with each predictor in the model are not really close in many instances. Here is the code I am using: formula=Surv(months, recidivate) ~ fac1 + fac2 + fac3 + fac4 + fac5 + fac6 + fac7 + fac8 fit=cph(formula, data=temp, x=T, y=T) validate(fit, method=boot, B=, bw=F, type=residual, sls=0.05, aics=0,force=NULL, estimates=TRUE, pr=FALSE) out=bootcov(fit, B=, pr=F, coef.reps=T, loglik=F) for (i in 1:8) { print(quantile(out$boot.Coef[,i], c(.025, .975))) } anova(out) variable low CI high CI p-value fac1 -8.919692 20.800878 .5917 fac2 -8.683579 3.091100 .6381 fac3 -1.848428 2.193492 .9312 fac4 -0.17575426 0.08333277 .8246 fac5 -3.1488578 0.5166171 .2946 fac6 -0.03621405 0.07241772 .5600 fac7 -0.62847922 0.08566296 .3433 fac8 -0.01553286 0.20909384 .5756 The results from SPSS I am trying to match (or come close to matching) are the following: variable low CI high CI p-value fac1 -8.474 20.020 .456 fac2 -8.206 3.093 .524 fac3 -1.829 2.087 .900 fac4 -.173 .083 .749 fac5 -2.945 .450 .143 fac6 -.035 .070 .306 fac7 -.626 .092 .189 fac8 -.017 .203 .247 Sorry if this is a really basic question. I have searched for several hours for an explanation, but cannot find anything that explains why the p-values would be different despite similar confidence intervals. Thanks in advance, Eric [[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 handle Chinese [It seems Cyrillic] character in R plot?
Your subject line says Chinese! On 29/11/2012 08:42, Manish Gupta wrote: Hi, I m working on R plot with Russian label but on windows (adobe) russian text are not visible. Do i need to install some package to view it. pdf(sample.pdf,width = 6.6 ,height = 4.2,family= URWHelvetica, encoding=KOI8-R) x-c(1,2,3,4,5) y-c(2,3,4,5,6) xlable-c(ручка,книга,часы,ложка,смотреть) plot(x,y,xlab=xlable) dev.off() See ?pdf: If you see problems with PDF output, do remember that the problem is much more likely to be in your viewer than in R. Try another viewer if possible. The fonts include with the Adobe viewers do not cover Cyrillic (as the help in fact says). It does work in poppler-based and gs-based viewers. It is possible that you need to install a suitable language pack for your unstated Adobe viewer. There are other devices for pdf, as the help says. Seem if cairo_pdf() works on Windows. -- 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] Label axis with strings instead of numbers
Hi, The axis function plots an axis ontop of my current axis. So although I am able to write my labels in, they are written ontop of the numbers in the current axis rather than replacing them. Any other alternatives? Sean -- View this message in context: http://r.789695.n4.nabble.com/Label-axis-with-strings-instead-of-numbers-tp4651275p4651305.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] comparing two vectors
On 29-11-2012, at 14:28, soham chakraborty wrote: Hello, I am performing Newton Raphson iteration where the parameter vector which I want to optimize is an *nx1* vector. Are you trying to solve a system of nonlinear equations? Have a look at package nleqslv. Are you max-/min-imizing a function? Look at R provided functions such as optim, nlminb and the CRAN Optimizing Task View. I am running a while loop which will continue unless a stopping condition is satisfied Now, the stopping condition will have to be such that the parameter vector after two successive iterations are very close to each other,*component wise*. I have tried the* all* function, in which case the number of iterations are enormous. Is there any better way to do this? How have you been using all()? Berend __ 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] Can R be embedded in html?
I grab the opportunity to suggest giving a try `pander` package, which holds a forked version of `brew` called `Pandoc.brew`. If you are familiar with `brew`, you could easily create nicely formatted HTML output automatically beside other formats, example: http://rapporter.github.com/pander/#examples But if you want to run those files directly, then RApache is the way to go with `RHandler brew::brew`, although that would end up in a spaghetti code. It's better to keep R and HTML separately in the long run. Best, Gergely On Thu, Nov 29, 2012 at 4:41 PM, jagat.k.sh...@wellsfargo.com wrote: Try R package 'brew'? From its package description Description:brew implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server Pages, and Python's psp module. There is also the rApache project and many other useful links mentioned on R Web Interfaces on the R FAQ page. Jagat -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of chawla Sent: Wednesday, November 28, 2012 9:04 AM To: r-help@r-project.org Subject: [R] Can R be embedded in html? Hi I have previously used PHP script in HTML to connect website with the database and do analysis. Is it also possible to execute R scripts within HTML files? Basically I want to create an application where user can input data such as gene list and their expression values, which can be processed by R and result be displayed or made available for download. If there is some guide on how to do this please give the link. Thanks Konika __ 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. [[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] splitting a string by space except when contained within quotes
Hi, May be this helps: str1 - 'rainfall snowfall Channel storage Rivulet storage' res-unlist(strsplit(gsub([\],,str1), )) res1-c(res[1],res[2],paste(res[3],res[4],),paste(res[5],res[6],collapse=)) res1 #[1] rainfall snowfall Channel storage Rivulet storage A.K. - Original Message - From: downtowater downtowa...@yahoo.ca To: r-help@r-project.org Cc: Sent: Thursday, November 29, 2012 9:43 AM Subject: [R] splitting a string by space except when contained within quotes I've been trying to split a space delimited string with double-quotes in R for some time but without success. An example of a string is as follows: /rainfall snowfall Channel storage Rivulet storage/ It's important for us because these are column headings that must match the subsequent data. Here is some code I've been trying: str - 'rainfall snowfall Channel storage Rivulet storage' regex - [^\\s\']+|\([^\]*)\ split - strsplit(str, regex, perl=T) what I would like is [1] rainfall snowfall Channel storage Rivulet storage but what I get is: [1] The vector is the right length (which is encouraging) but of course the strings are empty or contain a single space. Any suggestions? Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/splitting-a-string-by-space-except-when-contained-within-quotes-tp4651286.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] splitting a string by space except when contained within quotes
Hi, You could also do this: res-unlist(strsplit(str,[\])) res1-res[res!= ] res2-c(unlist(strsplit(res1[grepl(\\s+$,res1)], )),res1[!grepl(\\s+$,res1)]) res2 #[1] rainfall snowfall Channel storage Rivulet storage A.K. - Original Message - From: downtowater downtowa...@yahoo.ca To: r-help@r-project.org Cc: Sent: Thursday, November 29, 2012 9:43 AM Subject: [R] splitting a string by space except when contained within quotes I've been trying to split a space delimited string with double-quotes in R for some time but without success. An example of a string is as follows: /rainfall snowfall Channel storage Rivulet storage/ It's important for us because these are column headings that must match the subsequent data. Here is some code I've been trying: str - 'rainfall snowfall Channel storage Rivulet storage' regex - [^\\s\']+|\([^\]*)\ split - strsplit(str, regex, perl=T) what I would like is [1] rainfall snowfall Channel storage Rivulet storage but what I get is: [1] The vector is the right length (which is encouraging) but of course the strings are empty or contain a single space. Any suggestions? Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/splitting-a-string-by-space-except-when-contained-within-quotes-tp4651286.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Deleting certain observations (and their imprint?)
I'm manipulating a large dataset and need to eliminate some observations based on specific identifiers. This isn't a problem in and of itself (using which.. or subset..) but an imprint of the deleted observations seem to remain, even though they have 0 observations. This is causing me problems later on. I'll use the dataset warpbreaks to illustrate, I apologize if this isn't in the best format ##Summary of warpbreaks suggests three tension levels (H, M, L) summary(warpbreaks) breaks wool tension Min. :10.00 A:27 L:18 1st Qu.:18.25 B:27 M:18 Median :26.00 H:18 Mean :28.15 3rd Qu.:34.00 Max. :70.00 ## Subset the dataset and keep only those observations with L wb.subset - warpbreaks[which(warpbreaks$tension==L),] ##Summary of the subsetted data shows: L=18, M=0, H=0, Why is M and H still included? summary(wb.subset) breaks wool tension Min. :14.00 A:9 L:18 1st Qu.:26.00 B:9 M: 0 Median :29.50 H: 0 Mean :36.39 3rd Qu.:49.25 Max. :70.00 ##The subsetted dataset does not show M or H wb.subset Is there a way that M H can be completely eliminated (i.e. they don't show up in summary)? The only way I found was to export the dataset and then reimport, which seems pretty cumbersome. Thanks in advance for any help. -Kirk __ 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] GSCA package error
it's the GSCA packagei made a typo in the subject, my apologies the package is available from here http://www.biostat.wisc.edu/~kendzior/GSCA/ i am now trying to do co-expression analysis using EBcoexpress but looks like i have a similar problem due to the sample size! thanks! -- View this message in context: http://r.789695.n4.nabble.com/GSEA-package-error-tp4651223p4651310.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] QQplot
Have you tried fitting your data to the Pearson family of distributions? In particular the Pearson Type IV has parameters to fit skewed and kurtotic distributions. The Pearson library is described here: http://cran.r-project.org/web/packages/PearsonDS/PearsonDS.pdf The Type IV is described here: http://www-cdf.fnal.gov/physics/statistics/notes/cdf6820_pearson4.pdf GL, Frank Chicago Date: Thu, 29 Nov 2012 07:03:28 -0800 From: michaelverbi...@msn.com To: r-help@r-project.org Subject: [R] QQplot Hi! http://r.789695.n4.nabble.com/file/n4651293/qq.png We are stuck with a problem considering the qqplot of a dataset. We are trying to discover what kind of distribution this is. We already tried to normal, exponential or the logaritmical distribution but none of those are able to solve our problem. Is there someone able to tell us what kind deformation we should try? (I'm sorry for the horrible English but I'm not a native speaker) Thanks! Nathan -- View this message in context: http://r.789695.n4.nabble.com/QQplot-tp4651293.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] Deleting certain observations (and their imprint?)
Hi Kirk, It's because tension is a factor with three levels, as you could see with str(warpbreaks). Factors are one of the mysteries of R that distinguish a novice from an initiate. Reading ?subset directs you to ?droplevels. Here's an example: summary(warpbreaks) breaks wool tension Min. :10.00 A:27 L:18 1st Qu.:18.25 B:27 M:18 Median :26.00 H:18 Mean :28.15 3rd Qu.:34.00 Max. :70.00 str(warpbreaks) 'data.frame':54 obs. of 3 variables: $ breaks : num 26 30 54 25 70 52 51 26 67 18 ... $ wool : Factor w/ 2 levels A,B: 1 1 1 1 1 1 1 1 1 1 ... $ tension: Factor w/ 3 levels L,M,H: 1 1 1 1 1 1 1 1 1 2 ... ?subset wb.subset - warpbreaks[which(warpbreaks$tension==L),] summary(wb.subset) breaks wool tension Min. :14.00 A:9 L:18 1st Qu.:26.00 B:9 M: 0 Median :29.50 H: 0 Mean :36.39 3rd Qu.:49.25 Max. :70.00 wb.subset - droplevels(wb.subset) summary(wb.subset) breaks wool tension Min. :14.00 A:9 L:18 1st Qu.:26.00 B:9 Median :29.50 Mean :36.39 3rd Qu.:49.25 Max. :70.00 Sarah On Thu, Nov 29, 2012 at 11:32 AM, Stodola, Kirk kstod...@illinois.edu wrote: I'm manipulating a large dataset and need to eliminate some observations based on specific identifiers. This isn't a problem in and of itself (using which.. or subset..) but an imprint of the deleted observations seem to remain, even though they have 0 observations. This is causing me problems later on. I'll use the dataset warpbreaks to illustrate, I apologize if this isn't in the best format ##Summary of warpbreaks suggests three tension levels (H, M, L) summary(warpbreaks) breaks wool tension Min. :10.00 A:27 L:18 1st Qu.:18.25 B:27 M:18 Median :26.00 H:18 Mean :28.15 3rd Qu.:34.00 Max. :70.00 ## Subset the dataset and keep only those observations with L wb.subset - warpbreaks[which(warpbreaks$tension==L),] ##Summary of the subsetted data shows: L=18, M=0, H=0, Why is M and H still included? summary(wb.subset) breaks wool tension Min. :14.00 A:9 L:18 1st Qu.:26.00 B:9 M: 0 Median :29.50 H: 0 Mean :36.39 3rd Qu.:49.25 Max. :70.00 ##The subsetted dataset does not show M or H wb.subset Is there a way that M H can be completely eliminated (i.e. they don't show up in summary)? The only way I found was to export the dataset and then reimport, which seems pretty cumbersome. Thanks in advance for any help. -Kirk -- 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.
[R] How to use doSMP(revoIPC) with R 2.15.x version
Hello, I'd like to use package 'doSMP'. But I can only found source codes in the CRAN. I tried to build source code using 'r CMD build doSMP' in the source directory, the following error is shown: ERROR: dependencies 'foreach', 'iterators', 'revoIPC' are not available for pack age 'doSMP' So, i tried to install dependency packages. But I failed to install revoIPC with following error: install.packages('revoIPC') Installing package(s) into âC:/Program Files/R/R-2.15.2/libraryâ (as âlibâ is unspecified) Warning in install.packages : package ârevoIPCâ is not available (for R version 2.15.2) Could you let me know how to use it in R ver2.15.x ? Thanks in advance, [[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] knitr error with Lyx
R Users, I just upgraded my version of R from R-2.15.0 to R-2.15.2 and installed the latest versions of LyX and MikTex running Windows 7 Ultimate, 64-bit OS. Prior to the upgrade, I was using Lyx with knitr to generate a document with no problems. However, after the upgrade, and using the same LyX document, I'm receiving the following error when I attempt to compile the document: \end{verbatim} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. I have determined that the error is caused when printing the anova results from the anova statement in my R source code, but can't seem to resolve the issue. Here is an example code chunk that creates the error: NonCP1, fig.width=6, fig.height=4, out.width='.8\\linewidth' ,par=FALSE= #Read in data y=c( 67, 73, 83, 89, 65, 91, 87, 86, 155, 127, 147, 212, 108, 100, 90, 153, 140, 142, 121, 150, 33, 8, 46, 54 ) temp=as.factor(c(rep(seq(360, 380, 10), each=4), rep(seq(380, 360, -10), each=4))) coat=as.factor(rep(seq(1, 4), 6)) replicate=as.factor(rep(seq(1, 6), each=4)) #Obtain Factorial/Incorrect Model o=lm(y~temp*coat) ano=anova(o) ano @ Removing the ano=anova(o) or ano lines in the code chunk allows the document to compile with no problem. Does anyone else have this problem or did I do something wrong when I migrated to the newer versions? Thanks, in advance for any help! Sincerely yours, Mark J. Lamias [[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] Label axis with strings instead of numbers
Hello, Use argument yaxt = n of function symbols. yaxt means y axis type and n for none (or no). Then plot the axis with axis(2, ...) Hope this helps, Rui Barradas Em 29-11-2012 16:17, seanlilley escreveu: Hi, The axis function plots an axis ontop of my current axis. So although I am able to write my labels in, they are written ontop of the numbers in the current axis rather than replacing them. Any other alternatives? Sean -- View this message in context: http://r.789695.n4.nabble.com/Label-axis-with-strings-instead-of-numbers-tp4651275p4651305.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] What am I missing when using zoo on version 2.15?
Hello I am running R versions 2.13 and 2.15. One of my codes run ok on 2.13 but on 2.15. I have tried to understand what is wrong but come up with nothing. Here is the code rm(list=ls()) graphics.off() library(R.matlab) library(zoo); library(xts); library(lattice); library(hydroGOF); a=readMat(exemplo_narmax_Aimores_MISO.mat) predicoes=zoo(cbind(a$predicoes[,,1]$Real,a$predicoes[,,1]$Predito),as.Date( a$predicoes[,,1]$data)) names(predicoes)=c(Real,Predito) ggof(obs=predicoes$Real,sim=predicoes$Predito,main=Predicao Vazao - NARMAX MISO, legend=c(Predito,Real)) ggof is a function on the hydroGOF available on CRAN. Predicoes looks like predicoes Real Predito 2008-12-20 921 921. 2008-12-21 1002 1002. 2008-12-22 870 870. 2008-12-23 695 695. 2008-12-24 751 751. 2008-12-25 650 650. 2008-12-26 443 443. .. which looks ok to me. The error msg on version 2.15 is ggof(obs=predicoes$Real,sim=predicoes$Predito,main=Predicao Vazao - NARMAX MISO, + legend=c(Predito,Real)) Error in try.xts(x, error = 'x' needs to be timeBased or xtsible) : 'x' needs to be timeBased or xtsible Just a remainder - there is no error whatsoever on version 2.13. What am I missing? Many thanks Ed [[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] RGL plot : cex and zlim arguments do not work
Hi Ducan and others, I am sorry for this such late reply but I did not see that I had a reply... I have not solved the problem text3d(1:3, 1:3, 1:3, LETTERS[1:3], cex=1:3) does not work for me Maybe it is related to my material, I am on linux debian Sys.info() sysname Linux release 2.6.32-5-amd64 packages: rgl_0.92.892 misc3d_0.8-3 2012/9/25 Duncan Murdoch murdoch.dun...@gmail.com On 25/09/2012 11:07 AM, Stephane Chantepie wrote: Dear all, I have a quiet simple problem (shared by a collegue) but no solution at yet. The arguments I use in bbox3d or text3d do not have any effect on the graph. I need to use 'cex' and 'zlim' but It does not work. Maybe my problem could appear trivial but I have spent a lot of time on that. If you have a solution, please let me know! You need to provide an example of what you are trying. cex works for me: text3d(1:3, 1:3, 1:3, LETTERS[1:3], cex=1:3) zlim makes no sense for text3d. Duncan Murdoch [[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] Fast Normalize by Group
Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 groups with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do this? 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.
Re: [R] knitr error with Lyx
Quite a few people have had this problem, but since I'm unable to reproduce it, I'm not exactly sure how to fix it either. A few references that might be helpful to you: http://stackoverflow.com/q/12448507/559676 https://github.com/yihui/knitr/issues/413 It is very likely to be a pure LaTeX problem. Letting MikTeX install the missing LaTeX packages on the fly might solve the problem. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Thu, Nov 29, 2012 at 10:53 AM, Mark Lamias mlam...@yahoo.com wrote: R Users, I just upgraded my version of R from R-2.15.0 to R-2.15.2 and installed the latest versions of LyX and MikTex running Windows 7 Ultimate, 64-bit OS. Prior to the upgrade, I was using Lyx with knitr to generate a document with no problems. However, after the upgrade, and using the same LyX document, I'm receiving the following error when I attempt to compile the document: \end{verbatim} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. I have determined that the error is caused when printing the anova results from the anova statement in my R source code, but can't seem to resolve the issue. Here is an example code chunk that creates the error: NonCP1, fig.width=6, fig.height=4, out.width='.8\\linewidth' ,par=FALSE= #Read in data y=c( 67, 73, 83, 89, 65, 91, 87, 86, 155, 127, 147, 212, 108, 100, 90, 153, 140, 142, 121, 150, 33, 8, 46, 54 ) temp=as.factor(c(rep(seq(360, 380, 10), each=4), rep(seq(380, 360, -10), each=4))) coat=as.factor(rep(seq(1, 4), 6)) replicate=as.factor(rep(seq(1, 6), each=4)) #Obtain Factorial/Incorrect Model o=lm(y~temp*coat) ano=anova(o) ano @ Removing the ano=anova(o) or ano lines in the code chunk allows the document to compile with no problem. Does anyone else have this problem or did I do something wrong when I migrated to the newer versions? Thanks, in advance for any help! Sincerely yours, Mark J. Lamias [[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] Fast Normalize by Group
Not tested but should work: sums = tapply(x, group, sum); sums.ext = sums[ match(group, names(sums))] normalized = x/sums.ext It may be that the tapply is just as slow as your loop though, I'm not sure. HTH, Peter On Thu, Nov 29, 2012 at 10:55 AM, Noah Silverman noahsilver...@ucla.edu wrote: Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 groups with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do this? 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 http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fast Normalize by Group
Yes, type in: ?by for example: data - data.frame(fac=factor(c(A,A,B,B)), vec=c(1:4) ) by(data$vec,data$fac, FUN=sum) Best, MikoÅaj Hnatiuk 2012/11/29 Noah Silverman noahsilver...@ucla.edu Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 groups with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do this? 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. [[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] Fast Normalize by Group
Hello, If yopu want one value per group use tapply(), if you want one value per value of x use ave() tapply(x, group, FUN = function(.x) .x/sum(.x)) ave(x, group, FUN = function(.x) .x/sum(.x)) Hope this helps, Rui Barradas Em 29-11-2012 18:55, Noah Silverman escreveu: Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 groups with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do this? 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 http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fast Normalize by Group
try the 'data.table' package. Takes about 0.1 seconds to normalize the data. x - data.frame(id = sample(1, 10, TRUE), value = runif(10)) require(data.table) Loading required package: data.table data.table 1.8.2 For help type: help(data.table) system.time({ + x - data.table(x) + newX - x[ + , list(value = value # keep original value + , normValue = value / sum(value) + ) + , by = id + ] + }) user system elapsed 0.030.010.11 head(newX, 20) id value normValue 1: 8094 0.6805425 0.101140797 2: 8094 0.3154233 0.046877543 3: 8094 0.8998646 0.133735993 4: 8094 0.8858863 0.131658564 5: 8094 0.1859526 0.027635892 6: 8094 0.4694456 0.069768023 7: 8094 0.9302886 0.138257544 8: 8094 0.7482040 0.96505 9: 8094 0.9052426 0.134535255 10: 8094 0.4650028 0.069107739 11: 8094 0.2428116 0.036086145 12: 6287 0.1979209 0.037505820 13: 6287 0.5117723 0.096980353 14: 6287 0.6425769 0.121767688 15: 6287 0.0397795 0.007538177 16: 6287 0.1255722 0.023795811 17: 6287 0.5606742 0.106247214 18: 6287 0.4818579 0.091311594 19: 6287 0.3913614 0.074162596 20: 6287 0.4622984 0.087605098 On Thu, Nov 29, 2012 at 1:55 PM, Noah Silverman noahsilver...@ucla.edu wrote: Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 groups with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do this? 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. -- 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.
Re: [R] Fast Normalize by Group
Close, but not quite what I need. That very nicely gives me sums by group. I need to take each value of X and divide it by the sum of the group it belongs to. With your example, I have 100,000 X and only 10,000 group. The by command gives me 10,000 sums. I still have to loop over all 100,000 entries, and find the group sum they belong to. On Nov 29, 2012, at 11:05 AM, MikoÅaj Hnatiuk mikolaj.hnat...@gmail.com wrote: Yes, type in: ?by for example: data - data.frame(fac=factor(c(A,A,B,B)), vec=c(1:4) ) by(data$vec,data$fac, FUN=sum) Best, MikoÅaj Hnatiuk 2012/11/29 Noah Silverman noahsilver...@ucla.edu Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 groups with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do this? 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. [[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] Fast Normalize by Group
On 29-11-2012, at 19:55, Noah Silverman wrote: Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 groups with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do this? Toy example: gx - data.frame(group=rep(1:4,each=3), x=1:12) gx gx$x - ave(gx$x, gx$group, FUN=function(x) x/sum(x)) gx Berend __ 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] Can R be embedded in html?
I did not read every reply; perhaps someone has already mentioned Shiny. There are a few live examples of embedding R in HTML here: http://www.rstudio.com/shiny/ Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Thu, Nov 29, 2012 at 10:34 AM, Gergely Daróczi gerg...@snowl.net wrote: I grab the opportunity to suggest giving a try `pander` package, which holds a forked version of `brew` called `Pandoc.brew`. If you are familiar with `brew`, you could easily create nicely formatted HTML output automatically beside other formats, example: http://rapporter.github.com/pander/#examples But if you want to run those files directly, then RApache is the way to go with `RHandler brew::brew`, although that would end up in a spaghetti code. It's better to keep R and HTML separately in the long run. Best, Gergely On Thu, Nov 29, 2012 at 4:41 PM, jagat.k.sh...@wellsfargo.com wrote: Try R package 'brew'? From its package description Description:brew implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server Pages, and Python's psp module. There is also the rApache project and many other useful links mentioned on R Web Interfaces on the R FAQ page. Jagat -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of chawla Sent: Wednesday, November 28, 2012 9:04 AM To: r-help@r-project.org Subject: [R] Can R be embedded in html? Hi I have previously used PHP script in HTML to connect website with the database and do analysis. Is it also possible to execute R scripts within HTML files? Basically I want to create an application where user can input data such as gene list and their expression values, which can be processed by R and result be displayed or made available for download. If there is some guide on how to do this please give the link. Thanks Konika __ 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] knitr error with Lyx
Thanks, Yihui! Luckily I kept R-2.15.0 and left it untouched (so I can continue to use that for now). If it helps any, I was able to go back into Lyx and change the path to point to R-2.15.0 and I also changed the windows path environment variable to point to the old version. After doing this, LyX worked fine with no problem on the code below. Changing the paths back to the new version R-2.15.2, generates the error below. If anyone else has any idea how to resolve this, either through R or a Lyx/LaTeX fix, I'd be all ears. Thanks, again for your response, Yihui! Sincerely yours, Mark J. Lamias From: Yihui Xie x...@yihui.name Cc: r-help@r-project.org r-help@r-project.org Sent: Thursday, November 29, 2012 2:02 PM Subject: Re: [R] knitr error with Lyx Quite a few people have had this problem, but since I'm unable to reproduce it, I'm not exactly sure how to fix it either. A few references that might be helpful to you: http://stackoverflow.com/q/12448507/559676 https://github.com/yihui/knitr/issues/413 It is very likely to be a pure LaTeX problem. Letting MikTeX install the missing LaTeX packages on the fly might solve the problem. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA R Users, I just upgraded my version of R from R-2.15.0 to R-2.15.2 and installed the latest versions of LyX and MikTex running Windows 7 Ultimate, 64-bit OS. Prior to the upgrade, I was using Lyx with knitr to generate a document with no problems. However, after the upgrade, and using the same LyX document, I'm receiving the following error when I attempt to compile the document: \end{verbatim} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. I have determined that the error is caused when printing the anova results from the anova statement in my R source code, but can't seem to resolve the issue. Here is an example code chunk that creates the error: NonCP1, fig.width=6, fig.height=4, out.width='.8\\linewidth' ,par=FALSE= #Read in data y=c( 67, 73, 83, 89, 65, 91, 87, 86, 155, 127, 147, 212, 108, 100, 90, 153, 140, 142, 121, 150, 33, 8, 46, 54 ) temp=as.factor(c(rep(seq(360, 380, 10), each=4), rep(seq(380, 360, -10), each=4))) coat=as.factor(rep(seq(1, 4), 6)) replicate=as.factor(rep(seq(1, 6), each=4)) #Obtain Factorial/Incorrect Model o=lm(y~temp*coat) ano=anova(o) ano @ Removing the ano=anova(o) or ano lines in the code chunk allows the document to compile with no problem. Does anyone else have this problem or did I do something wrong when I migrated to the newer versions? [[elided Yahoo spam]] Sincerely yours, Mark J. Lamias [[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] Can R be embedded in html?
I haven't used it yet, so I can't comment about the stability or appropriateness of it, but R.NET looks somewhat promising for this: http://rdotnet.codeplex.com/ Shiny is another potential way to go. You could also take a look at David Firth's CGIwithR: http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/cgiwithr/. --Mark J. Lamias From: Gergely Daróczi gerg...@snowl.net To: jagat.k.sh...@wellsfargo.com Cc: r-help@r-project.org; cha...@bio.ntnu.no Sent: Thursday, November 29, 2012 11:34 AM Subject: Re: [R] Can R be embedded in html? I grab the opportunity to suggest giving a try `pander` package, which holds a forked version of `brew` called `Pandoc.brew`. If you are familiar with `brew`, you could easily create nicely formatted HTML output automatically beside other formats, example: http://rapporter.github.com/pander/#examples But if you want to run those files directly, then RApache is the way to go with `RHandler brew::brew`, although that would end up in a spaghetti code. It's better to keep R and HTML separately in the long run. Best, Gergely On Thu, Nov 29, 2012 at 4:41 PM, jagat.k.sh...@wellsfargo.com wrote: Try R package 'brew'? From its package description Description: brew implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server Pages, and Python's psp module. There is also the rApache project and many other useful links mentioned on R Web Interfaces on the R FAQ page. Jagat -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of chawla Sent: Wednesday, November 28, 2012 9:04 AM To: r-help@r-project.org Subject: [R] Can R be embedded in html? Hi I have previously used PHP script in HTML to connect website with the database and do analysis. Is it also possible to execute R scripts within HTML files? Basically I want to create an application where user can input data such as gene list and their expression values, which can be processed by R and result be displayed or made available for download. If there is some guide on how to do this please give the link. Thanks Konika __ 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. [[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] RGL plot : cex and zlim arguments do not work
On 29/11/2012 1:34 PM, Stephane Chantepie wrote: Hi Ducan and others, I am sorry for this such late reply but I did not see that I had a reply... I have not solved the problem text3d(1:3, 1:3, 1:3, LETTERS[1:3], cex=1:3) does not work for me It works for me. Perhaps if you explained what does not work means, I could help. Duncan Murdoch Maybe it is related to my material, I am on linux debian Sys.info() sysname Linux release 2.6.32-5-amd64 packages: rgl_0.92.892 misc3d_0.8-3 2012/9/25 Duncan Murdoch murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.com On 25/09/2012 11:07 AM, Stephane Chantepie wrote: Dear all, I have a quiet simple problem (shared by a collegue) but no solution at yet. The arguments I use in bbox3d or text3d do not have any effect on the graph. I need to use 'cex' and 'zlim' but It does not work. Maybe my problem could appear trivial but I have spent a lot of time on that. If you have a solution, please let me know! You need to provide an example of what you are trying. cex works for me: text3d(1:3, 1:3, 1:3, LETTERS[1:3], cex=1:3) zlim makes no sense for text3d. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] knitr error with Lyx
That is very helpful! Just to continue debugging, can you save the two versions of the tex files produced from LyX with different versions of R and do a diff on them? It sounds like something has changed from R 2.15.0 to 2.15.2. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Thu, Nov 29, 2012 at 1:26 PM, Mark Lamias mlam...@yahoo.com wrote: Thanks, Yihui! Luckily I kept R-2.15.0 and left it untouched (so I can continue to use that for now). If it helps any, I was able to go back into Lyx and change the path to point to R-2.15.0 and I also changed the windows path environment variable to point to the old version. After doing this, LyX worked fine with no problem on the code below. Changing the paths back to the new version R-2.15.2, generates the error below. If anyone else has any idea how to resolve this, either through R or a Lyx/LaTeX fix, I'd be all ears. Thanks, again for your response, Yihui! Sincerely yours, Mark J. Lamias __ 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] RGL plot : cex and zlim arguments do not work
yes sorry, When we use this function text3d(1:3, 1:3, 1:3, LETTERS[1:3], cex=1:3) we expect the letters to have different size (increase from 1 to 3). But when I try this code , all the letter have the same size. This problem (to not be able to resize character) occurs with diiferent the text function like mtext3d and axe3d. It looks like cex argument do not have any effect on function which can use it. I hope that it is more clear stephane 2012/11/29 Duncan Murdoch murdoch.dun...@gmail.com On 29/11/2012 1:34 PM, Stephane Chantepie wrote: Hi Ducan and others, I am sorry for this such late reply but I did not see that I had a reply... I have not solved the problem text3d(1:3, 1:3, 1:3, LETTERS[1:3], cex=1:3) does not work for me It works for me. Perhaps if you explained what does not work means, I could help. Duncan Murdoch Maybe it is related to my material, I am on linux debian Sys.info() sysname Linuxrelease 2.6.32-5-amd64 packages: rgl_0.92.892 misc3d_0.8-3 2012/9/25 Duncan Murdoch murdoch.dun...@gmail.com mailto: murdoch.duncan@gmail.**com murdoch.dun...@gmail.com On 25/09/2012 11:07 AM, Stephane Chantepie wrote: Dear all, I have a quiet simple problem (shared by a collegue) but no solution at yet. The arguments I use in bbox3d or text3d do not have any effect on the graph. I need to use 'cex' and 'zlim' but It does not work. Maybe my problem could appear trivial but I have spent a lot of time on that. If you have a solution, please let me know! You need to provide an example of what you are trying. cex works for me: text3d(1:3, 1:3, 1:3, LETTERS[1:3], cex=1:3) zlim makes no sense for text3d. Duncan Murdoch [[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] Weight matrix in linear regression
The gls function in the nlme package is one approach. If you know the covariance matrix exactly (it is just numerical with nothing that needs to be estimated) then you can also take the Cholesky decomposition of the inverse of the covariance matrix (or other square root method) and multiply the x matrix and y vector by this root, then do ordinary least squares. Another possibility is generalized estimating equations (gee) which I think are implemented in a few different packages. On Wed, Nov 28, 2012 at 4:03 PM, Emese Vágó vagoem...@hotmail.com wrote: Hi all, I would like to do a weighted linear regression, when the error of the dependent variable is correlated. So I have a weighting (covariance) matrix instead of a vector. As I understood the weights argument in the lm function should be a vector and not a matrix. Can anyone suggest me a function (package) which would do the job? Thanks a lot! Emese [[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 [[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] Read in alphanumeric column without decimals
All - How can I read in a column of alphanumeric values without including .0 on the numeric values? Original column: TeamLeaderID 258 342 316 U8 331 279 D1 116 235 296 ... [truncated] leaders = read.xlsx2('FILE', sheetIndex = 1, header = T) Column after it's been read in: leaders$TeamLeaderID 258.0 342.0 316.0 U8 331.0 279.0 D1 116.0 235.0 296.0 ... [truncated] If I try as.numeric(leaders$TeamLeaderID), everything gets converted: leaders$TeamLeaderID 11 27 19 54 23 13 28 2 8 15 ... [truncated] as.character() and as.vector() leave the .0 in place. These data are being used to merge two files, one whose data$TeamLeaderID is identical to the original column of values above. When I try to merge the dataframes by TeamLeaderID, R can't match the numbers without decimal to the ones that have decimal points. The alphanumeric TeamLeaderID values merge without a problem. As a result, I get a dataframe filled with the proper values for those TeamLeaderID values that are alphanumeric, but NA values for those whose values are strictly numeric. How can I read in the values without R adding the .0 to the end of the numerals? If there isn't a way, how can I automate the removal of the .0, as I have several 10s of TeamLeaderID values? I'm using 64-bit R v. 2.15.1 on a Windows 7 machine. Thank you - Steven H. Ranney __ 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-pkgs] New package: gRain - gRAphical Independence Networks
I am trying to use your package gRain using your book on graphical models in R to do predictions, I have 38 columns of vectors all factors and built a bayesian network using iamb() function, then I used the following command to make a grpahNEL (However, I have 38 nodes and 106 edges) using BN-iamb(data1) BN.gr-as(amat(BN),graphNEL) Then when I am using the following command to make a grain object I got the following errors, any thoughts? Thanks a lot for your help in advance. BN.grain-grain(BN.gr,data=data1) Error in function (classes, fdef, mtable) : unable to find an inherited method for function nodes, for signature graphNEL, missing -- View this message in context: http://r.789695.n4.nabble.com/R-pkgs-New-package-gRain-gRAphical-Independence-Networks-tp846943p4651338.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 Bissection algorithm
I'm trying to make a function witch recieves a function f, a and b, and the error e. When I run the algorithm without labeling it a function and typing the values it works, but when I just try to save it in a function It doesn't ' bug but don't do anything. Here's the code, anyone know whats happening? raiz=function(f,a,b,e){ repeat{ if(i50){break} if(abs(a-b)e){m=(a+b)/2 raiz1=m} if(abs(a-b)e){ m=(a+b)/2 af=f(a) if((af*f(m))0){a=m} if((af*f(m))0){b=m}} i=i+1}} -- View this message in context: http://r.789695.n4.nabble.com/Help-in-Bissection-algorithm-tp4651295.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] Coerce rownames to factor for ordering
Hi all, I think this might be an easy one but I cannot think of a way to do this other than what I am currently attempting. I simply want to sort my data frame's rownames by a defined vector so that the plots I generate from that vector are in the desired order Consider the test data below: #Create test data DataToPlot.. - data.frame(Location1 = c(100,200),Location2 = c(200,400)) #Name rowns rownames(DataToPlot..) - c(Fall,Summer) #Attempt to coerce row names to factors rownames(DataToPlot..) - as.factor(rownames(DataToPlot..)) #Attenmpt to sort rownames by defined vector rownames(DataToPlot..)- reorder(as.factor(rownames(DataToPlot..)), new.order = c(Summer,Fall,Winter,Spring)) The rownames do not reorder nor do they remain factors. Perhaps I can just sort these in the plot? Not sure whats easier/possible? barchart(DataToPlot..SeCl , horizontal = FALSE, ylab = Average Weekday Counts, group = colnames(DataToPlot..SeCl ), col = Colors.[rownames(DataToPlot..SeCl)] ) Thanks for any help. Josh -- View this message in context: http://r.789695.n4.nabble.com/Coerce-rownames-to-factor-for-ordering-tp4651330.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
Help Please Hello, I want to find the whole hat matrix not only the hat values. Is there anyway that could be extracted from lm function ?. If not, please suggest something else. Direct computations using chol2inv or solve are not stable if t(X)%*%X has high determinant. In this case lm is still able to produce correct fitted values, hat_value, residuals...etc but direct computations fail to do so. Thus I guess extracting the hat matrix from lm function will be perfect. 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.
Re: [R] bootstrapped cox regression (rms package)
Eric, the output you showed for anova(out) is not correct. anova.rms does not produce such output. Please give us the correct script that obtained those results and let us know if you are overriding the anova command somehow. To your point, make sure that SPSS does not use the bootstrap to obtain a new point estimate of beta but rather uses the original Cox beta coefficients in the test. Frank Eric Claus wrote Hi, I am trying to convert a colleague from using SPSS to R, but am having trouble generating a result that is similar enough to a bootstrapped cox regression analysis that was run in SPSS. I tried unsuccessfully with bootcens, but have had some success with the bootcov function in the rms package, which at least generates confidence intervals similar to what is observed in SPSS. However, the p-values associated with each predictor in the model are not really close in many instances. Here is the code I am using: formula=Surv(months, recidivate) ~ fac1 + fac2 + fac3 + fac4 + fac5 + fac6 + fac7 + fac8 fit=cph(formula, data=temp, x=T, y=T) validate(fit, method=boot, B=, bw=F, type=residual, sls=0.05, aics=0,force=NULL, estimates=TRUE, pr=FALSE) out=bootcov(fit, B=, pr=F, coef.reps=T, loglik=F) for (i in 1:8) { print(quantile(out$boot.Coef[,i], c(.025, .975))) } anova(out) variable low CI high CI p-value fac1 -8.919692 20.800878 .5917 fac2 -8.683579 3.091100 .6381 fac3 -1.848428 2.193492 .9312 fac4 -0.17575426 0.08333277 .8246 fac5 -3.1488578 0.5166171 .2946 fac6 -0.03621405 0.07241772 .5600 fac7 -0.62847922 0.08566296 .3433 fac8 -0.01553286 0.20909384 .5756 The results from SPSS I am trying to match (or come close to matching) are the following: variable low CI high CI p-value fac1 -8.474 20.020 .456 fac2 -8.206 3.093 .524 fac3 -1.829 2.087 .900 fac4 -.173 .083 .749 fac5 -2.945 .450 .143 fac6 -.035 .070 .306 fac7 -.626 .092 .189 fac8 -.017 .203 .247 Sorry if this is a really basic question. I have searched for several hours for an explanation, but cannot find anything that explains why the p-values would be different despite similar confidence intervals. Thanks in advance, Eric [[alternative HTML version deleted]] __ R-help@ 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/bootstrapped-cox-regression-rms-package-tp4651306p4651344.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] deleting data of a given date range.
Hi, You haven't given any example dataset. So,not sure about the format of the date column. set.seed(5) dat1-data.frame(Date1=c(10/25/2009,11/25/2009,12/25/2009,5/10/2010,8/10/2010,9/25/2011,11/28/2011,5/3/2012),col2=sample(1:15,8,replace=TRUE)) dat1$Date1-as.Date(dat1$Date1,format=%m/%d/%Y) #change your date column format if it is not matching to this example. dat2-dat1[format(dat1$Date1,%Y)!=2009,] dat2 # Date1 col2 #4 2010-05-10 5 #5 2010-08-10 2 #6 2011-09-25 11 #7 2011-11-28 8 #8 2012-05-03 13 A.K. - Original Message - From: siddanth911 siddanth.srivast...@mu-sigma.com To: r-help@r-project.org Cc: Sent: Thursday, November 29, 2012 6:10 AM Subject: [R] deleting data of a given date range. hey, I have a huge dataset with over 30 rows which contains data about something from 2009-2012. does anyone know how i can delete all the rows which contain data from 2009 and only have data from 2010-2012??? is there a particular function i can use on the date column so that all data from 2009 can be deleted??? -- View this message in context: http://r.789695.n4.nabble.com/deleting-data-of-a-given-date-range-tp4651272.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] googleVis plot and knitr/sweave
Dear R users. I'm currently making a report with knitr (RStudio) where I would like to plot a googleVis map. However, the map generated is an HTML file which I don't know how to integrate it in my report. So my question is how to include a map generated with googleVis in a PDF created with knitr/sweave. Regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/googleVis-plot-and-knitr-sweave-tp4651341.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] Help in Bissection algorithm
On 29-11-2012, at 16:18, finehko wrote: I'm trying to make a function witch recieves a function f, a and b, and the error e. When I run the algorithm without labeling it a function and typing the values it works, but when I just try to save it in a function It doesn't ' bug but don't do anything. I don't understand what you mean with this: doesn't ' bug but don't do anything Here's the code, anyone know whats happening? raiz=function(f,a,b,e){ repeat{ if(i50){break} if(abs(a-b)e){m=(a+b)/2 raiz1=m} if(abs(a-b)e){ m=(a+b)/2 af=f(a) if((af*f(m))0){a=m} if((af*f(m))0){b=m}} i=i+1}} Initialize i before starting the repeat loop. i - 1 Berend __ 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 Bissection algorithm
Hello, Actually, it would throw an error, you forgot to assign 'i'. And in the end your function didn't have a return value. I've edited and simplified it a bit. (And what to do if abs(a - b) == e ? The second condition was deleted.) raiz - function(f,a,b,e){ i - 0 repeat{ if(i 50) break m - (a + b)/2 if(abs(a-b) e) break af - f(a) if(af*f(m) 0) a - m if(af*f(m) 0) b - m i=i+1 } #raiz1 - m # not needed m } f - function(x) x^2 - 2 raiz(f, 0, 2, 1e-5) [1] 1.414211 Hope this helps, Rui Barradas Em 29-11-2012 15:18, finehko escreveu: I'm trying to make a function witch recieves a function f, a and b, and the error e. When I run the algorithm without labeling it a function and typing the values it works, but when I just try to save it in a function It doesn't ' bug but don't do anything. Here's the code, anyone know whats happening? raiz=function(f,a,b,e){ repeat{ if(i50){break} if(abs(a-b)e){m=(a+b)/2 raiz1=m} if(abs(a-b)e){ m=(a+b)/2 af=f(a) if((af*f(m))0){a=m} if((af*f(m))0){b=m}} i=i+1}} -- View this message in context: http://r.789695.n4.nabble.com/Help-in-Bissection-algorithm-tp4651295.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] Help in Bissection algorithm
And have the function return a value. All values set in the function will be destroyed when the function is done - you must return something and the caller must assign the return value to a variable if you want to keep it. E.g., raiz function (f, a, b, e) { i - 0 repeat { if (i 50) { break } if (abs(a - b) e) { m = (a + b)/2 raiz1 = m } if (abs(a - b) e) { m = (a + b)/2 af = f(a) if ((af * f(m)) 0) { a = m } if ((af * f(m)) 0) { b = m } } i = i + 1 } c(a, b) # bounds on estimate of root } z - raiz(function(x)x^4 - 3, -2, -1, 1e-10) z [1] -1.316074 -1.316074 z^4 - 3 [1] 7.566836e-12 -5.231717e-10 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Berend Hasselman Sent: Thursday, November 29, 2012 12:13 PM To: finehko Cc: r-help@r-project.org Subject: Re: [R] Help in Bissection algorithm On 29-11-2012, at 16:18, finehko wrote: I'm trying to make a function witch recieves a function f, a and b, and the error e. When I run the algorithm without labeling it a function and typing the values it works, but when I just try to save it in a function It doesn't ' bug but don't do anything. I don't understand what you mean with this: doesn't ' bug but don't do anything Here's the code, anyone know whats happening? raiz=function(f,a,b,e){ repeat{ if(i50){break} if(abs(a-b)e){m=(a+b)/2 raiz1=m} if(abs(a-b)e){ m=(a+b)/2 af=f(a) if((af*f(m))0){a=m} if((af*f(m))0){b=m}} i=i+1}} Initialize i before starting the repeat loop. i - 1 Berend __ 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] Help
Hello, The following document is _not_ about lm(), it's about creating packages but it includes an example that might answer to what you want, a simple lm() substitute. (It uses the QR decomposition, not Cholesky) http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf Hope this helps, Rui Barradas Em 29-11-2012 19:58, Mohammad Ahmed escreveu: Help Please Hello, I want to find the whole hat matrix not only the hat values. Is there anyway that could be extracted from lm function ?. If not, please suggest something else. Direct computations using chol2inv or solve are not stable if t(X)%*%X has high determinant. In this case lm is still able to produce correct fitted values, hat_value, residuals...etc but direct computations fail to do so. Thus I guess extracting the hat matrix from lm function will be perfect. 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. [[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] Data Cleaning -New user coming from SAS
Hello, this is my first post. I have a large CSV file where I need to fill in the 1st and 2nd column with a Loan # and Account name that would be found in a line of text : like this: ,,Loan #:,ML-113-07,Account Name:, Quilting Boutique,,, I would like to place the Loan #: ML-113-07 in the first column and the account name quilting boutique in the second column. If possible I would also like to copy these details all the way down until the end of the record. But I would just be happy to know the best way to script the conditional logic that says something like if column 3 = Loan # then Column 1 eq Column 4 and Column 2 eq column 6. Here is a snap shot of the CSV file I am working with. Thanks Loan #,Account Name,Date,Action,Amount,Disbursed,Capitalized,Interest,Fees,Insurance,Principal,Interest,Fees,Insurance,Writeoff,Recovery,Balance Page #: 11 ,,Date,Action,Amount,Disbursed,Capitalized,Interest,Fees,Insurance,Principal,Interest,Fees,Insurance,Writeoff,Recovery,Balance ,,Loan #:,ML-123-07,Account Name:, Quilting Shop,,, ,,11/30/2009,Interest,2.36,0,0,2.36,0,0,0,0,0,0,0,0,1767.76 ,,12/24/2009,Payment: Regular,161,0,0,11.33,0,0,147.31,13.69,0,0,0,0,1620.45 ,,12/31/2009,Interest,3.03,0,0,3.03,0,0,0,0,0,0,0,0,1620.45 ,,01/26/2010,Fee: Late,10,0,0,0,10,0,0,0,0,0,0,0,1620.45 ,,01/31/2010,Interest,13.42,0,0,13.42,0,0,0,0,0,0,0,0,1620.45 ,,02/09/2010,Payment: Regular,180,0,0,3.9,0,0,149.65,20.35,10,0,0,0,1470.8 ,,02/25/2010,Payment: Regular,170,0,0,6.29,0,0,163.71,6.29,0,0,0,0,1307.09 ,,02/28/2010,Interest,1.05,0,0,1.05,0,0,0,0,0,0,0,0,1307.09 ,,03/25/2010,Payment: Regular,180,0,0,8.73,0,0,170.22,9.78,0,0,0,0,1136.87 ,,03/31/2010,Interest,1.82,0,0,1.82,0,0,0,0,0,0,0,0,1136.87 ,,04/26/2010,Fee: Late,10,0,0,0,10,0,0,0,0,0,0,0,1136.87 ,,04/26/2010,Payment: Regular,165,0,0,7.9,0,0,145.28,9.72,10,0,0,0,991.59 ,,04/30/2010,Interest,1.06,0,0,1.06,0,0,0,0,0,0,0,0,991.59 ,,05/27/2010,Payment: Regular,999.8,0,0,7.15,0,0,991.59,8.21,0,0,0,0,0 ,,,Loan Totals,,5000,0,795.58,172,0,5000,795.58,172,0,0,0,0 Page #: 12 ,,Date,Action,Amount,Disbursed,Capitalized,Interest,Fees,Insurance,Principal,Interest,Fees,Insurance,Writeoff,Recovery,Balance ,,Loan #:,ML-124-07,Account Name:,Tata Bird Farm,,, ,,10/26/2007,Commitment,5000,0,0,0,0,0,0,0,0,0,0,0,0 ,,10/26/2007,Advance: Principal,5000,5000,0,0,0,0,0,0,0,0,0,0,5000 ,,10/26/2007,Fee: Admin,50,0,0,0,50,0,0,0,0,0,0,0,5000 ,,10/26/2007,Payment: Customized,50,0,0,0,0,0,0,0,50,0,0,0,5000 -- View this message in context: http://r.789695.n4.nabble.com/Data-Cleaning-New-user-coming-from-SAS-tp4651348.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] Analysis of Variance
Hi, I am encountering a difficulty I don't understand. Be patient, I'm very new to analysis of variance. If I load this data: example12_7=read.table(http://msemac.redwoods.edu/~darnold/math15/data/chapter12/example12_7.dat,header=TRUE) The run the oneway.test: oneway.test(time~drug,data=example12_7,var.equal=TRUE) I get these results: data: time and drug F = 4.1881, num df = 2, denom df = 16, p-value = 0.03445 Now, I've done the problem by hand and this result agrees with my calculations. Now I try aov and get these results: res1 - aov(time~drug,data=example12_7) summary(res1) Df Sum Sq Mean Sq F value Pr(F) drug 1 7.96 7.964 2.417 0.138 Residuals 17 56.01 3.294 Note these do not agree with above. However, if I enter the data by hand: Drug1=c(7.3,8.2,10.1,6.0,9.5) Drug2=c(7.1,10.6,11.2,9.0,8.5,10.9,7.8) Drug3=c(5.8,6.5,8.8,4.9,7.9,8.5,5.2) boxplot(Drug1,Drug2,Drug3) Then create a dataframe: d=stack(list(Drug1=Drug1,Drug2=Drug2,Drug3=Drug3)) And run aov again: res=aov(values~ind,data=d) summary(res) I get these results: Df Sum Sq Mean Sq F value Pr(F) ind 2 21.98 10.991 4.188 0.0345 * Residuals 16 41.99 2.624 Which completely agree with my calculations. What's going on? Thanks. D. -- View this message in context: http://r.789695.n4.nabble.com/Analysis-of-Variance-tp4651352.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] googleVis plot and knitr/sweave
I'm not aware of the possibility of embedding google vis in PDF: https://developers.google.com/chart/interactive/docs/gallery I do not think everything has to live in PDF, otherwise what is the point of HTML/JS and web browsers? Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Thu, Nov 29, 2012 at 1:53 PM, Filoche pmassico...@hotmail.com wrote: Dear R users. I'm currently making a report with knitr (RStudio) where I would like to plot a googleVis map. However, the map generated is an HTML file which I don't know how to integrate it in my report. So my question is how to include a map generated with googleVis in a PDF created with knitr/sweave. Regards, Phil __ 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] Weight matrix in linear regression
Hello, is there a way to compute multilevel (3-stage) regression using weights matrix (on different levels, just like in HLM) in R ? The nlme package doesn't seem to get the job done. Do you have any suggestions ? I _really_ don't want to use HLM to do this. Best, MikoÅaj Hnatiuk 2012/11/29 Greg Snow 538...@gmail.com The gls function in the nlme package is one approach. If you know the covariance matrix exactly (it is just numerical with nothing that needs to be estimated) then you can also take the Cholesky decomposition of the inverse of the covariance matrix (or other square root method) and multiply the x matrix and y vector by this root, then do ordinary least squares. Another possibility is generalized estimating equations (gee) which I think are implemented in a few different packages. On Wed, Nov 28, 2012 at 4:03 PM, Emese Vágó vagoem...@hotmail.com wrote: Hi all, I would like to do a weighted linear regression, when the error of the dependent variable is correlated. So I have a weighting (covariance) matrix instead of a vector. As I understood the âweightsâ argument in the lm function should be a vector and not a matrix. Can anyone suggest me a function (package) which would do the job? Thanks a lot! Emese [[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 [[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] libary survival
On Nov 29, 2012, at 5:18 AM, Thiago Luiz Nogueira da Silva wrote: Hello,I would like to know if there is residue analysis after the Cox model and make the adjustment for my random cluster? Is this in 'coxme' or in 'survival'. If in 'survival' then there are residuals functions and when I run the generic 'residuals' function on a coxph fit using the second to last example on the`coxph` help page (whose formula includes a cluster term) I get no errors. But you said a 'random cluster', so is this supposed to be a coxme model? A year and a half ago Terry Therneau was observed on this list to write[1]: Residuals methods for coxme would be an important addition and is on my to-do list. (But as my wife would point out, so is a bathroom remodel and she isn't holding her breath.) (Can one nominate an 18-month old posting for a fortune? This could be the first entry in the 'bathroom humor' genre for fortunes.) I just checked to see if there were a new `residuals.coxme` function in version 2.2-3 but don't see one. -- David Winsemius, MD Alameda, CA, USA [1] http://markmail.org/search/?q=list%3Aorg.r-project.r-help+coxme+residuals#query:list%3Aorg.r-project.r-help%20coxme%20residuals+page:1+mid:eodxspnzjqgopw5m+state:results __ 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] Conditional model in R
On Nov 28, 2012, at 11:32 AM, Kirsten Martin wrote: Hello all, I have a data set where the response variable is the percent cover of a specific plant (represented in cover classes 0,1,2,3,4,5, or 6). This data set has a lot of zeros (plots where the plant was not present). I am trying to model cover class of the plant as a function of both total nitrogen and shrub cover. After quite a bit of research I have come across a conditional approach to modeling data with a lot of zeros (Fletcher et al. 2005, Welsh et al. 1996). In this approach you model the presence/absence data using a logistic regression and then model the presence only data using ordinary (least squares) regression. Just because you have zeroes does not mean a Poisson model for instance might no be a good fit. You are dealing with count data and you really ought to at least attempt to model it using an appropriate distribution. Achim Zeileis has written avery nice tutorial on using R for count data. A google-search with his name and 'count data' will likely get it as the first hit. I have successfully come up with both a logistic model and an ols model with good fits. I am running into trouble combining the two (as outlined in the third step of the Fletcher et al. 2005 paper). Does anyone have any experience or any advice on doing this? How does one come up with an overall model for the data using this approach? You might search on hurdle models. require(sos) findFn(hurdle model) found 43 matches; retrieving 3 pages 2 3 Downloaded 23 links in 8 packages. -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error, R commends cannot show the expected output
On Nov 28, 2012, at 5:43 PM, Jack Bryan wrote: I run You are asked to state which OS and version of R you are using. cars - c(1, 3, 6, 4, 9) plot(cars) When this happens and you add: dev.new() ### Do you then see a plot with: plot(cars)# ??? -- David No graph pops up. Any help will be appreciated. Date: Wed, 28 Nov 2012 12:35:39 +0900 From: kri...@ymail.com To: dtustud...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] error, R commends cannot show the expected output Hello, And what do you get? Regards, Pascal Le 28/11/2012 12:25, Jack Bryan a écrit : Hi, I am working on R 2.15.2 on Win. 7. I am trying to run some simple commends. class(SWX.RET) # SWX.RET is a data file that has been loaded. But, I cannot see the expected output. I have deselected buffered output. Still it does not work. Any help will be appreciated. Thanks [[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. David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in Bissection algorithm
What is 'i'? I don't see it as a parameter? is it something in the global environment that you forgot to pass? On Thu, Nov 29, 2012 at 10:18 AM, finehko j9...@hotmail.com wrote: I'm trying to make a function witch recieves a function f, a and b, and the error e. When I run the algorithm without labeling it a function and typing the values it works, but when I just try to save it in a function It doesn't ' bug but don't do anything. Here's the code, anyone know whats happening? raiz=function(f,a,b,e){ repeat{ if(i50){break} if(abs(a-b)e){m=(a+b)/2 raiz1=m} if(abs(a-b)e){ m=(a+b)/2 af=f(a) if((af*f(m))0){a=m} if((af*f(m))0){b=m}} i=i+1}} -- View this message in context: http://r.789695.n4.nabble.com/Help-in-Bissection-algorithm-tp4651295.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. -- 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.
Re: [R] Analysis of Variance
Hi D, R is taking drug as numeric, you ned indicate to R that drug is a factor: example12_7$drug -factor(example12_7$drug) ej2-aov(time~drug,data=example12_7) summary(ej2) Df Sum Sq Mean Sq F value Pr(F) drug 2 21.98 10.991 4.188 0.0345 * Residuals 16 41.99 2.624 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Regards, Andrés El 29/11/2012, a las 14:39, David Arnold dwarnol...@suddenlink.net escribió: Hi, I am encountering a difficulty I don't understand. Be patient, I'm very new to analysis of variance. If I load this data: example12_7=read.table(http://msemac.redwoods.edu/~darnold/math15/data/chapter12/example12_7.dat,header=TRUE) The run the oneway.test: oneway.test(time~drug,data=example12_7,var.equal=TRUE) I get these results: data: time and drug F = 4.1881, num df = 2, denom df = 16, p-value = 0.03445 Now, I've done the problem by hand and this result agrees with my calculations. Now I try aov and get these results: res1 - aov(time~drug,data=example12_7) summary(res1) Df Sum Sq Mean Sq F value Pr(F) drug 1 7.96 7.964 2.417 0.138 Residuals 17 56.01 3.294 Note these do not agree with above. However, if I enter the data by hand: Drug1=c(7.3,8.2,10.1,6.0,9.5) Drug2=c(7.1,10.6,11.2,9.0,8.5,10.9,7.8) Drug3=c(5.8,6.5,8.8,4.9,7.9,8.5,5.2) boxplot(Drug1,Drug2,Drug3) Then create a dataframe: d=stack(list(Drug1=Drug1,Drug2=Drug2,Drug3=Drug3)) And run aov again: res=aov(values~ind,data=d) summary(res) I get these results: Df Sum Sq Mean Sq F value Pr(F) ind 2 21.98 10.991 4.188 0.0345 * Residuals 16 41.99 2.624 Which completely agree with my calculations. What's going on? Thanks. D. -- View this message in context: http://r.789695.n4.nabble.com/Analysis-of-Variance-tp4651352.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. [[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] Read in alphanumeric column without decimals
Your problem is the the data read in from the spreadsheet is probably a 'factor' since it has a non-numeric in the column. To change it to number you have to do the following as.numeric(as.character(yourdata$TeamLeaderID)) What you as seeing with just the call to as.numeric is the value of the 'factor', not the value of the number. On Thu, Nov 29, 2012 at 2:53 PM, Steven Ranney steven.ran...@gmail.com wrote: All - How can I read in a column of alphanumeric values without including .0 on the numeric values? Original column: TeamLeaderID 258 342 316 U8 331 279 D1 116 235 296 ... [truncated] leaders = read.xlsx2('FILE', sheetIndex = 1, header = T) Column after it's been read in: leaders$TeamLeaderID 258.0 342.0 316.0 U8 331.0 279.0 D1 116.0 235.0 296.0 ... [truncated] If I try as.numeric(leaders$TeamLeaderID), everything gets converted: leaders$TeamLeaderID 11 27 19 54 23 13 28 2 8 15 ... [truncated] as.character() and as.vector() leave the .0 in place. These data are being used to merge two files, one whose data$TeamLeaderID is identical to the original column of values above. When I try to merge the dataframes by TeamLeaderID, R can't match the numbers without decimal to the ones that have decimal points. The alphanumeric TeamLeaderID values merge without a problem. As a result, I get a dataframe filled with the proper values for those TeamLeaderID values that are alphanumeric, but NA values for those whose values are strictly numeric. How can I read in the values without R adding the .0 to the end of the numerals? If there isn't a way, how can I automate the removal of the .0, as I have several 10s of TeamLeaderID values? I'm using 64-bit R v. 2.15.1 on a Windows 7 machine. Thank you - Steven H. Ranney __ 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.
Re: [R] Read in alphanumeric column without decimals
Thanks for the replies. I hadn't considered changing the original spreadsheet to a table as there are several different analyses using the .xlsx spreadsheet that contains the alphanumeric data, thus requiring an alteration of all of our code. However, the first response did prompt me to try changing the read.xlsx2() statement to read.xlsx(). This worked. I was able to complete the merge successfully without any further issue. I don't understand why read.xlsx2 was causing such an issue when read.xlsx didn't have a problem adding the .0. I would have thought that both read.xlsx2() and read.xlsx() would have brought the data in as a factor. SR Steven H. Ranney On Thu, Nov 29, 2012 at 2:33 PM, jim holtman jholt...@gmail.com wrote: Your problem is the the data read in from the spreadsheet is probably a 'factor' since it has a non-numeric in the column. To change it to number you have to do the following as.numeric(as.character(yourdata$TeamLeaderID)) What you as seeing with just the call to as.numeric is the value of the 'factor', not the value of the number. On Thu, Nov 29, 2012 at 2:53 PM, Steven Ranney steven.ran...@gmail.com wrote: All - How can I read in a column of alphanumeric values without including .0 on the numeric values? Original column: TeamLeaderID 258 342 316 U8 331 279 D1 116 235 296 ... [truncated] leaders = read.xlsx2('FILE', sheetIndex = 1, header = T) Column after it's been read in: leaders$TeamLeaderID 258.0 342.0 316.0 U8 331.0 279.0 D1 116.0 235.0 296.0 ... [truncated] If I try as.numeric(leaders$TeamLeaderID), everything gets converted: leaders$TeamLeaderID 11 27 19 54 23 13 28 2 8 15 ... [truncated] as.character() and as.vector() leave the .0 in place. These data are being used to merge two files, one whose data$TeamLeaderID is identical to the original column of values above. When I try to merge the dataframes by TeamLeaderID, R can't match the numbers without decimal to the ones that have decimal points. The alphanumeric TeamLeaderID values merge without a problem. As a result, I get a dataframe filled with the proper values for those TeamLeaderID values that are alphanumeric, but NA values for those whose values are strictly numeric. How can I read in the values without R adding the .0 to the end of the numerals? If there isn't a way, how can I automate the removal of the .0, as I have several 10s of TeamLeaderID values? I'm using 64-bit R v. 2.15.1 on a Windows 7 machine. Thank you - Steven H. Ranney __ 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] How to subtract the counter i in for loop?
Hi list, I am writing a for loop that looks like this: samples-rep(NA,10) x - rep(c(111, 225), 5) for(i in 1:10){ If(x[i]200){ samples[i] - x[i] }else{ i=i-1 } } The problem is that the returning vector still contains NA, I think the i in else is not getting subtracted. How should I get it to work? Thanks, Mike [[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] Analysis of Variance
HI, Try this: res2-aov(time~factor(drug),data=example12_7) summary(res2) # Df Sum Sq Mean Sq F value Pr(F) #factor(drug) 2 21.98 10.991 4.188 0.0345 * #Residuals 16 41.99 2.624 #--- #Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 A.K. - Original Message - From: David Arnold dwarnol...@suddenlink.net To: r-help@r-project.org Cc: Sent: Thursday, November 29, 2012 3:39 PM Subject: [R] Analysis of Variance Hi, I am encountering a difficulty I don't understand. Be patient, I'm very new to analysis of variance. If I load this data: example12_7=read.table(http://msemac.redwoods.edu/~darnold/math15/data/chapter12/example12_7.dat,header=TRUE) The run the oneway.test: oneway.test(time~drug,data=example12_7,var.equal=TRUE) I get these results: data: time and drug F = 4.1881, num df = 2, denom df = 16, p-value = 0.03445 Now, I've done the problem by hand and this result agrees with my calculations. Now I try aov and get these results: res1 - aov(time~drug,data=example12_7) summary(res1) Df Sum Sq Mean Sq F value Pr(F) drug 1 7.96 7.964 2.417 0.138 Residuals 17 56.01 3.294 Note these do not agree with above. However, if I enter the data by hand: Drug1=c(7.3,8.2,10.1,6.0,9.5) Drug2=c(7.1,10.6,11.2,9.0,8.5,10.9,7.8) Drug3=c(5.8,6.5,8.8,4.9,7.9,8.5,5.2) boxplot(Drug1,Drug2,Drug3) Then create a dataframe: d=stack(list(Drug1=Drug1,Drug2=Drug2,Drug3=Drug3)) And run aov again: res=aov(values~ind,data=d) summary(res) I get these results: Df Sum Sq Mean Sq F value Pr(F) ind 2 21.98 10.991 4.188 0.0345 * Residuals 16 41.99 2.624 Which completely agree with my calculations. What's going on? Thanks. D. -- View this message in context: http://r.789695.n4.nabble.com/Analysis-of-Variance-tp4651352.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] knitr error with Lyx
Hi, Yihui, Attached is an HTML Diff report of the two files. The left pane contains the R-2.15.0 file. Thanks. --Mark From: Yihui Xie x...@yihui.name To: Mark Lamias mlam...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Thursday, November 29, 2012 2:43 PM Subject: Re: [R] knitr error with Lyx That is very helpful! Just to continue debugging, can you save the two versions of the tex files produced from LyX with different versions of R and do a diff on them? It sounds like something has changed from R 2.15.0 to 2.15.2. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Thu, Nov 29, 2012 at 1:26 PM, Mark Lamias mlam...@yahoo.com wrote: Thanks, Yihui! Luckily I kept R-2.15.0 and left it untouched (so I can continue to use that for now). If it helps any, I was able to go back into Lyx and change the path to point to R-2.15.0 and I also changed the windows path environment variable to point to the old version. After doing this, LyX worked fine with no problem on the code below. Changing the paths back to the new version R-2.15.2, generates the error below. If anyone else has any idea how to resolve this, either through R or a Lyx/LaTeX fix, I'd be all ears. Thanks, again for your response, Yihui! Sincerely yours, Mark J. Lamias C:\Users\Mark\Desktop\Test\2.15.0.tex C:\Users\Mark\Desktop\Test\2.15.2.tex \batchmode \batchmode \makeatletter \makeatletter \def\input@path{{C:/Users/Mark/Desktop//}} \def\input@path{{C:/Users/Mark/Desktop//}} \makeatother \makeatother \documentclass{article} \documentclass{article}\usepackage{graphicx, color} \usepackage{graphicx, color} %% maxwidth is the original width if it is less than linewidth %% otherwise use linewidth (to make sure the graphics do not exceed the margin) \makeatletter \def\maxwidth{ % \ifdim\Gin@nat@width\linewidth \linewidth \else \Gin@nat@width \fi } \makeatother \IfFileExists{upquote.sty}{\usepackage{upquote}}{} \definecolor{fgcolor}{rgb}{0.2, 0.2, 0.2} \newcommand{\hlnumber}[1]{\textcolor[rgb]{0,0,0}{#1}}% \newcommand{\hlnumber}[1]{\textcolor[rgb]{0,0,0}{#1}}% \newcommand{\hlfunctioncall}[1]{\textcolor[rgb]{.5,0,.33}{\textbf{#1}}}% \newcommand{\hlfunctioncall}[1]{\textcolor[rgb]{0.501960784 313725,0,0.329411764705882}{\textbf{#1}}}% \newcommand{\hlstring}[1]{\textcolor[rgb]{.6,.6,1}{#1}}% \newcommand{\hlstring}[1]{\textcolor[rgb]{0.6,0.6,1}{#1}}% \newcommand{\hlkeyword}[1]{\textbf{#1}}% \newcommand{\hlkeyword}[1]{\textcolor[rgb]{0,0,0}{\textbf{#1}}}% \newcommand{\hlargument}[1]{\textcolor[rgb]{.69,.25,.02}{#1}}% \newcommand{\hlargument}[1]{\textcolor[rgb]{0.6901960784313 73,0.250980392156863,0.0196078431372549}{#1}}% \newcommand{\hlcomment}[1]{\textcolor[rgb]{.18,.6,.34}{#1}}% \newcommand{\hlcomment}[1]{\textcolor[rgb]{0.18039215686274 5,0.6,0.341176470588235}{#1}}% \newcommand{\hlroxygencomment}[1]{\textcolor[rgb]{.44,.48,.7}{#1}}% \newcommand{\hlroxygencomment}[1]{\textcolor[rgb]{0.4392156 8627451,0.47843137254902,0.701960784313725}{#1}}% \newcommand{\hlformalargs}[1]{\hlargument{#1}}% \newcommand{\hlformalargs}[1]{\textcolor[rgb]{0.69019607843 1373,0.250980392156863,0.0196078431372549}{#1}}% \newcommand{\hleqformalargs}[1]{\hlargument{#1}}% \newcommand{\hleqformalargs}[1]{\textcolor[rgb]{0.690196078 431373,0.250980392156863,0.0196078431372549}{#1}}% \newcommand{\hlassignement}[1]{\textbf{#1}}% \newcommand{\hlassignement}[1]{\textcolor[rgb]{0,0,0}{\textbf{#1}}}% \newcommand{\hlpackage}[1]{\textcolor[rgb]{.59,.71,.145}{#1}}% \newcommand{\hlpackage}[1]{\textcolor[rgb]{0.58823529411764 7,0.709803921568627,0.145098039215686}{#1}}% \newcommand{\hlslot}[1]{\textit{#1}}% \newcommand{\hlslot}[1]{\textit{#1}}% \newcommand{\hlsymbol}[1]{#1}% \newcommand{\hlsymbol}[1]{\textcolor[rgb]{0,0,0}{#1}}% \newcommand{\hlprompt}[1]{\textcolor[rgb]{.5,.5,.5}{#1}}% \newcommand{\hlprompt}[1]{\textcolor[rgb]{0.2,0.2,0.2}{#1}}% \usepackage{color}% \newsavebox{\hlnormalsizeboxclosebrace}% \newsavebox{\hlnormalsizeboxopenbrace}% \newsavebox{\hlnormalsizeboxbackslash}% \newsavebox{\hlnormalsizeboxlessthan}% \newsavebox{\hlnormalsizeboxgreaterthan}% \newsavebox{\hlnormalsizeboxdollar}% \newsavebox{\hlnormalsizeboxunderscore}% \newsavebox{\hlnormalsizeboxand}% \newsavebox{\hlnormalsizeboxhash}% \newsavebox{\hlnormalsizeboxat}% \newsavebox{\hlnormalsizeboxpercent}% \newsavebox{\hlnormalsizeboxhat}% \newsavebox{\hlnormalsizeboxsinglequote}% \newsavebox{\hlnormalsizeboxbacktick}% \setbox\hlnormalsizeboxopenbrace=\hbox{\begin{normalsize}\v erb.{.\end{normalsize}}% \setbox\hlnormalsizeboxclosebrace=\hbox{\begin{normalsize}\
Re: [R] bootstrapped cox regression (rms package)
Hi Frank, Below is the actual output from the anova(out) command. I had copied in the p-values and from the previous output from anova(out) and the confidence intervals from print(quantile(out$boot.Coef[,i], c(.025, .975))) to illustrate that the confidence intervals were similar to SPSS while the p-values were not. Actual output from anova.rms(out): Wald Statistics Response: Surv(months, recidivate) Factor Chi-Square d.f. P fac1 0.27 10.6055 fac2 0.20 10.6514 fac3 0.01 10.9338 fac4 0.05 10.8311 fac5 1.06 10.3036 fac6 0.33 10.5647 fac7 0.81 10.3670 fac8 0.30 10.5832 TOTAL 1.48 80.9930 Regarding your second question, it looks like SPSS is using the original estimate of Cox beta coefficients in the test (i.e. a new point estimate is not generated for the statistical test) Thanks again, Eric -- View this message in context: http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651363.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] instrumental variables regression using ivreg (AER) or tsls (sem)
Dear friends, I am trying to understand and implement instrumental variables regression using R. I found a small (simple) example here which purportedly illustrates the mechanics (using 2-stage least-squares): http://www.r-bloggers.com/a-simple-instrumental-variables-problem/ Basically, here are the R commands (reproducible example) from that site: # -- begin R library(AER) library(lmtest) data(CollegeDistance) cd.d-CollegeDistance simple.ed.1s- lm(education ~ distance,data=cd.d) cd.d$ed.pred- predict(simple.ed.1s) simple.ed.2s- lm(wage ~ urban + gender + ethnicity + unemp + ed.pred , data=cd.d) # -- end R This yields the following summary: summary(simple.ed.2s) Call: lm(formula = wage ~ urban + gender + ethnicity + unemp + ed.pred, data = cd.d) Residuals: Min 1Q Median 3Q Max -3.1692 -0.8294 0.1502 0.8482 3.9537 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -2.053604 1.675314 -1.226 0.2203 urbanyes -0.013588 0.046403 -0.293 0.7697 genderfemale -0.086700 0.036909 -2.349 0.0189 * ethnicityafam -0.566524 0.051686 -10.961 2e-16 *** ethnicityhispanic -0.529088 0.048429 -10.925 2e-16 *** unemp 0.145806 0.006969 20.922 2e-16 *** ed.pred0.774340 0.120372 6.433 1.38e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.263 on 4732 degrees of freedom Multiple R-squared: 0.1175, Adjusted R-squared: 0.1163 F-statistic: 105 on 6 and 4732 DF, p-value: 2.2e-16 Question: Assuming that the above illustration is correct, I was wondering how I could mimic these calculations using the ivreg () in AER or tsls () in sem? Any suggestions? Many thanks in advance, and best wishes, Ranjan -- Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. For those needing to send personal or professional e-mail, please use appropriate addresses. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ 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 subtract the counter i in for loop?
Mike, Based on this example, what do you want samples to look like? It's not clear to me what you're trying to do with i-1 Jean C W tmrs...@gmail.com wrote on 11/29/2012 03:55:12 PM: Hi list, I am writing a for loop that looks like this: samples-rep(NA,10) x - rep(c(111, 225), 5) for(i in 1:10){ If(x[i]200){ samples[i] - x[i] }else{ i=i-1 } } The problem is that the returning vector still contains NA, I think the i in else is not getting subtracted. How should I get it to work? Thanks, Mike [[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 subtract the counter i in for loop?
Use a while loop instead of a for loop. I don't think what you have coded makes any sense, but fighting the for loop over control of the indexing variable is a recipe for failure. --- 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. C W tmrs...@gmail.com wrote: Hi list, I am writing a for loop that looks like this: samples-rep(NA,10) x - rep(c(111, 225), 5) for(i in 1:10){ If(x[i]200){ samples[i] - x[i] }else{ i=i-1 } } The problem is that the returning vector still contains NA, I think the i in else is not getting subtracted. How should I get it to work? Thanks, Mike [[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 subtract the counter i in for loop?
On Nov 29, 2012, at 1:55 PM, C W wrote: Hi list, I am writing a for loop that looks like this: samples-rep(NA,10) x - rep(c(111, 225), 5) for(i in 1:10){ If(x[i]200){ samples[i] - x[i] }else{ i=i-1 If you expected the else clause to assign something to the samples vector, you are mistaken. } } The problem is that the returning vector still contains NA, I think the i in else is not getting subtracted. How should I get it to work? You could start by telling us what you wanted to happen. You can change the index of a for loop inside the body, but it will not back up the process since at the end of the loop the next i will not depend on what you changed it to inside the loop. -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.