[R] Calculation of VCOV using FFT.
Hello there, I need a piece of advice how to calculate the covariance matrix after calculating the fourier coeff with FFT or the spectral density using R. Thank you beforehand. Regards, Chuse. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 adjust the output
Hi R-users,  I have this code below and I understand the error message but do not know how to correct it. My question is how do I get rid of âwith absolute error 7.5e-06â attach to value of cdf so that I can carry out the calculation.  integrand - function(z) { alp - 2.0165  rho - 0.868  # simplified expressions  a     - alp-0.5  c1    - sqrt(pi)/(gamma(alp)*(1-rho)^alp)  c2    - sqrt(rho)/(1-rho)  t1    - exp(-z/(1-rho))  t2    - (z/(2*c2))^a  bes1  - besselI(z*c2,a)  t1bes1 - t1*bes1  c1*t1bes1*t2 }  z1 - 20 cdf - integrate(integrand, lower = 0, upper = z1,abs.tol = FALSE) r  - runif(1)  ## Newton iteration z2 - z1 - (cdf - r)/integrand(z1)  Output  z1 - 20  cdf - integrate(integrand, lower = 0, upper = z1)  r  - runif(1)  z2 - z1 - (cdf - r)/integrand(z1) Error in cdf - r : non-numeric argument to binary operator  source(.trPaths[5], echo=TRUE, max.deparse.length=1)  cdf 0.9996004 with absolute error 7.5e-06  Thank you so much for any help given. [[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] useGeneric and useMethod
hi all, I would like to know what the difference between creating a function using useGeneric and useMethod I'm new to this and would like to know where there is a good documentation about creating my own functions THX, Assa -- Assa Yeroslaviz Kockelsberg 22 51371 Leverkusen Sent from Dusseldorf, NW, Germany [[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] append something to an xls file
Hi everyone, I run into this problem and hope somebody can help. Thank you in advance. I have an excel file with the first column being a list of names. What I want is to add values that I compute for each person to the right of the corresponding names. Can someone help me with this? Thanks. Best, Zhongyi [[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] lmer
Does lmer do three-level mixed-effects models? What forms of outcome variables can it handle (continuous, survival, binary)? I'd appreciate any help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 R on USB-drive
Lauri Nikkinen wrote: Hi, I installed R on USB-drive, but when I run Rgui.exe from bin folder, I get this error: ... Error in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : 'stats' is not a valid installed package var(1:10) Error: could not find function var So it seems that stats package is not loaded. How can I fix this? Does R know where to find its packages? Can you say .libPaths() and tell us what the output is? And where is the actual install of ...\library\stats? -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] release memory
'gc();' solved my problem. Thanks. -- View this message in context: http://n4.nabble.com/release-memory-tp1473643p1474062.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] For and while in looping
I would like to solve a nonlinear eqn using newton method and here is the code:  library(numDeriv)  fprime - function(z) { alp - 2.0165;  rho - 0.868;  # simplified expressions  a     - alp-0.5  c1    - sqrt(pi)/(gamma(alp)*(1-rho)^alp)  c2    - sqrt(rho)/(1-rho)  t1    - exp(-z/(1-rho))  t2    - (z/(2*c2))^a  bes1  - besselI(z*c2,a)  t1bes1 - t1*bes1  c1*t1bes1*t2 }  ## Newton iteration newton_gam - function(z) { n  - length(z)  r  - runif(n)  tol - 1E-6   for (i in 1:n)  { # numerical intergration to find the cdf    cdf[i] - integrate(fprime, lower = 0, upper = z[i])$val       # Newton method    z[i]   - z[i] - (cdf[i] - r[i])/fprime(z[i])  }  z }  z - c(0.5,10,20,30) newton_gam(z)  Output z - c(0.5,10,20,30)  newton_gam(z) [1] 4.498542e-01 -2.543392e+01 -4.031082e+03 -5.227064e+05  My question is how do I use âforâ and âwhileâ statement so that I can ask it to repeat until it reaches certain tolerance and for a certain number of times. 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] Problem with R on USB-drive
The answer is: .libPaths() [1] E:/R/R-2.10.1/library stats package is found under .../library/ I tried Jim's suggestion and copied R-2.10.1 directory from C:\Program Files\R\ into USB-disk, and everything seems to work fine. Re-istallation did not help. Thanks, -Lauri 2010/2/9, Prof Brian Ripley rip...@stats.ox.ac.uk: On Tue, 9 Feb 2010, Peter Dalgaard wrote: Lauri Nikkinen wrote: Hi, I installed R on USB-drive, but when I run Rgui.exe from bin folder, I get this error: ... Error in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : 'stats' is not a valid installed package var(1:10) Error: could not find function var So it seems that stats package is not loaded. How can I fix this? Does R know where to find its packages? Can you say .libPaths() and tell us what the output is? And where is the actual install of ...\library\stats? It would not have got that far if it could not find 'base'. I think Duncan Murdoch is likely to be correct: this looks like a corrupt install. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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 [[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] interpreting error estimate in SEM
hi, I'm using the sem package, and I want to make sure I'm interpreting the output correctly. Here is an excerpt of my output. When I report the MWD error, should I say that 59% of the variation in MWD is not explained by the model, or that 59% of the variation is explained, or something entirely different. Parameter Estimates Estimate Std Error z value Pr(|z|) NplantRoots 0.462029 0.120803 3.82466 1.3095e-04 plantRoots --- N ... CoError 1.11 0.151850 6.58553 4.5325e-11 Co -- Co carbonateError 1.09 0.156217 6.40142 1.5394e-10 carbonate -- carbonate MWDError0.589788 0.092128 6.40185 1.5351e-10MWD -- MWD Thanks Kathryn __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] evolution of Nelder-Mead process
The optim function has a debug option called trace see the helppage: trace Non-negative integer. If positive, tracing information on the progress of the optimization is produced. Higher values may produce more tracing information: for method L-BFGS-B there are six levels of tracing. (To understand exactly what these do see the source code: higher levels give more detail.) for Nelder-Mead this outputs quite a bit of information. You would only need more if you were debugging optim, as a user if you think visualizing how the damned thing walks will help you understand your problem better, you are probably onto the wrong path. That said, you seem to have data which is defined on a grid, the appropriate method in this case in SANN, not Nelder-Mead. Hope this helps, K --- Nanjing University tel: +8625 8622 8040 (h) +86 13451911944 (m) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] interpreting error estimate in SEM
Dear Kathryn, I assume that MWDError is the error variance associated with MWD. If MWD is a standardized variable (i.e., with a variance of 1) then 59% of its variance is unaccounted for. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Kathryn Barto Sent: February-09-10 6:23 AM To: r-help@r-project.org Subject: [R] interpreting error estimate in SEM hi, I'm using the sem package, and I want to make sure I'm interpreting the output correctly. Here is an excerpt of my output. When I report the MWD error, should I say that 59% of the variation in MWD is not explained by the model, or that 59% of the variation is explained, or something entirely different. Parameter Estimates Estimate Std Error z value Pr(|z|) NplantRoots 0.462029 0.120803 3.82466 1.3095e-04 plantRoots -- - N ... CoError 1.11 0.151850 6.58553 4.5325e-11 Co -- Co carbonateError 1.09 0.156217 6.40142 1.5394e-10 carbonate -- carbonate MWDError0.589788 0.092128 6.40185 1.5351e-10MWD -- MWD Thanks Kathryn __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 adjust the output
On Feb 9, 2010, at 4:27 AM, Roslina Zakaria wrote: Hi R-users, I have this code below and I understand the error message but do not know how to correct it. My question is how do I get rid of “with absolute error 7.5e-06” attach to value of cdf so that I can carry out the calculation. Read the help page. The Value section says that integrate returns a list. Access the list by name of desired component: cdf$value # should get you the desired number. -- David. integrand - function(z) { alp - 2.0165 rho - 0.868 # simplified expressions a - alp-0.5 c1 - sqrt(pi)/(gamma(alp)*(1-rho)^alp) c2 - sqrt(rho)/(1-rho) t1 - exp(-z/(1-rho)) t2 - (z/(2*c2))^a bes1 - besselI(z*c2,a) t1bes1 - t1*bes1 c1*t1bes1*t2 } z1 - 20 cdf - integrate(integrand, lower = 0, upper = z1,abs.tol = FALSE) r - runif(1) ## Newton iteration z2 - z1 - (cdf - r)/integrand(z1) Output z1 - 20 cdf - integrate(integrand, lower = 0, upper = z1) r - runif(1) z2 - z1 - (cdf - r)/integrand(z1) Error in cdf - r : non-numeric argument to binary operator source(.trPaths[5], echo=TRUE, max.deparse.length=1) cdf 0.9996004 with absolute error 7.5e-06 Thank you so much for any help given. [[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 Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem in Installing R Packages
Please see the R for Windows FAQs if you have a problem for downloading packages from the internet via R. Uwe Ligges On 09.02.2010 10:12, mohsin ali wrote: Dear Sir I am facing the following problems in installing packages. Would you please help in this regards? install.packages(ctv) Warning in install.packages(ctv) : 'lib = C:/PROGRA~2/R/R-210~1.1/library' is not writable --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.10 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.10 Warning messages: 1: In open.connection(con, r) : unable to connect to 'cran.r-project.org' on port 80. 2: In getDependencies(pkgs, dependencies, available, lib) : package ‘ctv’ is not available Best Regards _ Hotmail: Powerful Free email with security by Microsoft. [[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] convert R plots into annotated web-graphics
Hi While there is different level of support for SVG in the different browsers, basic SVG (non-animation) does work on all of them (with a plugin for IE). In addition to the 2 SVG packages on CRAN, there is SVGAnnotation at www.omegahat.org/SVGAnnotation and that is quite a bit more powerful. There is a link on that page to some examples that are similar to yours. Imagemaps are a perfectly good way of achieving the interactivity you describe and Barry's imagemap package should make this pretty straightforward. If all you need is to have event handlers for regions, then imagemaps will be fine. And some JavaScript code will allow you to connect the image map events to changing characteristics of the table. The rest of this mail is about richer approaches However, there are other styles of interaction and animation that require working at the level of objects on the plot, i.e. points, lines, text, etc. When we have these objects at rendering time rather than pixels and regions, we can, e.g., change the color of a point, changing its appearance (color or size), hide or move a point, etc. You need this to do linked plots, for example, i.e. where we mouse over a point in one plot or the data table and highlight the corresponding observations in other plots. If you want this richer framework, you can generate the plot in R in such a way that it will be displayed in your browser not as a PNG file, but with real objects being created within the rendering. The SVGAnnotation package does this reasonably comprehensively. You can generate a plot in R that will be displayed on the JavaScript canvas. Again, this will create objects and they can then be manipulated by JavaScript event handlers that work on the plot elements and the table. There is a prototype of such an R-JavaScript canvas graphics devices in the RGraphicsDevice package at www.omegahat.org/RGraphicsDevice. Also, there is a beta-level Flash device that works at the object level and allows an R programmer to annotate the resulting plot in either R or ActionScript. (This is at www.omegahat.org/FlashMXML.) There is another Flash graphics device for R at https://r-forge.r-project.org/projects/swfdevice/ but this doesn't work at the object-level (at this point in time, at least). Both the FlashMXML and JavaScript packages rely on the RGraphicsDevice package and that could be fixed up minorily to handle font metric calculations with more accuracy (e.g. using RFreetype). Instead of using an HTML table and modifying it programmatically via CSS properties, etc., you might use a widget. a DataTable widget from the Yahoo UI javascript library. a Flash DataGrid to display the data as an interactive table. As I said, image maps are probably simplest if your needs are reasonably simple. These other approaches allow for potentially richer Web-based graphics. Barry Rowlingson wrote: On Sun, Feb 7, 2010 at 2:35 PM, Rainer Tischler rainer_...@yahoo.de wrote: Dear all, I would like to make a large scatter plot created with R available as an interactive web graphic, in combination with additional text-annotations for each data point in the plot. The idea is to present the text-annotations in an HTML-table and inter-link the data points in the plot with their corresponding entries in the table, i.e. when clicking on a data point in the plot, the corresponding entry in the table should be highlighted or centered and vice-versa, when clicking on a table-entry, the corresponding point in the plot should be highlighted. I have seen that CRAN contains various R-packages for SVG-based output of interactive graphics (with hyperlinks and tool-tip annotations for each data point); however, SVG is not supported by all browsers. Is anybody aware of another solution for this problem (maybe based on image-maps and javascript)? If you have alternative ideas for interlinking tabular annotations with plotted data points, I would appreciate any recommendation/suggestion. (I work with R 2.8.1 on different 32-bit PCs with both Linux and Windows operating systems). My 'imagemaps' package? https://r-forge.r-project.org/projects/imagemap/ Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Hypercube in R
On 08.02.2010 21:36, Andrej Kastrin wrote: Dear all, Does anybody have an idea or suggestion how to construct (plot) 4-dimensional hypercube in R. Maybe the ggobi interface package is of some help? Uwe Ligges Thanks in advance for any pointers. Regards, Andrej __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] linear predictors and survreg function
Hi, I calculated the linear predictors derived from weibull model using ovarian data sets. I calculated the linear predictors as the sum of covariates weighted by the weibull coefficients and compared to the linear predictors generated by survreg function. Why are they different? note that the first element of coefficients vector is intercept was excluded in my calculation. Look forward to your reply, Carol -- data(ovarian) library(survival) survreg.obj = survreg(Surv(ovarian[,1],ovarian[,2])~age +resid.ds +rx +ecog.ps,ovarian, dist = weibull, scale = 1) survreg.obj$linear.predictors [1] 5.298074 5.108976 5.558852 7.584172 7.221841 7.202655 7.019320 6.764081 [9] 6.011550 7.939097 7.174129 8.634805 6.783737 7.261585 8.955989 8.366687 [17] 7.970807 8.489844 8.302639 8.385361 7.553247 4.855690 7.851908 7.235689 [25] 6.616655 7.917497 *** lp = survreg.obj$coefficients[2:5]%*%t(ovarian[,3:6]) lp 1 2 3 4 5 6 7 [1,] -7.484549 -7.673647 -7.223771 -5.198451 -5.560782 -5.579968 -5.763303 8 91011121314 [1,] -6.018542 -6.771073 -4.843526 -5.608495 -4.147818 -5.998886 -5.521038 15161718192021 [1,] -3.826634 -4.415936 -4.811816 -4.292779 -4.479984 -4.397262 -5.229376 2223242526 [1,] -7.926933 -4.930715 -5.546934 -6.165968 -4.865126 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] step and glmer
Is it possible to use the step() function with a glmer() as an object? I obtain the following error message when I try to do it: Error in x$terms : $ operator not defined for this S4 class. I perform the glmer correctly but I can't do the step. Thank you so much. -- View this message in context: http://n4.nabble.com/step-and-glmer-tp1474390p1474390.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] step and glmer
glmer() nor lmer() work with the step function. You have to build your models manually. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Alba Verzonden: dinsdag 9 februari 2010 14:07 Aan: r-help@r-project.org Onderwerp: [R] step and glmer Is it possible to use the step() function with a glmer() as an object? I obtain the following error message when I try to do it: Error in x$terms : $ operator not defined for this S4 class. I perform the glmer correctly but I can't do the step. Thank you so much. -- View this message in context: http://n4.nabble.com/step-and-glmer-tp1474390p1474390.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. Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] contour persp
Further to Uwe's answer: I suspect that you're not telling us the whole story (that's why it's so useful to have reproducible code). Try this: x - y - 1:3 z - outer(x, y) z[1,1] - 1/0 persp(x,y,z) which results in: Error in persp.default(x, y, z) : invalid 'z' limits So, are some your 'NaN's actually 'Inf's? -Peter Ehlers Uwe Ligges wrote: On 07.02.2010 22:46, Andrew Wang wrote: I have this data set that both x y are ordered vectors of length 600 700 respectively; z is a 600 by 700 matrix whose entry z[i,j] is either a missing value (indicated by 'NaN') or a real number between 0 and 1. The contour function contour(x,y,z) gives me a blank picture. I guess the reason is that most of z-entries are missing, only less than 1% are non missing. Question (1) Is there a way that I could manipulate the data or function to have the non-missing values plotted? Also, trying function persp gives me this error message persp(x,y,z) Error in persp.default(x, y, z) : invalid 'z' limits I look at the manual of persp. I guess, the error message comes from its internal call zlim = range(z, na.rm = TRUE) it appears to me that persp can't handle missing value yet its manual states clearly z: a matrix containing the values to be plotted ('NA's are allowed). Note that ‘x’ can be used instead of ‘z’ for convenience. Question (2) Can persp handle missing values in z? if the answer is a sounding yes, how should I do in my case? Works for me: persp(1:2, 1:2, matrix(c(1:3, NA), nrow=2)) Hence you really need to specify an example where it does not work - as the posting guide asks you to do anyway. Uwe Ligges Please help, Thanks! Your frustrated Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] performing the same commands on two different data sets
Hi All, I would like to perform the same set of commands on the two different sets. I would to avoid writing the same set of command twice so I was wondering if there is an smart way to do this. I was thinking to use a loop as follows Data-read.table(file=”data.txt”, header=T, sep=’\t’) D1-Data[,1:30] D2-Data[,30:60] ID-c(“D1”,”D2”) for (i in 1:length(ID)){ data-ID[i] } I can not assign D1 or D2 as data-ID[i]? is there a way to do this? Thanks -- View this message in context: http://n4.nabble.com/performing-the-same-commands-on-two-different-data-sets-tp1474452p1474452.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] Problems installing stats (prcomp) package
Hi, since nearly 2 hours I try to install the stats package which includes the prcomp package for principal component analysis. I can not find the stats package via the R paket-repository. I found the following url (http://finzi.psych.upenn.edu/R/library/stats/) which includes 2 files: stats.rdb and stats.rdx. I downloaded both files and tried to install them via the R installer choosing local packets (binary and source) but both variants failed. Can anyone help? best mentor -- View this message in context: http://n4.nabble.com/Problems-installing-stats-prcomp-package-tp1474341p1474341.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 on R functions
Dear R Experts, I have written a following function :- myfunction- function(servername,dbname,dbtablename){ library(RODBC) channel - odbcDriverConnect(driver=SQL Server;server=servername) initdata- sqlQuery(channel,paste(select * from dbname .. dbtablename)) return(dim(initdata)) } I have written this function which has input parameters like servername ,dbname and dbtable to connect to Ms SQL server 2005 and get data from the table. Now when I run this function using the following command myfunction(01wh155073,test_DB,test_vikrant) The variable initdata should contain all the data. But it does not contain any data and dim(initdata)) is NULL. I dont know how to pass the strings as parameters in the function. Do I have done this correctly? If I run the same commands directly from the command line I get the expected data. library(RODBC) channel - odbcDriverConnect(driver=SQL Server;server=01wh155073) initdata- sqlQuery(channel,paste(select * from test_DB .. test_vikrant)) dim(initdata) Then the initdata contains the data in the table test_vikrant. My question is there a way to write above in a function which contains the above parameters. Please Help me... -- View this message in context: http://n4.nabble.com/Help-on-R-functions-tp1474342p1474342.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] Missing interaction effect in binomial GLMM with lmer
Dear all, I was wondering if anyone could help solve a problem of a missing interaction effect!! I carried out a 2 x 2 factorial experiment to see if eggs from 2 different locations (Origin = 1 or 2) had different hatching success under 2 different incubation schedules (Treat = 1 or 2). Six eggs were taken from 10 females (random = Female) at each location and split between the treatments, giving 30 eggs from each location in each treatment. Overall proportions hatching were as follows: Treat 1 2 Origin 1 29/30 5/30 2 29/30 16/30 I made a binomial response in which hatching was a success and not-hatching was a failure, and analysed as a binomial GLMM. I'm particularly interested in the interaction between the two factors. An expression reproducing the raw data is attached at the end of the post in case it is helpful. hatch.frame$success-cbind(hatch.frame$Hatched,hatch.frame$Nothatched) model-lmer(success~Origin*Treat+(1|Female),family=binomial,method=ML,data=hatch.frame) model2-update(model,~.-Origin:Treat) anova(model,model2) Data: Models: model2: success ~ Origin + Treat + (1 | Female) model: success ~ Origin * Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model2 4 94.707 105.857 -43.353 model 5 95.350 109.287 -42.675 1.3572 1 0.244 model3-update(model2,~.-Origin) anova(model2,model3) Data: Models: model3: success ~ Treat + (1 | Female) model2: success ~ Origin + Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model3 3 98.863 107.225 -46.431 model2 4 94.707 105.857 -43.353 6.1558 10.01310 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 model4-update(model2,~.-Treat) anova(model2,model4) Data: Models: model4: success ~ Origin + (1 | Female) model2: success ~ Origin + Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model4 3 155.592 163.954 -74.796 model2 4 94.707 105.857 -43.353 62.885 1 2.191e-15 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 So the model implies that there is a very significant effect of treatment (reduced hatching at treatment 2) with a small effect of origin (improved hatching from origin 2). However the lack of interaction effect implies hatching was better for Origin 2 at both treatments, which looking at the raw values above does not seem to be the case. Identical numbers of eggs hatched from both Origins in Treatment 1, but much more from Origin 2 hatched at Treatment 2. If you divide the analysis by treatments, Origin only has a significant effect on hatching under Treatment 2 and not with Treatment 1 Hot-data.frame(hatch.frame[hatch.frame$Treat==2,]) Cold-data.frame(hatch.frame[hatch.frame$Treat==1,]) #2 model-lmer(success~Origin+(1|Female),family=binomial,method=ML,data=Hot) model2-update(model,~.-Origin) anova(model,model2) Data: Hot Models: model2: incubate ~ (1 | Code) model: incubate ~ Origin + (1 | Code) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model2 2 78.633 82.821 -37.316 model 3 73.697 79.980 -33.848 6.9357 1 0.008449 ** #1 model-lmer(success~Origin+(1|Female),family=binomial,method=ML,data=Cold) model2-update(model,~.-Origin) anova(model,model2) Data: Cold Models: model2: incubate ~ (1 | Code) model: incubate ~ Origin + (1 | Code) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model2 2 21.5086 25.6973 -8.7543 model 3 23.3472 29.6302 -8.6736 0.1615 1 0.6878 So I can't understand where the interaction effect has gone in the full model?! I get the same result in a binomial GLM, without the random effect of Female i.e. a small effect of origin but no interaction with treatment. I'm sure I must be missing something here so I would be very grateful to anyone who can point out my mistakes. I've read previous R Help posts that suggest binomial GLM(M) can create problems when estimated probabilities are close to 0 or 1. In Treatment 1 hatching probability was 0.97 for both Origins, so could this be the source of the problem? Thanks for your help Sam Weber University of Exeter Centre for Ecology and Conservation Tremough Campus Penryn Cornwall TR10 9EZ UK hatch.frame - structure(list(Female = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L,
[R] transparent concentric circles
I have a data set which I would like to plot as a set of concentric circles. The data represent a count of the number of characteristics shared by various elements - an example would look like this: 1 100 2 75 3 50 4 25 I.e. all four sets share 25 characteristics, three of them share 50 characteristics, and so on. I would like to plot these as concentric circles, with the circle size preferentially being proportional to the size of the number of elements (this is not a must, however). I would also like the colors of the circles to become stronger/deeper as we progress to the innermost circle (which would be the one containing the number of characteristics shared by all four). Can somebody point me to what I can use to do this? Thanks! Karin -- Karin Lagesen, PhD __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 ggplot2 legend text left justify
Hi Paul, That's a bug in the current version of ggplot. I'm working on update for later this week. Hadley On Mon, Feb 8, 2010 at 5:56 PM, Paul Sutcliffe psutc...@it.uts.edu.au wrote: In ggplot2 how do you justify the legend text ? In the example below the opts(legend.text = theme_text(size = 9,hjust=0)) changes the size of the text OK but it remains right justified. mydata=data.frame(RowID=c(A,B,C),Name=c(long long long long long name,short name ,medium medium name),Speed=c(100,140,120)) mydata RowID Name Speed 1 A long long long long long name 100 2 B short name 140 3 C medium medium name 120 ggplot(mydata, aes(RowID,Speed))+ opts(legend.text = theme_text(size = 9,hjust=0)) + geom_bar() + xlab(Name) + aes(colour = Name) +aes(fill=Name) Thank in advance Paul -- Dr. Paul J Sutcliffe Casual Academic Faculty of Engineering and IT, University of Technology, Sydney (UTS) email: psutc...@it.uts.edu.au http://www-staff.it.uts.edu.au/~psutclif/ CRICOS Provider Code 00099F __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] performing the same commands on two different data sets
Did you try data-ID[[i]] instead of your data-ID[i]? Kjetil On Tue, Feb 9, 2010 at 11:19 AM, kayj kjaj...@yahoo.com wrote: Hi All, I would like to perform the same set of commands on the two different sets. I would to avoid writing the same set of command twice so I was wondering if there is an smart way to do this. I was thinking to use a loop as follows Data-read.table(file=”data.txt”, header=T, sep=’\t’) D1-Data[,1:30] D2-Data[,30:60] ID-c(“D1”,”D2”) for (i in 1:length(ID)){ data-ID[i] } I can not assign D1 or D2 as data-ID[i]? is there a way to do this? Thanks -- View this message in context: http://n4.nabble.com/performing-the-same-commands-on-two-different-data-sets-tp1474452p1474452.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 on R functions
On 09/02/2010 7:10 AM, vikrant wrote: Dear R Experts, I have written a following function :- myfunction- function(servername,dbname,dbtablename){ library(RODBC) channel - odbcDriverConnect(driver=SQL Server;server=servername) initdata- sqlQuery(channel,paste(select * from dbname .. dbtablename)) return(dim(initdata)) } I have written this function which has input parameters like servername ,dbname and dbtable to connect to Ms SQL server 2005 and get data from the table. Now when I run this function using the following command myfunction(01wh155073,test_DB,test_vikrant) The variable initdata should contain all the data. But it does not contain any data and dim(initdata)) is NULL. I dont know how to pass the strings as parameters in the function. Do I have done this correctly? No. driver=SQL Server;server=servername is a literal string. If you want to replace servername with the contents of the servername argument, use paste(driver=SQL Server;server=, servername, sep=) and similarly for your query. Duncan Murdoch If I run the same commands directly from the command line I get the expected data. library(RODBC) channel - odbcDriverConnect(driver=SQL Server;server=01wh155073) initdata- sqlQuery(channel,paste(select * from test_DB .. test_vikrant)) dim(initdata) Then the initdata contains the data in the table test_vikrant. My question is there a way to write above in a function which contains the above parameters. Please Help me... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems installing stats (prcomp) package
The stats package should be installed automatically, and loaded by default when you start R. The search() command will show you which packages are loaded, for example on my computer starting with R --vanilla: search() [1] .GlobalEnvpackage:stats package:graphics [4] package:grDevices package:utils package:datasets [7] package:methods Autoloads package:base The stats package is already loaded. If for some reason this is untrue for you, we need more information, as requested in the posting guide, including OS and R version. Sarah On Tue, Feb 9, 2010 at 7:09 AM, syrvn ment...@gmx.net wrote: Hi, since nearly 2 hours I try to install the stats package which includes the prcomp package for principal component analysis. I can not find the stats package via the R paket-repository. I found the following url (http://finzi.psych.upenn.edu/R/library/stats/) which includes 2 files: stats.rdb and stats.rdx. I downloaded both files and tried to install them via the R installer choosing local packets (binary and source) but both variants failed. Can anyone help? best mentor -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] performing the same commands on two different data sets
You skipped a step: the get() function allows you to use the name of an object to load the object itself. ID-c(“D1”,”D2”) for (i in 1:length(ID)){ data- get(ID[i]) do stuff with data } Alternatively you could write a function that takes the object as its argument. myFunction - function(data) { do stuff with data } myFunction(D1) myFunction(D2) Naming your objects data and Data is a recipe for confusion, though. Sarah On Tue, Feb 9, 2010 at 9:19 AM, kayj kjaj...@yahoo.com wrote: Hi All, I would like to perform the same set of commands on the two different sets. I would to avoid writing the same set of command twice so I was wondering if there is an smart way to do this. I was thinking to use a loop as follows Data-read.table(file=”data.txt”, header=T, sep=’\t’) D1-Data[,1:30] D2-Data[,30:60] ID-c(“D1”,”D2”) for (i in 1:length(ID)){ data-ID[i] } I can not assign D1 or D2 as data-ID[i]? is there a way to do this? Thanks -- View this message in context: http://n4.nabble.com/performing-the-same-commands-on-two-different-data-sets-tp1474452p1474452.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. -- Sarah Goslee http://www.stringpage.com http://www.astronomicum.com http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fast way to determine number of lines in a file
I was looking for a fast line counter as well a while ago and ended up writing a small function in R: countLines() in the R.utils package At least at the time, it was faster than readLines() [for unknown reasons]. It is also more memory efficient. It supports connections. I don't think it beats a system call to 'wc', though. When there will be a faster solution available, it'll be calling that instead. It does not avoid reading the file twice. Perfect - exactly what I was looking for. Thanks! Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 stacked line plot
Hi Liam, Your syntax is a little off. You want: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_area(aes(fill = Type), position = 'stack') Position isn't an aesthetic. Hadley On Sun, Feb 7, 2010 at 10:40 PM, Liam Blanckenberg liam.blanckenb...@gmail.com wrote: Hi all, I have been hunting around for hours trying to figure out how to generate a stacked line chart using ggplot2. This type of chart can be generated in excel 2007 by selecting: Chart type Line Stacked line. I can generate a stacked area chart using the following code: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_area(aes(position = 'stack', fill = Type)) However, when I try and replicate this using the following code for geom_line: p - ggplot(~, aes(x = ~, y = ~, colour = Type)) + geom_line(aes(position = 'stack')) the resulting plot is not stacked - i.e. each 'Type' is plotted at its actual value rather than cumulatively to form a stacked chart... I have poured through Hadley's ggplot2 book (ggplot2: elegant graphics for data analysis), the R help list and also done general google searching but cannot find a way to generate this type of plot. R version: 2.9.2 ggplot2 version: 0.8.5 OS: windows 7 (64-bit). Any suggestions or assistance would be greatly appreciated. Regards, Liam __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] transparent concentric circles
On Tue, Feb 9, 2010 at 2:20 PM, Karin Lagesen kar...@cbs.dtu.dk wrote: I have a data set which I would like to plot as a set of concentric circles. The data represent a count of the number of characteristics shared by various elements - an example would look like this: 1 100 2 75 3 50 4 25 I.e. all four sets share 25 characteristics, three of them share 50 characteristics, and so on. I would like to plot these as concentric circles, with the circle size preferentially being proportional to the size of the number of elements (this is not a must, however). I would also like the colors of the circles to become stronger/deeper as we progress to the innermost circle (which would be the one containing the number of characteristics shared by all four). Can somebody point me to what I can use to do this? help.search(circle)? Have you tried any of those? Specifically: plotrix::draw.circleDraw a circle. shape::filledcircle adds colored circle to a plot grid::grid.circle Draw a Circle - assuming you have those packages loaded... Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] question about nlme...
I am looking for R code to be able to fit a linear-linear piecewise model with person-specific changepoint. I have searched the web, but have not been able to locate any code. Below is my attempt at some code: chgpt = function(a1,a2,a3,gam,wave){ yht=numeric(10) y1=(wave = gam)*(a1+(a2*wave)) y2=(wave gam)*((a1+(a2-a3)*gam)+a3*wave) yhat=y1+y2 return(yht) } nl.dat - nlme(y ~ chgpt(a1,a2,a3,gam,wave)~wave|id, data = ndat, fixed = a1 + a2 + a3 + gam, random = a1 + a2 + a3, start = c(a1=10,a2=5,a3=1,gam=4.5)) summary(n1.dat) I would appreciate any advice on this code or guidance as to where to search for example code to fit this nonlinear mixed effects model. Many thanks, Jeff Harring -- ** Jeffrey R. Harring, Assistant Professor Department of Measurement, Statistics Evaluation (EDMS) 1230 Benjamin Building University of Maryland College Park, MD 20742-1115 Phone: 301.405.3630 Fax:301.314.9245 Email: harr...@umd.edu Web:http://www.education.umd.edu/EDMS/fac/Harring/webpage.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] performing the same commands on two different data sets
thank you all for your help, the get() function worked perfectly. -- View this message in context: http://n4.nabble.com/performing-the-same-commands-on-two-different-data-sets-tp1474452p1474515.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] step and glmer
Thank you for your rapid answer! -- View this message in context: http://n4.nabble.com/step-and-glmer-tp1474390p1474580.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] Interpretation of high order interaction terms.
I have difficulties in interpreting high order interaction terms in high-way ANOVA. According to Introductory Statistics with R by Peter Dalgaard (Section 12.5), The exact definition of the interaction terms and the interpretation of their associated regression coefficients can be elusive. Some peculiar things happen if an interaction term is present but one or more of the main effects are missing. The full details are probably best revealed through experimentation. However, I do want to understand the full details. I have checked a few books, but I haven't found a book that describes high order interactions in a satisfactory way. Besides learning interactions through experimentation, could somebody let me know if there are any detailed documentation on interactions? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] interpreting error estimate in SEM
If it is not standardized, I have the following script that I use to calculate the r^2 for each variable of a model. I do wonder, however, if there is a way to calculate a model-wide r^2 like index. -Jarrett ## #returns the r^2 for endogenous variables and error path coefficients # # Last updated 8/18/08 ## rsquare.sem-function (sem.obj){ output.info-list() for (index in 1:length(sem.obj$S[,1])){ var.name-sem.obj$var.names[index] obs.var-sem.obj$S[index,index] est.var-sem.obj$P[index,index] r.sq-1-(est.var/obs.var) std.error.coef-sqrt(1-r.sq) #if it's 0, or close to (due to rounding error), it's exogenous if(r.sq 1e-10){ output.info-c(output.info, var.name, obs.var, est.var, r.sq, std.error.coef) } } output.matrix-matrix(output.info, ncol=5, byrow=TRUE) colnames(output.matrix)-c(Variable, Observed.Variance, Estimated.Variance, R^2, Standardized.Error.Coefficient) output.matrix } Jarrett Byrnes Postdoctoral Associate, Santa Barbara Coastal LTER Marine Science Institute University of California Santa Barbara Santa Barbara, CA 93106-6150 http://www.lifesci.ucsb.edu/eemb/labs/cardinale/people/byrnes/index.html On Feb 9, 2010, at 4:17 AM, John Fox wrote: Dear Kathryn, I assume that MWDError is the error variance associated with MWD. If MWD is a standardized variable (i.e., with a variance of 1) then 59% of its variance is unaccounted for. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Kathryn Barto Sent: February-09-10 6:23 AM To: r-help@r-project.org Subject: [R] interpreting error estimate in SEM hi, I'm using the sem package, and I want to make sure I'm interpreting the output correctly. Here is an excerpt of my output. When I report the MWD error, should I say that 59% of the variation in MWD is not explained by the model, or that 59% of the variation is explained, or something entirely different. Parameter Estimates Estimate Std Error z value Pr(|z|) NplantRoots 0.462029 0.120803 3.82466 1.3095e-04 plantRoots -- - N ... CoError 1.11 0.151850 6.58553 4.5325e-11 Co -- Co carbonateError 1.09 0.156217 6.40142 1.5394e-10 carbonate -- carbonate MWDError0.589788 0.092128 6.40185 1.5351e-10MWD -- MWD Thanks Kathryn __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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.
[R] Resampling a grid to coarsen its resolution
Dear all, I have a grid (data frame) dataset at 0.5 x 0.5 degrees spatial resolution (720 columns x 360 rows; regular spacing) and wish to coarsen this to a resolution of 2.5 x 2.5 degrees. A simple calculation which takes the mean of a block of points to form the regridded values would do the trick. Values which should be excluded from the calculation are - (unless all points within a block are -, in which case - should be returned as the 'new' cell). How would I go about achieving this in R? Any help or guidelines would be very much appreciated. Many thanks, Steve _ Got a cool Hotmail story? Tell us now __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Formula used to create new plot
Dear list users, I was wondering if there is any way to know, for an open graphical peripheric, the instruction that was used to call it. For example, if I create a plot using plot(runif(10)) is there any way to have the call returned to me? That would be especially usefull to know it there are any log axes, for example thanks t --- Timothée POISOT - Institut des Sciences de l'Evolution Université Montpellier 2, CC 065 Place Eugène Bataillon 34095 Montpellier CEDEX 5 - Phone : (+33)4 67 14 40 61 Fax : (+33)4 67 14 40 61 E-mail : tpoi...@um2.fr Web : http://www.timotheepoisot.fr/ --- [[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] How can I rearange my dataframe
Hello I am recently began to work with R, so I am not so experienced. But anyway I cannot find a clear way to process my dataframe which is a bigger one. It shows similar to this name=c(A,B,C,B,C,C,C,B,C) nicknames=c(A1,B1,C1,B2,C2,C3,C4,B3,C5) value=c(4,5,9,2,7,6,3,6,7) table=data.frame(cbind(name,nickname,value)) table=data.frame(cbind(name,nicknames,value)) table name nicknames value 1 A A1 4 2 B B1 5 3 C C1 9 4 B B2 2 5 C C2 7 6 C C3 6 7 C C4 3 8 B B3 6 9 C C5 7 So I have to rearrange it in the next way: - the first column should contain just unduplicated data, I did this, it is OK and it will look like 1 A 2 B 3 C - the second column should contain different 'nicknames' which correspond to the single A, B or C name nickname value 1 A A1 2 B B1,B2,B3 3 C C1,C2,C3,C4,C5 -the third one should contain the mean value of the numbers which correspond to the same A, B or C 1 A A1 mean(4) 2 B B1,B2,B3 mean(5,2,6) 3 C C1,C2,C3,C4,C5 mean(9,7,6,3,7) I did this using a loop 'for'. to be clear I created tree dataframes which correspond to each of columns, and finally will combine them ulist=which(!duplicated(table$name)) # I extract the list of positions in which I don't have duplications name1=data.frame(table$name[ulist]) # I extract the list of unique names nicknames1=data.frame(row.names(1:length(ulist))) # I create a dataframe of dimension equal to unique list length value1=data.frame(row.names(1:length(ulist))) # I create a dataframe of dimension equal to unique list length for(i in 1:length(ulist)) { position=which(as.character(name1[i,1])==table$name) nicknames1[i,1]=toString(table$nicknames[position]) value1[i,1]=mean(as.numeric(table$value[position])) } fin=cbind(name1,nicknames1,value1) colnames(fin)=c(NAME,NICKNAME,VALUE) fin NAME NICKNAME VALUE 1 A A1 3.00 2 B B1, B2, B3 3.33 3 C C1, C2, C3, C4, C5 5.20 it works successfully. But in general I work with dataframes of high dimensions (tens thousands or more rows). So my loop works too slow (i.e., a dataframe of 2 rows and 3 columns is processed in about 10 minutes). I intend to integrate it into a function, so it is obvious that time will be even longer. If someone can advise me any possibility to modify which I have done or to the way I can do it, please give me a message. King regards to all guys who develop and maintain R sources for such dummies as me Alex Levitchi [[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] Conditional sampling?
Hello all, Here is my solution, in case someone else needs it. I have a dataframe consisting of two columns. col1-factor(c(a,a,b,b,c,c)) col2-factor(c(a,b,c,d,e,f)) somedf-data.frame(col1,col2) somedf col1 col2 1 a d 2 a e 3 b f 4 b g 5 c h 6 c i sample(col1,2,replace=T) [1] b c Levels: a b c Now I want to sample from col2, but I want to restrict a vector I am going to sample from to only those elements that correspond to col1 That is, I want to take a sample from f, g, h, i. Elements corresponding to level a need to be dropped. col1col2 3 b f 4 b g 5 c h 6 c i s - sample(col1,2,replace=T) col2[col1 %in% s] Cheers, Olga __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Nonparametric alternative to LDA
Can anybody recommend a nonparametric alternative to linear discriminant function that may be available as a package in R? Cheers, Rob [[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] Re-execute previous command
Hello All, In bash, to re-execute a command, say, 'gnuplot plot.gnu', one can type !gnu. Is there a similar feature in the R console? For example: plot(g1$mean,g2$mean) . . . Lines, many lines of commands -Here I want to repeat the previous plot command. !plot and plot(+TAB) do not work. This question was asked in this forum back in 2006 but the answer seems to have been lost somewhere in their discussions. This is the thread http://n4.nabble.com/R-command-line-need-intelligent-command-history-recall-td793072.html#a793075 . Can some one comment if there is a way to do it? Thank you, MoonStone -- View this message in context: http://n4.nabble.com/Re-execute-previous-command-tp1474629p1474629.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] Comparing means and trends in short time-series
Dear R-list, I have a statistical problem with the comparison of short time-series, representing densities of fish in different streams. For each stream (6 in total, here below showed only part of the dataset) I have 8 years of density data, as follows: year density stream 1 2000 0.51 stream1 2 2001 0.87 stream1 3 2002 0.68 stream1 4 2003 0.56 stream1 5 2004 0.50 stream1 6 2005 0.51 stream1 7 2006 1.07 stream1 8 2007 1.02 stream1 9 2000 0.23 stream2 10 2001 0.43 stream2 11 2002 0.56 stream2 12 2003 0.59 stream2 13 2004 0.52 stream2 14 2005 0.36 stream2 15 2006 0.28 stream2 16 2007 0.38 stream2 17 2000 0.07 stream3 18 2001 0.06 stream3 . . There is a clear problem of non-indipendence of data, so this seem to preclude a classical ANOVA and subsequent pairwise comparisons. What I would like to test is: are mean densities different among streams from 2000 to 2007? Is it sufficient and appropriate a test of correlation (using rcorr of the library Design, for example) to test if density trends in time are similar among streams? Any help would be greatly appreciated. Simone Simone Vincenzi, PhD Department of Environmental Sciences University of Parma [[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 can I rearange my dataframe
try this: x - read.table(textConnection(name nicknames value + 1 A A1 4 + 2 B B1 5 + 3 C C1 9 + 4 B B2 2 + 5 C C2 7 + 6 C C3 6 + 7 C C4 3 + 8 B B3 6 + 9 C C5 7), header=TRUE) closeAllConnections() result - do.call(rbind, lapply(split(x, x$name), function(.name){ + data.frame(name=.name$name[1], nicknames=paste(.name$nicknames, collapse=','), + mean=mean(.name$value)) + })) result name nicknames mean AA A1 4.00 BB B1,B2,B3 4.33 CC C1,C2,C3,C4,C5 6.40 On Tue, Feb 9, 2010 at 11:24 AM, Alex Levitchi alex.levit...@cbm.fvg.it wrote: Hello I am recently began to work with R, so I am not so experienced. But anyway I cannot find a clear way to process my dataframe which is a bigger one. It shows similar to this name=c(A,B,C,B,C,C,C,B,C) nicknames=c(A1,B1,C1,B2,C2,C3,C4,B3,C5) value=c(4,5,9,2,7,6,3,6,7) table=data.frame(cbind(name,nickname,value)) table=data.frame(cbind(name,nicknames,value)) table name nicknames value 1 A A1 4 2 B B1 5 3 C C1 9 4 B B2 2 5 C C2 7 6 C C3 6 7 C C4 3 8 B B3 6 9 C C5 7 So I have to rearrange it in the next way: - the first column should contain just unduplicated data, I did this, it is OK and it will look like 1 A 2 B 3 C - the second column should contain different 'nicknames' which correspond to the single A, B or C name nickname value 1 A A1 2 B B1,B2,B3 3 C C1,C2,C3,C4,C5 -the third one should contain the mean value of the numbers which correspond to the same A, B or C 1 A A1 mean(4) 2 B B1,B2,B3 mean(5,2,6) 3 C C1,C2,C3,C4,C5 mean(9,7,6,3,7) I did this using a loop 'for'. to be clear I created tree dataframes which correspond to each of columns, and finally will combine them ulist=which(!duplicated(table$name)) # I extract the list of positions in which I don't have duplications name1=data.frame(table$name[ulist]) # I extract the list of unique names nicknames1=data.frame(row.names(1:length(ulist))) # I create a dataframe of dimension equal to unique list length value1=data.frame(row.names(1:length(ulist))) # I create a dataframe of dimension equal to unique list length for(i in 1:length(ulist)) { position=which(as.character(name1[i,1])==table$name) nicknames1[i,1]=toString(table$nicknames[position]) value1[i,1]=mean(as.numeric(table$value[position])) } fin=cbind(name1,nicknames1,value1) colnames(fin)=c(NAME,NICKNAME,VALUE) fin NAME NICKNAME VALUE 1 A A1 3.00 2 B B1, B2, B3 3.33 3 C C1, C2, C3, C4, C5 5.20 it works successfully. But in general I work with dataframes of high dimensions (tens thousands or more rows). So my loop works too slow (i.e., a dataframe of 2 rows and 3 columns is processed in about 10 minutes). I intend to integrate it into a function, so it is obvious that time will be even longer. If someone can advise me any possibility to modify which I have done or to the way I can do it, please give me a message. King regards to all guys who develop and maintain R sources for such dummies as me Alex Levitchi [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How can I rearange my dataframe
On Feb 9, 2010, at 11:24 AM, Alex Levitchi wrote: Hello I am recently began to work with R, so I am not so experienced. But anyway I cannot find a clear way to process my dataframe which is a bigger one. It shows similar to this name=c(A,B,C,B,C,C,C,B,C) nicknames=c(A1,B1,C1,B2,C2,C3,C4,B3,C5) value=c(4,5,9,2,7,6,3,6,7) table=data.frame(cbind(name,nickname,value)) table=data.frame(cbind(name,nicknames,value)) table name nicknames value 1 A A1 4 2 B B1 5 3 C C1 9 4 B B2 2 5 C C2 7 6 C C3 6 7 C C4 3 8 B B3 6 9 C C5 7 So I have to rearrange it in the next way: - the first column should contain just unduplicated data, I did this, it is OK and it will look like 1 A 2 B 3 C - the second column should contain different 'nicknames' which correspond to the single A, B or C name nickname value 1 A A1 2 B B1,B2,B3 3 C C1,C2,C3,C4,C5 Dataframes are not designed to hold irregular length items. Lists are the data structure best suited for this type of data. tapply() is one function useful for colecting elements of one structure based on the contents of another (name): (I renamed your table object table1 to avoid confusion with the table function.) tapply(table1$nicknames, table1$name, list) $A [1] A1 Levels: A1 B1 B2 B3 C1 C2 C3 C4 C5 $B [1] B1 B2 B3 Levels: A1 B1 B2 B3 C1 C2 C3 C4 C5 $C [1] C1 C2 C3 C4 C5 Levels: A1 B1 B2 B3 C1 C2 C3 C4 C5 The process of tabulating has created factor variables which some would see as a good thing, but perhaps was not desired. Since you now have a lis, you can sequentially apply the as.character function to recover only the character vectors: lapply( tapply(table1$nicknames, table1$name, list), as.character) $A [1] A1 $B [1] B1 B2 B3 $C [1] C1 C2 C3 C4 C5 Then I saw the rest of your request, so forget the above and see if this two-liner looks a bit more simple. tcollapse - tapply(table1$nicknames, table1$name, paste, collapse=, ) #gets you the strings separated by commas and spaces. cbind(names(tcollapse), tcollapse, lapply( tapply(table1$nicknames, table1$name, list), length) ) tcollapse A A A1 1 B B B1, B2, B3 3 C C C1, C2, C3, C4, C5 5 You can obviously name them whatever you like. -- David -the third one should contain the mean value of the numbers which correspond to the same A, B or C 1 A A1 mean(4) 2 B B1,B2,B3 mean(5,2,6) 3 C C1,C2,C3,C4,C5 mean(9,7,6,3,7) I did this using a loop 'for'. to be clear I created tree dataframes which correspond to each of columns, and finally will combine them ulist=which(!duplicated(table$name)) # I extract the list of positions in which I don't have duplications name1=data.frame(table$name[ulist]) # I extract the list of unique names nicknames1=data.frame(row.names(1:length(ulist))) # I create a dataframe of dimension equal to unique list length value1=data.frame(row.names(1:length(ulist))) # I create a dataframe of dimension equal to unique list length for(i in 1:length(ulist)) { position=which(as.character(name1[i,1])==table$name) nicknames1[i,1]=toString(table$nicknames[position]) value1[i,1]=mean(as.numeric(table$value[position])) } fin=cbind(name1,nicknames1,value1) colnames(fin)=c(NAME,NICKNAME,VALUE) fin NAME NICKNAME VALUE 1 A A1 3.00 2 B B1, B2, B3 3.33 3 C C1, C2, C3, C4, C5 5.20 it works successfully. But in general I work with dataframes of high dimensions (tens thousands or more rows). So my loop works too slow (i.e., a dataframe of 2 rows and 3 columns is processed in about 10 minutes). I intend to integrate it into a function, so it is obvious that time will be even longer. If someone can advise me any possibility to modify which I have done or to the way I can do it, please give me a message. King regards to all guys who develop and maintain R sources for such dummies as me Alex Levitchi [[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 Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re-execute previous command
On Feb 9, 2010, at 11:21 AM, mnstn wrote: Hello All, In bash, to re-execute a command, say, 'gnuplot plot.gnu', one can type !gnu. Is there a similar feature in the R console? For example: plot(g1$mean,g2$mean) In most system typeing up-arrow will prompt the console to echo the last command (and repeating the process will scroll back through history.) There is also a .Last.value object but I don't know if it will replot. -- David. . . . Lines, many lines of commands -Here I want to repeat the previous plot command. !plot and plot(+TAB) do not work. This question was asked in this forum back in 2006 but the answer seems to have been lost somewhere in their discussions. This is the thread http://n4.nabble.com/R-command-line-need-intelligent-command-history-recall-td793072.html#a793075 . Can some one comment if there is a way to do it? Thank you, MoonStone -- View this message in context: http://n4.nabble.com/Re-execute-previous-command-tp1474629p1474629.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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Missing interaction effect in binomial GLMM with lmer
Hi Sam, Good question. I originally guessed that the simple effect (I know some people on this list don't seem to care for that term, but it's always made sense to me) coefficients were in the same direction, such that the effect if Origin at Treat=hot was significantly different from zero, but not from the effect of Origin at Treat = cold. But a quick look indicated that is not the case: contrasts(hatch.frame$Treat) - contr.treatment(2, base=1) model1-lmer(success~Origin*Treat+(1|Female),family=binomial,REML=TRUE,data=hatch.frame) summary(model1) Generalized linear mixed model fit by the Laplace approximation Formula: success ~ Origin * Treat + (1 | Female) Data: hatch.frame AIC BIC logLik deviance 95.34 109.3 -42.6785.34 Random effects: Groups NameVariance Std.Dev. Female (Intercept) 0.54993 0.74157 Number of obs: 120, groups: Female, 20 Fixed effects: Estimate Std. Error z value Pr(|z|) (Intercept) 3.609227 1.146844 3.147 0.00165 ** Origin2-0.004192 1.606214 -0.003 0.99792 Treat2 -5.401703 1.238911 -4.360 1.3e-05 *** Origin2:Treat2 1.948242 1.697945 1.147 0.25121 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) Orign2 Treat2 Origin2 -0.714 Treat2 -0.889 0.635 Orign2:Trt2 0.649 -0.907 -0.730 contrasts(hatch.frame$Treat) - contr.treatment(2, base=2) model2-lmer(success~Origin*Treat+(1|Female),family=binomial,REML=TRUE,data=hatch.frame) summary(model2) Generalized linear mixed model fit by the Laplace approximation Formula: success ~ Origin * Treat + (1 | Female) Data: hatch.frame AIC BIC logLik deviance 95.34 109.3 -42.6785.34 Random effects: Groups NameVariance Std.Dev. Female (Intercept) 0.54993 0.74157 Number of obs: 120, groups: Female, 20 Fixed effects: Estimate Std. Error z value Pr(|z|) (Intercept) -1.7925 0.5683 -3.154 0.00161 ** Origin2 1.9441 0.7190 2.704 0.00686 ** Treat1 5.4017 1.2389 4.360 1.3e-05 *** Origin2:Treat1 -1.9484 1.6979 -1.148 0.25116 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) Orign2 Treat1 Origin2 -0.790 Treat1 -0.385 0.305 Orign2:Trt1 0.281 -0.336 -0.730 So I'm as stumped as you are. How can the effect of Origin at treat=hot be significantly different from zero, but not significantly different from -0.004? Clearly there is something here I'm not understanding. I'm very curious to know the answer. Best, Ista On Tue, Feb 9, 2010 at 12:22 PM, Weber, Sam sam.we...@exeter.ac.uk wrote: Dear all, I was wondering if anyone could help solve a problem of a missing interaction effect!! I carried out a 2 x 2 factorial experiment to see if eggs from 2 different locations (Origin = 1 or 2) had different hatching success under 2 different incubation schedules (Treat = 1 or 2). Six eggs were taken from 10 females (random = Female) at each location and split between the treatments, giving 30 eggs from each location in each treatment. Overall proportions hatching were as follows: Treat 1 2 Origin 1 29/30 5/30 2 29/30 16/30 I made a binomial response in which hatching was a success and not-hatching was a failure, and analysed as a binomial GLMM. I'm particularly interested in the interaction between the two factors. An expression reproducing the raw data is attached at the end of the post in case it is helpful. hatch.frame$success-cbind(hatch.frame$Hatched,hatch.frame$Nothatched) model-lmer(success~Origin*Treat+(1|Female),family=binomial,method=ML,data=hatch.frame) model2-update(model,~.-Origin:Treat) anova(model,model2) Data: Models: model2: success ~ Origin + Treat + (1 | Female) model: success ~ Origin * Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model2 4 94.707 105.857 -43.353 model 5 95.350 109.287 -42.675 1.3572 1 0.244 model3-update(model2,~.-Origin) anova(model2,model3) Data: Models: model3: success ~ Treat + (1 | Female) model2: success ~ Origin + Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model3 3 98.863 107.225 -46.431 model2 4 94.707 105.857 -43.353 6.1558 1 0.01310 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 model4-update(model2,~.-Treat) anova(model2,model4) Data: Models: model4: success ~ Origin + (1 | Female) model2: success ~ Origin + Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model4 3 155.592 163.954 -74.796 model2 4 94.707 105.857 -43.353 62.885 1 2.191e-15 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 So the model implies that there is a very significant effect of
[R] odfTable: table width and alignment
Dear R and odfWeave users, I am trying to figure out how to control table width and alignment on the page for a table generated by odfTable. Based on reading odfWeave documentation (including formattingOut.odt), here is how I manipulate the styles: st = getStyleDefs() # modify the table style tab = getStyles()$table st[[tab]]$align = center# seems to have no effect st[[tab]]$marginLeft = 2.0 in # seems to have no effect setStyleDefs(st) My table always ends up fully justified (taking all page width). When I check Table Format in the output .odf, Alignment is always Automatic. When doing Column/Optimal Width on the table, the table shrinks but becomes left aligned, not centered. The table style is understood by odfWeave -- here is the output I get after sourcing my style definition file: getStyles()$table [1] RTable1 getStyleDefs()[[getStyles()$table]] $type [1] Table $marginLeft [1] 2.0 in $marginRight [1] 0.05in $marginTop [1] 0.05in $marginBottom [1] 0.05in $align [1] center I am not sure why these style options do not seem to have effect on the output. My specific questions are: (1) How do I get table alignment to work? (2) Is the only way to control table width via setting the margins in the $table style? What am I doing wrong in the above style code? (3) What about column width -- is it possible to automatically size columns to fit the content, like selecting Column/Optimal Width but programmatically via odfWeave? Thank you, Aleksey [[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] The default argument 'envir' of eval()
In ?eval, it says ... If ‘envir’ is not specified, then the default is ‘parent.frame()’ (the environment where the call to ‘eval’ was made). I tried the following example with eval(expr) and eval(expr, parent.frame()) in f(). The results are different, which are not consistent with the help. Could somebody let know whether I misunderstand the help? Or there is something with the help? expr=expression(print(paste('x =', x))) x=0 f=function() { + x=2 + eval(expr) + eval(expr, parent.frame()) + eval(expr, parent.frame(2)) + eval(expr, parent.frame(3)) + } g=function() { + x=1 + f() + } g() [1] x = 2 [1] x = 1 [1] x = 0 [1] x = 0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re-execute previous command
On Feb 9, 2010, at 12:13 PM, David Winsemius wrote: On Feb 9, 2010, at 11:21 AM, mnstn wrote: Hello All, In bash, to re-execute a command, say, 'gnuplot plot.gnu', one can type !gnu. Is there a similar feature in the R console? For example: plot(g1$mean,g2$mean) In most system typeing up-arrow will prompt the console to echo the last command (and repeating the process will scroll back through history.) There is also a .Last.value object but I don't know if it will replot. It will if the plotting function returned a value as do the lattice and ggplot functions, but not if it returns NULL as do the base graphics functions. -- David. . . . Lines, many lines of commands -Here I want to repeat the previous plot command. !plot and plot(+TAB) do not work. This question was asked in this forum back in 2006 but the answer seems to have been lost somewhere in their discussions. This is the thread http://n4.nabble.com/R-command-line-need-intelligent-command-history-recall-td793072.html#a793075 . Can some one comment if there is a way to do it? Thank you, MoonStone -- View this message in context: http://n4.nabble.com/Re-execute-previous-command-tp1474629p1474629.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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Kernel density / weights matrix?
Dear everyone, I'm coding the Horowitz-Spokoiny (2001) test [1], and I would be very grateful or some advice regarding the Kernel density (apologies beforehand if my terminology is not fully correct). I have looked into ksmooth and npreg, but with no success. Given a (n x p) matrix of covariates X, I need to construct the following matrix of Kernel densities or weights: w(x_i, x_j) = K(x_i - x_j) - sum_{k=1}^n K(x_i - x_k) where x_i, x_j, x_k are (1 x p) vectors, and K is a multivariate normal kernel. The resulting weighting matrix W has dimension (n x n). I have looked into npreg, but if I get this correctly, it does not output this weighting matrix. I do need the weighting matrix itself for the test statistic, and not just the kernel regression estimates. I can construct it myself, but I thought I'd ask around before doing so. Best, Stephan [1] Horowitz Joel L. and Spokoiny Vladimir G. (2001): An Adaptive, Rate-Optimal Test of a Parametric Mean-Regression Model against a Nonparametric Alternative. Econometrica, Vol. 69, No. 3 (May, 2001), pp. 599-631 -- --- Stephan Lindner University of Michigan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] The default argument 'envir' of eval()
On 09/02/2010 12:18 PM, bluesky...@gmail.com wrote: In ?eval, it says ... If ‘envir’ is not specified, then the default is ‘parent.frame()’ (the environment where the call to ‘eval’ was made). I tried the following example with eval(expr) and eval(expr, parent.frame()) in f(). The results are different, which are not consistent with the help. Could somebody let know whether I misunderstand the help? Or there is something with the help? The help is correct, you misunderstood it. Default values for arguments are evaluated in the evaluation frame of the function. Explicit arguments are evaluated in the evaluation frame of the caller. parent.frame() has different meanings in those two contexts. Duncan Murdoch expr=expression(print(paste('x =', x))) x=0 f=function() { + x=2 + eval(expr) + eval(expr, parent.frame()) + eval(expr, parent.frame(2)) + eval(expr, parent.frame(3)) + } g=function() { + x=1 + f() + } g() [1] x = 2 [1] x = 1 [1] x = 0 [1] x = 0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bar plot
Hello (this might be a very simple question) My data is as follows (table name is student) YearStudentsPassed 1 2000300 2 2001360 3 2002450 4 2003450 5 2004270 6 2005280 7 2006400 8 2007270 I want to plot a barplot so for this If I use barplot(students) it says Error in barplot.default(students) : 'height' must be a vector or a matrix so I used the following command barplot(StudentsPassed) But this doesnt give me the names for Xaxis, how can I get the names for Xaxis, also how can I get labels for X and Y axis, and tittle, I tried title(main = Year Vs Number of Publications) to get the title but its giving me an error Thanks in advance Sunita I want to -- View this message in context: http://n4.nabble.com/Bar-plot-tp1474748p1474748.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 means and trends in short time-series
Simone Vincenzi-2 wrote: I have a statistical problem with the comparison of short time-series, representing densities of fish in different streams. For each stream (6 in total, here below showed only part of the dataset) I have 8 years of density data, as follows: year density stream 1 2000 0.51 stream1 2 2001 0.87 stream1 Are mean densities different among streams from 2000 to 2007? Is it sufficient and appropriate a test of correlation (using rcorr of the library Design, for example) to test if density trends in time are similar among streams? Have a look at function gls in in package nlme. gls(density~year*stream,) There are some similar examples in the book coming with nlme (chapter 5.4) Dieter -- View this message in context: http://n4.nabble.com/Comparing-means-and-trends-in-short-time-series-tp1474688p1474750.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] question about nlme...
Jeff Harring wrote: I am looking for R code to be able to fit a linear-linear piecewise model with person-specific changepoint. I have searched the web, but have not been able to locate any code. .. I would appreciate any advice on this code or guidance as to where to search for example code to fit this nonlinear mixed effects model. I had good success in fitting piecewise functions with continuous derivatives, e.g. a logistic function with a linear continuation. Things did not work well with nlme when there was a discontinuity. There is an discussion from 2000 right from Douglas Bates' and Mary Lindstrom's mouth for nls and the hockey-stick, so it could be possible to get is to work with good data. http://www.biostat.wustl.edu/archives/html/s-news/2000-04/msg00209.html Also check http://markmail.org/message/6p63i4cxfk6enlp5 Dieter -- View this message in context: http://n4.nabble.com/question-about-nlme-tp1474561p1474765.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] Nonparametric alternative to LDA
Classification trees (rpart package), but know too little about your problem... Best, Andrej On Feb 9, 5:50 pm, Robert Lonsinger rob.lonsin...@gmail.com wrote: Can anybody recommend a nonparametric alternative to linear discriminant function that may be available as a package in R? Cheers, Rob [[alternative HTML version deleted]] __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] model II major axis regression
Hello all; My question is part statistical and part R. I have performed model II major axis regression in R using both the smatr() and lmodel2() packages, but neither offers an option to statistically weight my regression. I have a vector of weights which I would like to apply to each of my regression points (x vs. y), and was hoping that someone out there could provide me with some help on this issue. I have searched on the R help pages and online with no luck. Just to provide context, I am comparing 2 random variables which have been geographically gridded so that each grid point has one x data and one y data point. I would like to weight the regression of x vs. y such that grids with larger geographic area (near the equator) get more weight than those with smaller geographic area (near the poles). My weights are already calculated. Thanks in advance, Dan. -- View this message in context: http://n4.nabble.com/model-II-major-axis-regression-tp1474711p1474711.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] Bar plot
Here is a simple 3-step solution: 1. type ?barplot 2. find the section labelled 'Arguments' 3. carefully read what each argument means/does Voila, problem(s) solved. (It was good to include some data, but not so good to say that title(...) is giving an error. No need to be secretive about the error; just say what it was.) -Peter Ehlers Sunitap22 wrote: Hello (this might be a very simple question) My data is as follows (table name is student) YearStudentsPassed 1 2000300 2 2001360 3 2002450 4 2003450 5 2004270 6 2005280 7 2006400 8 2007270 I want to plot a barplot so for this If I use barplot(students) it says Error in barplot.default(students) : 'height' must be a vector or a matrix so I used the following command barplot(StudentsPassed) But this doesnt give me the names for Xaxis, how can I get the names for Xaxis, also how can I get labels for X and Y axis, and tittle, I tried title(main = Year Vs Number of Publications) to get the title but its giving me an error Thanks in advance Sunita I want to -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Missing interaction effect in binomial GLMM with lmer
You might do better posting this on the R-sig-mixed-models list. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Tuesday, February 09, 2010 9:19 AM To: Weber, Sam Cc: r-help@R-project.org Subject: Re: [R] Missing interaction effect in binomial GLMM with lmer Hi Sam, Good question. I originally guessed that the simple effect (I know some people on this list don't seem to care for that term, but it's always made sense to me) coefficients were in the same direction, such that the effect if Origin at Treat=hot was significantly different from zero, but not from the effect of Origin at Treat = cold. But a quick look indicated that is not the case: contrasts(hatch.frame$Treat) - contr.treatment(2, base=1) model1-lmer(success~Origin*Treat+(1|Female),family=binomial,REML=TRUE,data= hatch.frame) summary(model1) Generalized linear mixed model fit by the Laplace approximation Formula: success ~ Origin * Treat + (1 | Female) Data: hatch.frame AIC BIC logLik deviance 95.34 109.3 -42.6785.34 Random effects: Groups NameVariance Std.Dev. Female (Intercept) 0.54993 0.74157 Number of obs: 120, groups: Female, 20 Fixed effects: Estimate Std. Error z value Pr(|z|) (Intercept) 3.609227 1.146844 3.147 0.00165 ** Origin2-0.004192 1.606214 -0.003 0.99792 Treat2 -5.401703 1.238911 -4.360 1.3e-05 *** Origin2:Treat2 1.948242 1.697945 1.147 0.25121 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Correlation of Fixed Effects: (Intr) Orign2 Treat2 Origin2 -0.714 Treat2 -0.889 0.635 Orign2:Trt2 0.649 -0.907 -0.730 contrasts(hatch.frame$Treat) - contr.treatment(2, base=2) model2-lmer(success~Origin*Treat+(1|Female),family=binomial,REML=TRUE,data= hatch.frame) summary(model2) Generalized linear mixed model fit by the Laplace approximation Formula: success ~ Origin * Treat + (1 | Female) Data: hatch.frame AIC BIC logLik deviance 95.34 109.3 -42.6785.34 Random effects: Groups NameVariance Std.Dev. Female (Intercept) 0.54993 0.74157 Number of obs: 120, groups: Female, 20 Fixed effects: Estimate Std. Error z value Pr(|z|) (Intercept) -1.7925 0.5683 -3.154 0.00161 ** Origin2 1.9441 0.7190 2.704 0.00686 ** Treat1 5.4017 1.2389 4.360 1.3e-05 *** Origin2:Treat1 -1.9484 1.6979 -1.148 0.25116 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Correlation of Fixed Effects: (Intr) Orign2 Treat1 Origin2 -0.790 Treat1 -0.385 0.305 Orign2:Trt1 0.281 -0.336 -0.730 So I'm as stumped as you are. How can the effect of Origin at treat=hot be significantly different from zero, but not significantly different from -0.004? Clearly there is something here I'm not understanding. I'm very curious to know the answer. Best, Ista On Tue, Feb 9, 2010 at 12:22 PM, Weber, Sam sam.we...@exeter.ac.uk wrote: Dear all, I was wondering if anyone could help solve a problem of a missing interaction effect!! I carried out a 2 x 2 factorial experiment to see if eggs from 2 different locations (Origin = 1 or 2) had different hatching success under 2 different incubation schedules (Treat = 1 or 2). Six eggs were taken from 10 females (random = Female) at each location and split between the treatments, giving 30 eggs from each location in each treatment. Overall proportions hatching were as follows: Treat 1 2 Origin 1 29/30 5/30 2 29/30 16/30 I made a binomial response in which hatching was a success and not-hatching was a failure, and analysed as a binomial GLMM. I'm particularly interested in the interaction between the two factors. An expression reproducing the raw data is attached at the end of the post in case it is helpful. hatch.frame$success-cbind(hatch.frame$Hatched,hatch.frame$Nothatched) model-lmer(success~Origin*Treat+(1|Female),family=binomial,method=ML,data =hatch.frame) model2-update(model,~.-Origin:Treat) anova(model,model2) Data: Models: model2: success ~ Origin + Treat + (1 | Female) model: success ~ Origin * Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model2 4 94.707 105.857 -43.353 model 5 95.350 109.287 -42.675 1.3572 1 0.244 model3-update(model2,~.-Origin) anova(model2,model3) Data: Models: model3: success ~ Treat + (1 | Female) model2: success ~ Origin + Treat + (1 | Female) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) model3 3 98.863 107.225 -46.431 model2 4 94.707 105.857 -43.353 6.1558 1 0.01310 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 model4-update(model2,~.-Treat) anova(model2,model4) Data: Models: model4:
Re: [R] Interpretation of high order interaction terms.
## Artificial data with all interactions significant. ## The interaction2wt plot shows all main effects and all pairwise ## interactions. We see in the Y ~ A|B panel (or in the ## interaction.plot) that Y goes uphill for levels 1 and 2 of B and ## goes down and then up for level 3 of B. This is the two-way A:B ## interaction. At each level of B, the main effect of A differs. ## From the xyplot, we see that at level 1 of C, Y goes down for level ## 3 of B. At level 2 of C, Y goes down a lot and then up for level 3 ## of B. This is the three-way A:B:C interaction. At each level of C ## the two-way interaction of A and B differs. set.seed(1) require(HH) ## needed for interaction2wt() threeway - data.frame(matrix(c( 1, 1, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 3, 3, 2, 1, 3, 1, 3, 1, 2, 2, 3, 1, 1, 3, 3, 1, 1, 1, 1, 2, 2, 2, 1, 2, 3, 3, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 3, 1, 3, 2, -4, 2, 3, 2, 1, 3, 3, 2), byrow=TRUE, 18, 4, dimnames=list(1:18,c(Y,A,B,C for (i in 2:4) threeway[[i]] - factor(threeway[[i]]) threeway - rbind(threeway, threeway) threeway$Y - threeway$Y + rnorm(36, s=.5) anova(aov(Y ~ A * B * C, data=threeway)) with(threeway, interaction.plot(A, B, Y)) ## shows just the Y ~ A|B panel ## all two-way interactions and main effects interaction2wt(Y ~ A + B + C, data=threeway) ## library(HH) required xyplot(x ~ A | C, groups=B, data=aggregate(threeway[,1], threeway[,-1], mean), type=l, auto.key=list(title=B, space=left, border=TRUE, lines=TRUE, points=FALSE), strip=strip.custom(strip.names=c(TRUE,TRUE))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re-execute previous command
Thanks David, I guess I have to settle with the upper-arrow thing I have been doing all along. My figures do not return any value so ggplot, lattice are out. -- View this message in context: http://n4.nabble.com/Re-execute-previous-command-tp1474629p1474813.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] Dickey Fuller test of a time series (problem)
i also having the problem with R . R version 2.10.0 (2009-10-26) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] z-rnorm(289) z [1] 2.330811003 1.504743043 1.768175890 0.629578885 -1.102466476 1.022360003 -0.683596222 0.825797728 1.970304092 [10] -0.434295690 -0.332111909 0.784754124 0.618029090 -0.323679397 0.477139243 0.567437753 -0.082967056 -0.631445108 [19] -0.599448056 -0.023043350 0.254275136 0.729704319 -0.557885077 0.136863688 0.336083722 -0.574337438 0.489163710 [28] -1.178968998 -0.500117153 0.194962840 1.077193868 -0.224323646 0.830018849 -0.923133317 0.984637207 -0.967962617 [37] -0.330364545 0.411477240 1.921856365 -0.402244385 0.287249079 -0.254981296 1.373816270 0.051474667 0.467294146 [46] -0.084979045 1.010413164 -1.685650845 -0.225540927 -0.068473164 0.076474205 -0.599026450 0.749528909 -0.005966977 [55] -0.751531710 -0.566290715 -0.653128084 1.252402084 -0.475794837 0.361830550 0.534634320 0.128657947 -0.998795343 [64] 0.439908085 -0.616926920 0.616190407 -0.503356528 -1.571513634 -0.862492045 -0.858421322 0.37011 0.026994800 [73] -0.072956095 0.750615120 -0.111619011 0.073884163 -0.962739147 0.038873386 -0.343490682 0.752229210 0.965300992 [82] -1.604473652 1.516414656 -0.938925299 -0.709151677 0.231854623 -0.218100137 1.543797726 -0.898485417 -0.383154763 [91] 1.676661233 -0.050011605 -0.885938130 -0.759522611 0.825827497 0.307787209 -1.582181323 1.548739934 0.874375153 [100] -1.929437918 -1.257364398 -1.789263683 -2.143550087 -0.299557119 -0.034432098 0.523581523 1.282782038 -0.627147412 [109] 1.379406957 -1.943450866 -0.109843039 -0.186738958 1.940752202 -0.399888402 0.889084467 0.347721291 0.221675595 [118] 1.014829243 0.815928201 -1.289821785 1.086385072 -0.299486086 -0.126573107 0.527587325 -1.988292033 -0.661784968 [127] -0.739984305 0.043729158 0.780508168 -0.329149317 -0.239561967 0.479590885 0.483343301 -1.330296792 -1.347459911 [136] -0.588658836 -0.954908406 -0.215942979 -0.079013859 -0.386107147 1.030946757 1.352902085 1.621552841 0.951461132 [145] 0.107764563 -0.143231089 0.837469606 -0.687510567 1.376661975 0.837165093 0.063985577 1.381120151 -0.628153036 [154] -1.144266557 1.005945165 1.085202192 0.273625164 0.022451305 -0.372955252 0.283434935 -1.174292734 1.513095774 [163] -1.406613019 -0.954491994 0.275374664 -0.404428637 -0.791690077 -0.325169327 0.859515784 -1.605660446 -0.126481055 [172] -1.163844796 0.234669024 0.694055806 -0.503758028 0.747620192 -0.490237653 -0.673188493 0.597849322 0.508355060 [181] 0.220080232 1.254662349 -1.390019760 1.036511650 0.004499064 -0.171119971 0.341759420 0.883209195 0.196981832 [190] 1.93083 -0.472635901 -0.143698739 0.134008071 0.123061173 -0.847030934 0.478631946 -0.640264555 1.198188793 [199] 0.928747360 -1.223396075 0.042572331 -1.193181087 -0.284040641 -0.511904510 -0.591542425 0.763156940 0.649463947 [208] -0.762889670 -0.628481227 0.367263423 -0.286380274 0.354460516 -0.138982551 -1.184283483 0.489375881 1.005739798 [217] 0.267274437 -0.118960041 -1.207006456 0.461973434 0.325420233 0.996123459 1.188010215 -2.000847324 1.043974965 [226] 0.356219212 0.620522833 3.800773985 -2.080091995 0.322824104 -1.793810727 0.49250 -0.092310467 2.893818046 [235] -0.846021981 0.402650410 -0.426312400 1.162983880 2.076818805 -0.260109032 0.725039578 0.361726563 -0.116508468 [244] 0.820778041 1.664995327 0.361725669 0.577447944 -1.008407703 0.390553465 0.263064760 0.915409450 0.294579966 [253] 1.478028593 1.865177412 -1.050708541 -2.071520363 0.450842362 0.530261688 0.226103509 -0.875767768 0.255960500 [262] -0.675455904 -1.436531605 -0.715532812 0.498582850 0.463511831 0.568583368 0.337032963 -0.31489 -0.738982923 [271] 1.740242504 1.089138147 -0.128574330 1.834612295 -0.657243928 0.701904808 1.550270461 -0.234375326 -0.420885683 [280] 1.845942481 -0.895760996 -0.593765244 0.586912606 -1.062899762 0.277845308 -0.834841694 -0.614720628 -0.343506642 [289] 0.442537573 x - data.frame(z) x z 12.330811003 21.504743043 31.768175890 40.629578885 5 -1.102466476 61.022360003 7 -0.683596222 80.825797728 91.970304092 10 -0.434295690 11 -0.332111909 12 0.784754124 13 0.618029090 14 -0.323679397 15 0.477139243 16
[R] how to rest the variables
Hi , I have several commands that I want to run, I was wondering if there is an easy way to reset my variables before the start of each run for ( i in 1:200){ reset the variables run the commands } My solution right now is to set all my vectors to 0 and my data frames to NULL after the start of the loop. Is there an easy way to do this? Thanks, -- View this message in context: http://n4.nabble.com/how-to-rest-the-variables-tp1474869p1474869.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 rest the variables
What do you mean by 'reset'? Why not put your processing in a function that you call so that each time you invoke it, any variables local to the function start in an 'initialized' state (depends on how you are using them). If you need them to have some specific value, then put in the code necessary since R does not know which ones you want initialized and which ones you want to keep the value for. Are you thinking about some other language that has this feature? If so how is it used there? On Tue, Feb 9, 2010 at 2:02 PM, kayj kjaj...@yahoo.com wrote: Hi , I have several commands that I want to run, I was wondering if there is an easy way to reset my variables before the start of each run for ( i in 1:200){ reset the variables run the commands } My solution right now is to set all my vectors to 0 and my data frames to NULL after the start of the loop. Is there an easy way to do this? Thanks, -- View this message in context: http://n4.nabble.com/how-to-rest-the-variables-tp1474869p1474869.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 Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installation require proxy settings (continued)
Timing can be an issue. You need to set the environment variables before accessing the internet for the 1st time in each R session. If you get the error, then try setting the variables, it will not work. For my situation I have http_proxy and http_proxy_user set for the entire computer (in windows you do this through the control panel). If you want to go with the .Renviron route, just type: Sys.getenv('home') At the command prompt and it will tell you what your Home folder is. Just create the .Renviron file in that folder. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Van Wyk, Jaap Sent: Monday, February 08, 2010 10:11 PM To: r-help@r-project.org Subject: Re: [R] Installation require proxy settings (continued) Importance: High Thanks to Greg and Michael for their advice. I have tried all these possibilities (and other); nothing seems to work; I persistently get the message: In open.connection(con, r) : cannot open: HTTP status was '407 Proxy Authentication Required' It seems as if proxy authentication required is causing the problem. It seems I have to set up an .Renviron file, but I am still learning R, and cannot find such a file. Would it help, and how do I create it (it that is a possible alternative to try). Thanks for any comments. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg (APK) PO Box 524, Auckland Park, 2006 Office ph: 011 559 3080 Fax: 011 559 2499 This email and all contents are subject to the following disclaimer: http://www.uj.ac.za/UJ_email_legal_disclaimer.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] subset in a matrix
Hi, I have a matrix of data values like the example bellow. I would like to extract a subset of the matrix for the values where the first column is negative. I am using the subset function. However, I am getting an error message that the conditional variable doe snot exist. For some reason, the subset operation only works if I transform the matrix to a data set using as.data.set(). The help indicates that the subset function can be applied to matrixes and data sets. I am wondering if anyone has seen a similar problem before. am I using the correct syntax? n = 15 m = 5 cnames = paste(x,1:m,sep=) rnames = 1:n z = matrix(rnorm(n*m),n,m,dimnames =list(rnames,cnames)) Thanks, Jorge test = subset(z,x1 0, select = c(cnames)) -- View this message in context: http://n4.nabble.com/subset-in-a-matrix-tp1474958p1474958.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] Re-execute previous command
On Feb 10, 5:21 am, mnstn pavan.n...@gmail.com wrote: Hello All, In bash, to re-execute a command, say, 'gnuplot plot.gnu', one can type !gnu. Is there a similar feature in the R console? For example: plot(g1$mean,g2$mean) . . . Lines, many lines of commands -Here I want to repeat the previous plot command. !plot and plot(+TAB) do not work. This question was asked in this forum back in 2006 but the answer seems to have been lost somewhere in their discussions. This is the threadhttp://n4.nabble.com/R-command-line-need-intelligent-command-history-... . Can some one comment if there is a way to do it? Thank you, MoonStone -- In bash, you can also use Ctrl-R plot to see the previous plot command - then Ctrl-R repeatedly to cycle through them all. Ctrl-S to search forward on the same text. Press enter to execute the one you want - or edit, etc. This also works in the R console for me. -- Anita __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installation require proxy settings (continued)
On Tue, 9 Feb 2010, Greg Snow wrote: Timing can be an issue. You need to set the environment variables before accessing the internet for the 1st time in each R session. If you get the error, then try setting the variables, it will not work. For my situation I have http_proxy and http_proxy_user set for the entire computer (in windows you do this through the control panel). If you want to go with the .Renviron route, just type: Sys.getenv('home') At the command prompt and it will tell you what your Home folder is. Just create the .Renviron file in that folder. I believe the OP specified internet2.dll on installation. It might be better not to do so ... otherwise you are at the mercy of IE internals. The rw-FAQ does say (Q2.19) (a) Use the alternative internet2.dll by starting R with the flag --internet2 (see How do I install R for Windows?) or calling setInternet2(TRUE). These cause R to use the Internet Explorer internals.. Note that this does not work with proxies that need authentication. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Van Wyk, Jaap Sent: Monday, February 08, 2010 10:11 PM To: r-help@r-project.org Subject: Re: [R] Installation require proxy settings (continued) Importance: High Thanks to Greg and Michael for their advice. I have tried all these possibilities (and other); nothing seems to work; I persistently get the message: In open.connection(con, r) : cannot open: HTTP status was '407 Proxy Authentication Required' It seems as if proxy authentication required is causing the problem. It seems I have to set up an .Renviron file, but I am still learning R, and cannot find such a file. Would it help, and how do I create it (it that is a possible alternative to try). Thanks for any comments. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg (APK) PO Box 524, Auckland Park, 2006 Office ph: 011 559 3080 Fax: 011 559 2499 This email and all contents are subject to the following disclaimer: http://www.uj.ac.za/UJ_email_legal_disclaimer.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset in a matrix
Try this: z[z[,1] 0,] On Tue, Feb 9, 2010 at 6:12 PM, DonDiego jorge.nie...@moorecap.com wrote: Hi, I have a matrix of data values like the example bellow. I would like to extract a subset of the matrix for the values where the first column is negative. I am using the subset function. However, I am getting an error message that the conditional variable doe snot exist. For some reason, the subset operation only works if I transform the matrix to a data set using as.data.set(). The help indicates that the subset function can be applied to matrixes and data sets. I am wondering if anyone has seen a similar problem before. am I using the correct syntax? n = 15 m = 5 cnames = paste(x,1:m,sep=) rnames = 1:n z = matrix(rnorm(n*m),n,m,dimnames =list(rnames,cnames)) Thanks, Jorge test = subset(z,x1 0, select = c(cnames)) -- View this message in context: http://n4.nabble.com/subset-in-a-matrix-tp1474958p1474958.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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] subset in a matrix
Hi: z = matrix(rnorm(n*m),n,m,dimnames =list(rnames,cnames)) z x1 x2 x3 x4 x5 1 -0.3942900 -0.61202639 -1.804958629 -0.1351786 -1.27659221 2 -0.0593134 0.34111969 1.465554862 1.1780870 -0.57326541 3 1.1000254 -1.12936310 0.153253338 -1.5235668 -1.22461261 4 0.7631757 1.43302370 2.172611670 0.5939462 -0.47340064 5 -0.1645236 1.98039990 0.475509529 0.3329504 -0.62036668 6 -0.2533617 -0.36722148 -0.709946431 1.0630998 0.04211587 7 0.6969634 -1.04413463 0.610726353 -0.3041839 -0.91092165 8 0.5566632 0.56971963 -0.934097632 0.3700188 0.15802877 9 -0.6887557 -0.13505460 -1.253633400 0.2670988 -0.65458464 10 -0.7074952 2.40161776 0.291446236 -0.5425200 1.76728727 11 0.3645820 -0.03924000 -0.443291873 1.2078678 0.71670748 12 0.7685329 0.68973936 0.001105352 1.1604026 0.91017423 13 -0.1123462 0.02800216 0.074341324 0.7002136 0.38418536 14 0.8811077 -0.74327321 -0.589520946 1.5868335 1.68217608 15 0.3981059 0.18879230 -0.568668733 0.5584864 -0.63573645 z[z[, 1] 0, ] x1 x2 x3 x4 x5 1 -0.3942900 -0.61202639 -1.80495863 -0.1351786 -1.27659221 2 -0.0593134 0.34111969 1.46555486 1.1780870 -0.57326541 5 -0.1645236 1.98039990 0.47550953 0.3329504 -0.62036668 6 -0.2533617 -0.36722148 -0.70994643 1.0630998 0.04211587 9 -0.6887557 -0.13505460 -1.25363340 0.2670988 -0.65458464 10 -0.7074952 2.40161776 0.29144624 -0.5425200 1.76728727 13 -0.1123462 0.02800216 0.07434132 0.7002136 0.38418536 Is this what you were looking for? HTH, Dennis On Tue, Feb 9, 2010 at 12:12 PM, DonDiego jorge.nie...@moorecap.com wrote: Hi, I have a matrix of data values like the example bellow. I would like to extract a subset of the matrix for the values where the first column is negative. I am using the subset function. However, I am getting an error message that the conditional variable doe snot exist. For some reason, the subset operation only works if I transform the matrix to a data set using as.data.set(). The help indicates that the subset function can be applied to matrixes and data sets. I am wondering if anyone has seen a similar problem before. am I using the correct syntax? n = 15 m = 5 cnames = paste(x,1:m,sep=) rnames = 1:n z = matrix(rnorm(n*m),n,m,dimnames =list(rnames,cnames)) Thanks, Jorge test = subset(z,x1 0, select = c(cnames)) -- View this message in context: http://n4.nabble.com/subset-in-a-matrix-tp1474958p1474958.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] Interpretation of high order interaction terms.
This is useful. But it is not exactly what I am looking for. I can use 'contrast' to infer linear combination factor level means as discussed in Statistical Inference by Casella and Berger. What is the equivalent 'contrast' for interaction terms? Is there a book that discuss this? On Tue, Feb 9, 2010 at 12:29 PM, RICHARD M. HEIBERGER r...@temple.edu wrote: ## Artificial data with all interactions significant. ## The interaction2wt plot shows all main effects and all pairwise ## interactions. We see in the Y ~ A|B panel (or in the ## interaction.plot) that Y goes uphill for levels 1 and 2 of B and ## goes down and then up for level 3 of B. This is the two-way A:B ## interaction. At each level of B, the main effect of A differs. ## From the xyplot, we see that at level 1 of C, Y goes down for level ## 3 of B. At level 2 of C, Y goes down a lot and then up for level 3 ## of B. This is the three-way A:B:C interaction. At each level of C ## the two-way interaction of A and B differs. set.seed(1) require(HH) ## needed for interaction2wt() threeway - data.frame(matrix(c( 1, 1, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 3, 3, 2, 1, 3, 1, 3, 1, 2, 2, 3, 1, 1, 3, 3, 1, 1, 1, 1, 2, 2, 2, 1, 2, 3, 3, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 3, 1, 3, 2, -4, 2, 3, 2, 1, 3, 3, 2), byrow=TRUE, 18, 4, dimnames=list(1:18,c(Y,A,B,C for (i in 2:4) threeway[[i]] - factor(threeway[[i]]) threeway - rbind(threeway, threeway) threeway$Y - threeway$Y + rnorm(36, s=.5) anova(aov(Y ~ A * B * C, data=threeway)) with(threeway, interaction.plot(A, B, Y)) ## shows just the Y ~ A|B panel ## all two-way interactions and main effects interaction2wt(Y ~ A + B + C, data=threeway) ## library(HH) required xyplot(x ~ A | C, groups=B, data=aggregate(threeway[,1], threeway[,-1], mean), type=l, auto.key=list(title=B, space=left, border=TRUE, lines=TRUE, points=FALSE), strip=strip.custom(strip.names=c(TRUE,TRUE))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] subset in a matrix
As others have said, z[z[, 1] 0, ] does it. Just in case you're wondering why your subset command won't work, str() is your friend (as is so often the case): str(z) str(as.data.frame(z)) ## (I don't think that R has 'as.data.set') So z is a matrix with column *names* x1, etc; as.data.frame(z) is a data.frame with *variables* named x1 etc. If you really want to use subset(), then subset(z, z[, x1] 0, select = ...) will work, but I wouldn't use it. -Peter Ehlers DonDiego wrote: Hi, I have a matrix of data values like the example bellow. I would like to extract a subset of the matrix for the values where the first column is negative. I am using the subset function. However, I am getting an error message that the conditional variable doe snot exist. For some reason, the subset operation only works if I transform the matrix to a data set using as.data.set(). The help indicates that the subset function can be applied to matrixes and data sets. I am wondering if anyone has seen a similar problem before. am I using the correct syntax? n = 15 m = 5 cnames = paste(x,1:m,sep=) rnames = 1:n z = matrix(rnorm(n*m),n,m,dimnames =list(rnames,cnames)) Thanks, Jorge test = subset(z,x1 0, select = c(cnames)) -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on start R in server
On 02/08/2010 11:05 PM, Jiiindo wrote: Thanks for your answer, I can run it with an application Java normal. In my web-application, when i need, i start R et calling R function (new REvaluator).eval(1+1) to calcule an expression 1+1example. And output of your code: Loading RInterpreter library Load the Java VM with .JavaInit() R version 2.10.1 (2009-12-14) i686-pc-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] SJava_0.72.0 Hi -- In your original email Warning: stack imbalance in 'if', 153 then 154 Warning: stack imbalance in '{', 151 then 152 this is definitely coming from R. If it does not occur in a normal Java application that uses SJava, but does occur in the web application that uses SJava, then the web application is configured differently from the normal application. The web application might be accessing a different version of R or SJava, or it might have the wrong java.library.path or LD_LIBRARY_PATH or CLASSPATH. The way you started the embedded R in the SJava web application (with the --no-save) means that any .RData or other R startup file, including those in the web application 'home' directory, will be loaded when R starts. I hope this provides some help; if it works out of the web app, but not in it, then it is a web app configuration issue. Martin -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Interpretation of high order interaction terms.
Googling for: contrasts for interaction terms produces useful results. For example: http://www.ats.ucla.edu/stat/spss/faq/test_subcommand_mixed_mod.htm Rich's example gave you an interpretation of a three-way interaction using contrasts. Maybe a bit hidden, but they are there. For example, excluded levels of a factor have a contrast coefficient of 0. Kevin On Tue, Feb 9, 2010 at 12:29 PM, RICHARD M. HEIBERGER r...@temple.eduwrote: ## Artificial data with all interactions significant. ## The interaction2wt plot shows all main effects and all pairwise ## interactions. We see in the Y ~ A|B panel (or in the ## interaction.plot) that Y goes uphill for levels 1 and 2 of B and ## goes down and then up for level 3 of B. This is the two-way A:B ## interaction. At each level of B, the main effect of A differs. ## From the xyplot, we see that at level 1 of C, Y goes down for level ## 3 of B. At level 2 of C, Y goes down a lot and then up for level 3 ## of B. This is the three-way A:B:C interaction. At each level of C ## the two-way interaction of A and B differs. set.seed(1) require(HH) ## needed for interaction2wt() threeway - data.frame(matrix(c( 1, 1, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 3, 3, 2, 1, 3, 1, 3, 1, 2, 2, 3, 1, 1, 3, 3, 1, 1, 1, 1, 2, 2, 2, 1, 2, 3, 3, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 3, 1, 3, 2, -4, 2, 3, 2, 1, 3, 3, 2), byrow=TRUE, 18, 4, dimnames=list(1:18,c(Y,A,B,C for (i in 2:4) threeway[[i]] - factor(threeway[[i]]) threeway - rbind(threeway, threeway) threeway$Y - threeway$Y + rnorm(36, s=.5) anova(aov(Y ~ A * B * C, data=threeway)) with(threeway, interaction.plot(A, B, Y)) ## shows just the Y ~ A|B panel ## all two-way interactions and main effects interaction2wt(Y ~ A + B + C, data=threeway) ## library(HH) required xyplot(x ~ A | C, groups=B, data=aggregate(threeway[,1], threeway[,-1], mean), type=l, auto.key=list(title=B, space=left, border=TRUE, lines=TRUE, points=FALSE), strip=strip.custom(strip.names=c(TRUE,TRUE))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Kevin Wright [[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] lmer
On Tue, Feb 9, 2010 at 4:38 AM, Demirtas, Hakan demir...@uic.edu wrote: Does lmer do three-level mixed-effects models? Yes. What forms of outcome variables can it handle (continuous, survival, binary)? I'd appreciate any help. Continuous outcomes for lmer. glmer can handle binary outcomes. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Formula used to create new plot
It is not clear what exactly you want, but here are some ideas. Lattice and ggplot2 allow you to save graph objects that can then be modified/printed/plotted, there is information in there on types of axes etc. For basic graphics (and others) you can use the history command to see recent plotting commands issued. The plot2script function in the TeachingDemos package will create a script that will recreate the current plot (but uses low level plotting commands, not the same as was typed in). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Timothée Poisot Sent: Tuesday, February 09, 2010 9:24 AM To: r-h...@stat.math.ethz.ch Subject: [R] Formula used to create new plot Dear list users, I was wondering if there is any way to know, for an open graphical peripheric, the instruction that was used to call it. For example, if I create a plot using plot(runif(10)) is there any way to have the call returned to me? That would be especially usefull to know it there are any log axes, for example thanks t --- Timothée POISOT - Institut des Sciences de l'Evolution Université Montpellier 2, CC 065 Place Eugène Bataillon 34095 Montpellier CEDEX 5 - Phone : (+33)4 67 14 40 61 Fax : (+33)4 67 14 40 61 E-mail: tpoi...@um2.fr Web : http://www.timotheepoisot.fr/ --- [[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] [R-pkgs] survey 3.20
Version 3.20 of the survey package is percolating through CRAN The major additions since the last announcement on this list (3.18, in September) are - database-backed designs can now use replicate weights - some multivariate statistics: principal components, factor analysis. The NEWS file has a more detailed list of additions and changes. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle ___ 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] Re-execute previous command
You can use the history function to see a list of previous commands (but it does not automatically run them). Do history(pat='plot') To get a list of all the commands that you ran that included the string 'plot' somewhere in it. You can then copy and paste to rerun (under the windows GUI (and possibly others) you can highlight and hit a button to rerun). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of mnstn Sent: Tuesday, February 09, 2010 9:21 AM To: r-help@r-project.org Subject: [R] Re-execute previous command Hello All, In bash, to re-execute a command, say, 'gnuplot plot.gnu', one can type !gnu. Is there a similar feature in the R console? For example: plot(g1$mean,g2$mean) . . . Lines, many lines of commands -Here I want to repeat the previous plot command. !plot and plot(+TAB) do not work. This question was asked in this forum back in 2006 but the answer seems to have been lost somewhere in their discussions. This is the thread http://n4.nabble.com/R-command-line-need-intelligent-command-history- recall-td793072.html#a793075 . Can some one comment if there is a way to do it? Thank you, MoonStone -- View this message in context: http://n4.nabble.com/Re-execute-previous- command-tp1474629p1474629.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] Installation require proxy settings (continued)
Thanks Prof. Ripley. I had forgotten that the OP had specified internet2. I don't use it, so my suggestions only apply when it is turned off. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Tuesday, February 09, 2010 1:18 PM To: Greg Snow Cc: Van Wyk, Jaap; r-help@r-project.org Subject: Re: [R] Installation require proxy settings (continued) On Tue, 9 Feb 2010, Greg Snow wrote: Timing can be an issue. You need to set the environment variables before accessing the internet for the 1st time in each R session. If you get the error, then try setting the variables, it will not work. For my situation I have http_proxy and http_proxy_user set for the entire computer (in windows you do this through the control panel). If you want to go with the .Renviron route, just type: Sys.getenv('home') At the command prompt and it will tell you what your Home folder is. Just create the .Renviron file in that folder. I believe the OP specified internet2.dll on installation. It might be better not to do so ... otherwise you are at the mercy of IE internals. The rw-FAQ does say (Q2.19) (a) Use the alternative internet2.dll by starting R with the flag --internet2 (see How do I install R for Windows?) or calling setInternet2(TRUE). These cause R to use the Internet Explorer internals.. Note that this does not work with proxies that need authentication. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Van Wyk, Jaap Sent: Monday, February 08, 2010 10:11 PM To: r-help@r-project.org Subject: Re: [R] Installation require proxy settings (continued) Importance: High Thanks to Greg and Michael for their advice. I have tried all these possibilities (and other); nothing seems to work; I persistently get the message: In open.connection(con, r) : cannot open: HTTP status was '407 Proxy Authentication Required' It seems as if proxy authentication required is causing the problem. It seems I have to set up an .Renviron file, but I am still learning R, and cannot find such a file. Would it help, and how do I create it (it that is a possible alternative to try). Thanks for any comments. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg (APK) PO Box 524, Auckland Park, 2006 Office ph: 011 559 3080 Fax: 011 559 2499 This email and all contents are subject to the following disclaimer: http://www.uj.ac.za/UJ_email_legal_disclaimer.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpretation of high order interaction terms.
## Continuing with the same example, I now show the full set of contrasts and their ## associated regression coefficients. Remember that regression coefficients in ## models with factors are meaningful only when the dummy variables are also displayed. ## construct full set of dummy variables to display all contrasts sapply(threeway[,2:4], contrasts) ## default is treatment contrasts contrasts(threeway$A) - cbind(Lin=c(-1,0,1), Quad=c(1,-2,1)) contrasts(threeway$B) - cbind(Lin=c(-1,0,1), Quad=c(1,-2,1)) contrasts(threeway$C) - cbind(Lin=c(-1,1)) sapply(threeway[,2:4], contrasts) ## changed to orthogonal ## integer-valued polynomial contrasts tw.aov - aov(Y ~ A * B * C, data=threeway, x=TRUE) x - tw.aov$x## dummy variables x t(x) anova(tw.aov) beta.hat - coef(tw.aov) ## regression coefficients beta.hat ## construct predicted values from beta.hat y.hat - x %*% beta.hat y.hat fitted(tw.aov) ## compare to predicted values from fitted function __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2 stacked line plot
Hadley, Thanks for the pointing that error out to me. Unfortunately, revising my code to: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_line(aes(colour = Type), position = 'stack') still does not generate what I'm after. I'm essentially after a line plot where each 'Type' ('series' in excel lingo) is stacked in an analogous fashion to a stacked area chart (i.e. geom_area(aes(Fill = Type), position = 'stack')) - again using lines rather than areas though. This chart should look just like a stacked area chart, however rather than each 'layer' (representing a given 'Type') being filled with a colour, each layer should have just a coloured line representing its values. Summing each line vertically for a given value on the x-axis across all the layers (i.e. 'Types') should then give the total y value for that x value (just like vertically summing an area chart). Really all I'm after is a stacked area chart where the fill for each 'Type' has been removed, leaving only a line for each (stacked) Type's value... I hope this is somewhat clear! Many thanks, Liam On Wed, Feb 10, 2010 at 1:53 AM, hadley wickham h.wick...@gmail.com wrote: Hi Liam, Your syntax is a little off. You want: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_area(aes(fill = Type), position = 'stack') Position isn't an aesthetic. Hadley On Sun, Feb 7, 2010 at 10:40 PM, Liam Blanckenberg liam.blanckenb...@gmail.com wrote: Hi all, I have been hunting around for hours trying to figure out how to generate a stacked line chart using ggplot2. This type of chart can be generated in excel 2007 by selecting: Chart type Line Stacked line. I can generate a stacked area chart using the following code: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_area(aes(position = 'stack', fill = Type)) However, when I try and replicate this using the following code for geom_line: p - ggplot(~, aes(x = ~, y = ~, colour = Type)) + geom_line(aes(position = 'stack')) the resulting plot is not stacked - i.e. each 'Type' is plotted at its actual value rather than cumulatively to form a stacked chart... I have poured through Hadley's ggplot2 book (ggplot2: elegant graphics for data analysis), the R help list and also done general google searching but cannot find a way to generate this type of plot. R version: 2.9.2 ggplot2 version: 0.8.5 OS: windows 7 (64-bit). Any suggestions or assistance would be greatly appreciated. Regards, Liam __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bad characters/fonts or something in R Help
Hello, I am experiencing problems viewing the help files in R. The easiest way to describe this is to just post an image. You can see what I'm talking about here: http://www.flickr.com/photos/matthewbk/4344722268/ If I copy and paste the weird characters, they show up like they should. Am I missing a specific font? Mac 10.6 Snow Leopard R 2.10.1 GUI 1.31 Leopard build 32-bit (5537) Thanks for any help. I have uninstalled and reinstalled but to no avail. Matt - Matthew Burton-Kelly, M.S. Graduate Student Department of Geology and Geological Engineering University of North Dakota (802) 922-3696 matthew.burton.ke...@und.nodak.edu matthew.burtonke...@gmail.com http://www.protichnoctem.com About thirty years ago there was much talk that geologists ought only to observe and not theorize; and I well remember someone saying that at this rate a man might as well go into a gravelpit and count the pebbles and describe the colors. How odd it is that anyone should not see that all observation must be for or against some view if it is to be of any service! -Charles Darwin, in an 1861 letter to Henry Fawcett. [[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] Double Integral Minimization Problem
Hello all, I am trying to minimize a function which contains a double integral, using nlminb for the minimization and adapt for the integral. The integral is over two variables (thita and radiusb) and the 3 free parameters I want to derive from the minimization are counts0, index and radius_eff. I have used both tasks in the past successfully but this is the first time I've tried using the functions where the free parameters are contained within the integral. My code is copied below: ## Begin of the code alpha=3.99 vita=4.4 ellip=0.2 majaxis_pix=c(3.0 6.5 10.0 13.5 17.0 20.5 24.0 27.5 31.0 34.5 38.0 41.5 45.0 48.5 52.0 55.5 59.0) counts=c(2479.117 718.061 298.918 157.963 98.869 63.883 44.524 31.918 23.500 17.877 13.915 11.032 8.881 7.245 5.978 4.972 4.175112) countserr=c(80.085 12.181 4.247 3.148 1.963 1.279 0.448 0.242 0.097 0.055 0.034 0.022 0.015 0.011 0.0082 0.006 0.0043) intensity=function(x,counts0,index,radius_eff){ thita=x[1] radiusb=x[2] counts2=(1-ellip)*(vita-1)/(pi*alpha^2)*counts0*radiusb*exp(-(2*index-0.324)*(radiusb/radius_eff)^(1/index))*(1+(((majaxis_pix^2)+(radiusb^2)-2*majaxis_pix*radiusb*cos(-thita)+(ellip^2-2*ellip)*((radiusb*sin(thita))^2))/(alpha^2)))^(-vita) return(counts2) } sersic=function(p) { counts0=p[1] index=p[2] radius_eff=p[3] value1=adapt(2,c(0,0),c(2*pi,200),functn=intensity,minpts=1000,maxpts=NULL,eps=0.01,counts0=counts0,index=index,radius_eff=radius_eff) test=value1$value f=sum(((counts-test)/countserr)^2) return(f) } out-nlminb(c(16000.0, 3.0,10.0), sersic) ##End of the code Any suggestions are welcome, Thank you, Marina -- View this message in context: http://n4.nabble.com/Double-Integral-Minimization-Problem-tp1475150p1475150.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] R ggplot2 legend text left justify
Thanks hadley wickham wrote: Hi Paul, That's a bug in the current version of ggplot. I'm working on update for later this week. Hadley On Mon, Feb 8, 2010 at 5:56 PM, Paul Sutcliffe psutc...@it.uts.edu.au wrote: In ggplot2 how do you justify the legend text ? In the example below the opts(legend.text = theme_text(size = 9,hjust=0)) changes the size of the text OK but it remains right justified. mydata=data.frame(RowID=c(A,B,C),Name=c(long long long long long name,short name ,medium medium name),Speed=c(100,140,120)) mydata RowID Name Speed 1 A long long long long long name 100 2 B short name140 3 Cmedium medium name 120 ggplot(mydata, aes(RowID,Speed))+ opts(legend.text = theme_text(size = 9,hjust=0)) + geom_bar() + xlab(Name) + aes(colour = Name) +aes(fill=Name) Thank in advance Paul -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Comparing means and trends in short time-series
I received also this message that did not show up here: This sounds like a problem in (linear) mixed effects models. Look into packages nlme (with the lme() function) and lme4 (function lmer()) for starters. What you have falls under the heading of longitudinal or repeated measures data. Both packages allow flexibility in the choice of within-unit covariance structure. It seem that it is trickier than it seems. I cannot test the gls(density~year*stream,..) as I do not have replicates within stream, but only one measurement for each stream. I tried to compare via anova the two models: Mixed1 - lme(density~year, data=mydata, random=~1|sector) Mixed2 - lme(density~year, data=mydata, random=~1|year/sector) But I'm not sure I can fit the Mixed2 model. Many thanks for the answers so far. Any ideas? Simone Vincenzi, PhD Department of Environmental Sciences University of Parma Viale G. P. Usberti, 33/A, 43100 Parma, Italy Phone: +39 0521 905696 Fax: +39 0521 906611 e.mail: mailto:svinc...@nemo.unipr.it svinc...@nemo.unipr.it [[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] ggplot2 stacked line plot
Hi Liam, Yes, that's what that code should do. Could you please send a small reproducible example? Hadley On Tue, Feb 9, 2010 at 4:21 PM, Liam Blanckenberg liam.blanckenb...@gmail.com wrote: Hadley, Thanks for the pointing that error out to me. Unfortunately, revising my code to: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_line(aes(colour = Type), position = 'stack') still does not generate what I'm after. I'm essentially after a line plot where each 'Type' ('series' in excel lingo) is stacked in an analogous fashion to a stacked area chart (i.e. geom_area(aes(Fill = Type), position = 'stack')) - again using lines rather than areas though. This chart should look just like a stacked area chart, however rather than each 'layer' (representing a given 'Type') being filled with a colour, each layer should have just a coloured line representing its values. Summing each line vertically for a given value on the x-axis across all the layers (i.e. 'Types') should then give the total y value for that x value (just like vertically summing an area chart). Really all I'm after is a stacked area chart where the fill for each 'Type' has been removed, leaving only a line for each (stacked) Type's value... I hope this is somewhat clear! Many thanks, Liam On Wed, Feb 10, 2010 at 1:53 AM, hadley wickham h.wick...@gmail.com wrote: Hi Liam, Your syntax is a little off. You want: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_area(aes(fill = Type), position = 'stack') Position isn't an aesthetic. Hadley On Sun, Feb 7, 2010 at 10:40 PM, Liam Blanckenberg liam.blanckenb...@gmail.com wrote: Hi all, I have been hunting around for hours trying to figure out how to generate a stacked line chart using ggplot2. This type of chart can be generated in excel 2007 by selecting: Chart type Line Stacked line. I can generate a stacked area chart using the following code: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_area(aes(position = 'stack', fill = Type)) However, when I try and replicate this using the following code for geom_line: p - ggplot(~, aes(x = ~, y = ~, colour = Type)) + geom_line(aes(position = 'stack')) the resulting plot is not stacked - i.e. each 'Type' is plotted at its actual value rather than cumulatively to form a stacked chart... I have poured through Hadley's ggplot2 book (ggplot2: elegant graphics for data analysis), the R help list and also done general google searching but cannot find a way to generate this type of plot. R version: 2.9.2 ggplot2 version: 0.8.5 OS: windows 7 (64-bit). Any suggestions or assistance would be greatly appreciated. Regards, Liam __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Model matrix using dummy regressors or deviation regressors
The model matrix for the code at the end the email is shown below. Since the model matrix doesn't have -1, I think that it is made of dummy regressors rather than deviation regressors. I'm wondering how to make a model matrix using deviation regressors. Could somebody let me know? model.matrix(aaov) (Intercept) A2 B2 B3 A2:B2 A2:B3 11 0 0 0 0 0 21 0 0 0 0 0 31 0 0 0 0 0 41 0 0 0 0 0 51 1 0 0 0 0 61 1 0 0 0 0 71 1 0 0 0 0 81 1 0 0 0 0 91 0 1 0 0 0 10 1 0 1 0 0 0 11 1 0 1 0 0 0 12 1 0 1 0 0 0 13 1 1 1 0 1 0 14 1 1 1 0 1 0 15 1 1 1 0 1 0 16 1 1 1 0 1 0 17 1 0 0 1 0 0 18 1 0 0 1 0 0 19 1 0 0 1 0 0 20 1 0 0 1 0 0 21 1 1 0 1 0 1 22 1 1 0 1 0 1 23 1 1 0 1 0 1 24 1 1 0 1 0 1 attr(,assign) [1] 0 1 2 2 3 3 attr(,contrasts) attr(,contrasts)$A [1] contr.treatment attr(,contrasts)$B [1] contr.treatment # a=2 b=3 n=4 A = rep(sapply(1:a,function(x){rep(x,n)}),b) B = as.vector(sapply(sapply(1:b, function(x){rep(x,n)}), function(x){rep(x,a)})) Y = A + B + rnorm(a*b*n) fr = data.frame(Y=Y,A=as.factor(A),B=as.factor(B)) aaov=aov(Y ~ A * B,fr) summary(aaov) model.matrix(aaov) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] split strings in a vector and convert it to a data.frame
hi, I have a vector full of strings like; xy_100_ab xy_101_ab xy_102_ab xy_103_ab I want to seperate each string in three pieces and the separator should be the _ at the end I want a data.frame like: column1 column2 column3 xy 100 ab xy 101 ab xy 102 ab xy 103 ab I tried strsplit but I couldn't figure out how to convert the list I get into a data.frame. I just need a function like read.table. But it seems that read.table only can handle files, not vectors... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Superimpose ksmooth() onto barplot
I'd like to superimpose a ksmooth() onto a barplot(). My data is: d 2009-06-20 2009-06-21 2009-06-22 2009-06-23 2009-06-24 2009-06-25 2009-06-26 2009-06-27 2009-06-28 2009-06-29 2009-06-30 2009-07-01 2009-07-02 Same Breed (B) 12.64 21.08 13.52 12.51 13.71 9.91 14.24 7.18 11.81 5.92 12.04 17.96 2.99 Different Breed 3.70 3.43 5.43 4.43 3.69 1.83 2.95 2.93 4.44 3.47 9.90 10.63 2.92 2009-07-04 2009-07-05 2009-07-06 2009-07-07 2009-07-08 2009-07-09 2009-07-10 2009-07-11 2009-07-12 2009-07-13 2009-07-14 2009-07-15 2009-07-16 Same Breed (B) 27.81 26.79 24.93 23.39 27.52 28.24 12.60 2.25 1.20 0.51 0.18 1.31 0.40 Different Breed 12.16 4.53 8.51 11.77 5.65 11.67 5.81 0.53 1.26 0.42 1.10 0.20 0.29 2009-07-17 2009-07-18 2009-07-19 2009-07-21 2009-07-22 2009-07-23 2009-07-24 2009-07-25 2009-07-26 2009-07-27 2009-07-28 2009-07-29 2009-10-29 Same Breed (B)0.24 0.03 0.05 13.34 7.70 9.50 9.12 8.62 10.60 7.46 13.17 15.55 3.17 Different Breed 0.13 0.01 0.05 4.98 2.75 4.38 2.17 3.51 1.97 2.68 1.60 2.47 0.38 2009-10-30 2009-10-31 2009-11-01 2009-11-02 2009-11-03 2009-11-04 2009-11-05 2009-11-06 2009-11-07 2009-11-08 2009-11-09 2009-11-24 2009-11-25 Same Breed (B)1.39 3.57 3.53 1.30 2.26 3.41 3.44 4.04 1.71 2.16 5.01 4.34 3.58 Different Breed 0.51 0.85 1.49 1.99 6.83 1.91 1.54 1.44 0.60 2.08 1.55 2.13 1.44 2009-11-26 2009-11-27 2009-11-28 2009-11-29 2009-11-30 Same Breed (B)2.12 2.34 1.90 4.99 2.11 Different Breed 4.21 1.00 2.28 2.90 1.68 I thought the following might work ok, but the x-axis doesn't quite line up correctly for the lines because of the spacing between the bars. I could set the space to zero, but does anyone have any thoughts on how to maintain the spacing and stretch the lines data? barplot(as.matrix(d), beside=FALSE, las=2, col=as.numeric(as.factor(rownames(d lines(ksmooth(1:ncol(d), colSums(d), kernel=normal, bandwidth=bandwidth), type=l, lwd=2, col=blue) lines(ksmooth(1:ncol(d), d[1,], kernel=normal, bandwidth=bandwidth), type=l, lwd=2, col=as.numeric(as.factor(rownames(d)))[1]) lines(ksmooth(1:ncol(d), d[2,], kernel=normal, bandwidth=bandwidth), type=l, lwd=2, col=as.numeric(as.factor(rownames(d)))[2]) legend(topright, c(rownames(d), Total), fill=c(as.numeric(as.factor(rownames(d))), blue)) Cheers, Nathan -- Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries University Drive Townsville, QLD 4810 Australia Tel: +61 (0)7 4753 8548 Fax: +61 (0)7 4753 8600 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Model matrix using dummy regressors or deviation regressors
On Feb 9, 2010, at 6:33 PM, bluesky...@gmail.com wrote: The model matrix for the code at the end the email is shown below. Since the model matrix doesn't have -1, I think that it is made of dummy regressors rather than deviation regressors. I'm wondering how to make a model matrix using deviation regressors. Could somebody let me know? If I understand your terminology, then: ?contr.sum -- David. model.matrix(aaov) (Intercept) A2 B2 B3 A2:B2 A2:B3 11 0 0 0 0 0 21 0 0 0 0 0 31 0 0 0 0 0 41 0 0 0 0 0 51 1 0 0 0 0 61 1 0 0 0 0 71 1 0 0 0 0 81 1 0 0 0 0 91 0 1 0 0 0 10 1 0 1 0 0 0 11 1 0 1 0 0 0 12 1 0 1 0 0 0 13 1 1 1 0 1 0 14 1 1 1 0 1 0 15 1 1 1 0 1 0 16 1 1 1 0 1 0 17 1 0 0 1 0 0 18 1 0 0 1 0 0 19 1 0 0 1 0 0 20 1 0 0 1 0 0 21 1 1 0 1 0 1 22 1 1 0 1 0 1 23 1 1 0 1 0 1 24 1 1 0 1 0 1 attr(,assign) [1] 0 1 2 2 3 3 attr(,contrasts) attr(,contrasts)$A [1] contr.treatment attr(,contrasts)$B [1] contr.treatment # a=2 b=3 n=4 A = rep(sapply(1:a,function(x){rep(x,n)}),b) B = as.vector(sapply(sapply(1:b, function(x){rep(x,n)}), function(x) {rep(x,a)})) Y = A + B + rnorm(a*b*n) fr = data.frame(Y=Y,A=as.factor(A),B=as.factor(B)) aaov=aov(Y ~ A * B,fr) summary(aaov) model.matrix(aaov) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] split strings in a vector and convert it to a data.frame
Hi Martin, Here is a sugestion: string - c(xy_100_ab, xy_101_ab,xy_102_ab,xy_103_ab) out - data.frame( do.call( rbind, strsplit( string, '_' ) ) ) names(out) - paste('column',1:3,sep=) out HTH, Jorge On Tue, Feb 9, 2010 at 6:46 PM, Martin Batholdy wrote: hi, I have a vector full of strings like; xy_100_ab xy_101_ab xy_102_ab xy_103_ab I want to seperate each string in three pieces and the separator should be the _ at the end I want a data.frame like: column1 column2 column3 xy 100 ab xy 101 ab xy 102 ab xy 103 ab I tried strsplit but I couldn't figure out how to convert the list I get into a data.frame. I just need a function like read.table. But it seems that read.table only can handle files, not vectors... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] split strings in a vector and convert it to a data.frame
On Feb 9, 2010, at 6:46 PM, Martin Batholdy wrote: hi, I have a vector full of strings like; xy_100_ab xy_101_ab xy_102_ab xy_103_ab I want to seperate each string in three pieces and the separator should be the _ at the end I want a data.frame like: column1 column2 column3 xy 100 ab xy 101 ab xy 102 ab xy 103 ab There are probably easier ways but this works: as.data.frame( t(sapply(1:4, function(x) strsplit(vec, _)[[x]])) ) V1 V2 V3 1 xy 100 ab 2 xy 101 ab 3 xy 102 ab 4 xy 103 ab I needed to transpose the matrix that resulted from the sideways presentation of the data. I tried strsplit but I couldn't figure out how to convert the list I get into a data.frame. I just need a function like read.table. But it seems that read.table only can handle files, not vectors... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Model matrix using dummy regressors or deviation regressors
Dear bluesky315, There are several ways in R to determine regressors associated with factors. One way is to set the global contrasts option. To get deviation regressors, use options(contrasts=c(contr.sum, contr.poly)), and see ?options and ?contrasts for details. Also see Section 11.1.1 of the Introduction to R manual that comes with R. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of bluesky...@gmail.com Sent: February-09-10 6:33 PM To: r-h...@stat.math.ethz.ch Subject: [R] Model matrix using dummy regressors or deviation regressors The model matrix for the code at the end the email is shown below. Since the model matrix doesn't have -1, I think that it is made of dummy regressors rather than deviation regressors. I'm wondering how to make a model matrix using deviation regressors. Could somebody let me know? model.matrix(aaov) (Intercept) A2 B2 B3 A2:B2 A2:B3 11 0 0 0 0 0 21 0 0 0 0 0 31 0 0 0 0 0 41 0 0 0 0 0 51 1 0 0 0 0 61 1 0 0 0 0 71 1 0 0 0 0 81 1 0 0 0 0 91 0 1 0 0 0 10 1 0 1 0 0 0 11 1 0 1 0 0 0 12 1 0 1 0 0 0 13 1 1 1 0 1 0 14 1 1 1 0 1 0 15 1 1 1 0 1 0 16 1 1 1 0 1 0 17 1 0 0 1 0 0 18 1 0 0 1 0 0 19 1 0 0 1 0 0 20 1 0 0 1 0 0 21 1 1 0 1 0 1 22 1 1 0 1 0 1 23 1 1 0 1 0 1 24 1 1 0 1 0 1 attr(,assign) [1] 0 1 2 2 3 3 attr(,contrasts) attr(,contrasts)$A [1] contr.treatment attr(,contrasts)$B [1] contr.treatment # a=2 b=3 n=4 A = rep(sapply(1:a,function(x){rep(x,n)}),b) B = as.vector(sapply(sapply(1:b, function(x){rep(x,n)}), function(x){rep(x,a)})) Y = A + B + rnorm(a*b*n) fr = data.frame(Y=Y,A=as.factor(A),B=as.factor(B)) aaov=aov(Y ~ A * B,fr) summary(aaov) model.matrix(aaov) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Novel (Maybe?) Visualizations
I'm interested in using R's plotting capabilities to try to generate a graph showing the relationship/pairing frequency of words appearing in a block of unstructured text. I don't have a specific algorithm or approach in mind, just looking to portray text in an interesting fashion. The output I'm hoping for is something like the following called a Phrase Network: http://manyeyes.alphaworks.ibm.com/manyeyes/page/Phrase_Net.html I found this package which seems semi-related, but I haven't been getting great results and I'm not sure if I'm on the right track. http://tm.r-forge.r-project.org/screenshots.html Does anyone have suggestions for another package I should look into? -D _ Hotmail: Free, trusted and rich email service. [[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] manipulate missing dates in a graphics a vector
Dear all, I am trying to identify the days absent in a vector so as to be able to display missing data in the graphics in .It should be done automatically since the graphics will be generated for different periods of the year. I have been trying to do a function below but it did not work. I really appreciate any help ordados - function(datas,var) { ind - !datas %in% var # find the missing date in var miss - datas[ind] mat - matrix(NA,length(miss),length(miss)) #insert NA in the missing date mat[,1]-miss jundado - rbind (mat,var) jundado - jundado[order(jundado[,1]),] # sort by dates } For instance: If I have the vector below: 2009-12-01 26.8 2009-12-03 27.9 2009-12-04 25.6 2009-12-05 20.8 2009-12-08 20.8 I will need a result like this one 2009-12-01 26.8 2009-12-02 NA 2009-12-03 27.9 2009-12-04 25.6 2009-12-05 20.8 2009-12-06 NA 2009-12-07 NA 2009-12-08 20.8 Bye and Best Regards Nilza Barros [[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] manipulate missing dates in a graphics a vector
Hi: # Create a sequence of consecutive dates and assign to a data frame dates - data.frame(day = seq(as.Date('2009-12-01'), by = 'days', length = 10)) # Let's call your data frame (not vector) 'df'; to make sure that things are # compatible, names(df) - c('day', 'y') df$day - as.Date(df$day) # Then, merge(dates, df, all.x =TRUE) dayy 1 2009-12-01 26.8 2 2009-12-02 NA 3 2009-12-03 27.9 4 2009-12-04 25.6 5 2009-12-05 20.8 6 2009-12-06 NA 7 2009-12-07 NA 8 2009-12-08 20.8 9 2009-12-09 NA 10 2009-12-10 NA HTH, Dennis On Tue, Feb 9, 2010 at 4:30 PM, Nilza BARROS nilzabar...@gmail.com wrote: Dear all, I am trying to identify the days absent in a vector so as to be able to display missing data in the graphics in .It should be done automatically since the graphics will be generated for different periods of the year. I have been trying to do a function below but it did not work. I really appreciate any help ordados - function(datas,var) { ind - !datas %in% var # find the missing date in var miss - datas[ind] mat - matrix(NA,length(miss),length(miss)) #insert NA in the missing date mat[,1]-miss jundado - rbind (mat,var) jundado - jundado[order(jundado[,1]),] # sort by dates } For instance: If I have the vector below: 2009-12-01 26.8 2009-12-03 27.9 2009-12-04 25.6 2009-12-05 20.8 2009-12-08 20.8 I will need a result like this one 2009-12-01 26.8 2009-12-02 NA 2009-12-03 27.9 2009-12-04 25.6 2009-12-05 20.8 2009-12-06 NA 2009-12-07 NA 2009-12-08 20.8 Bye and Best Regards Nilza Barros [[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] split strings in a vector and convert it to a data.frame
On Tue, Feb 9, 2010 at 6:46 PM, Martin Batholdy batho...@googlemail.com wrote: hi, I have a vector full of strings like; xy_100_ab xy_101_ab xy_102_ab xy_103_ab I want to seperate each string in three pieces and the separator should be the _ at the end I want a data.frame like: column1 column2 column3 xy 100 ab xy 101 ab xy 102 ab xy 103 ab I tried strsplit but I couldn't figure out how to convert the list I get into a data.frame. I just need a function like read.table. But it seems that read.table only can handle files, not vectors... Using textConnection() it can handle character vectors: DF - read.table(textConnection(x), sep = _); DF V1 V2 V3 1 xy 100 ab 2 xy 101 ab 3 xy 102 ab 4 xy 103 ab __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] manipulate missing dates in a graphics a vector
Tena koe Nilza I think merge() will do what you want. For example: completeDates V1 1 01-12-09 2 02-12-09 3 03-12-09 4 04-12-09 5 05-12-09 6 06-12-09 7 07-12-09 8 08-12-09 testData V1 V2 1 01-12-09 26.8 2 03-12-09 27.9 3 04-12-09 25.6 4 05-12-09 20.8 5 08-12-09 20.8 merge(completeDates, testData, by=1, all=T) V1 V2 1 01-12-09 26.8 2 02-12-09 NA 3 03-12-09 27.9 4 04-12-09 25.6 5 05-12-09 20.8 6 06-12-09 NA 7 07-12-09 NA 8 08-12-09 20.8 HTH ... Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Nilza BARROS Sent: Wednesday, 10 February 2010 1:30 p.m. To: r-help@r-project.org Subject: [R] manipulate missing dates in a graphics a vector Dear all, I am trying to identify the days absent in a vector so as to be able to display missing data in the graphics in .It should be done automatically since the graphics will be generated for different periods of the year. I have been trying to do a function below but it did not work. I really appreciate any help ordados - function(datas,var) { ind - !datas %in% var # find the missing date in var miss - datas[ind] mat - matrix(NA,length(miss),length(miss)) #insert NA in the missing date mat[,1]-miss jundado - rbind (mat,var) jundado - jundado[order(jundado[,1]),] # sort by dates } For instance: If I have the vector below: 2009-12-01 26.8 2009-12-03 27.9 2009-12-04 25.6 2009-12-05 20.8 2009-12-08 20.8 I will need a result like this one 2009-12-01 26.8 2009-12-02 NA 2009-12-03 27.9 2009-12-04 25.6 2009-12-05 20.8 2009-12-06 NA 2009-12-07 NA 2009-12-08 20.8 Bye and Best Regards Nilza Barros [[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.