[R] installing package from source
Hi R users, Currently I want to fit a FIGARCH model to a dataset. The only package that allow for it that I could find is fGarch. However it seems that the FIGARCH model class fitting of this package has been moved to Oxmetrics. I tried to install the old versions of it using 'tar.gz' files from CRAN archive http://cran.r-project.org/src/contrib/Archive/fGarch/ http://cran.r-project.org/src/contrib/Archive/fGarch/ but not sure how it works. I tried install.packages(myfilepath\fGarch_260.71.tar.gz, repos = NULL, type=source) And received this error: Warning: invalid package './I:_R filesGarch_260.71.tar.gz' Error: ERROR: no packages specified Warning messages: 1: running command 'I:/01_RFI~1/INSTAL~1/R-30~1.1/bin/i386/R CMD INSTALL -l I:\01_R files\installment\R-3.0.1\library ./I:_R files Garch_260.71.tar.gz' had status 1 2: In install.packages(I:\001_R files\fGarch_260.71.tar.gz, repos = NULL, : installation of package ‘./I:_R filesGarch_260.71.tar.gz’ had non-zero exit status Any helps on this? Regards, Long -- View this message in context: http://r.789695.n4.nabble.com/installing-package-from-source-tp4678928.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] How can I use a script l (LaTeX \ell) in mathematical annotation of plots?
Original post: On 13/10/2013 18:53, Byron Dom wrote: Due to convention a script l - $$\ell$$ (LaTeX \ell) is used to represent a certain quantity in something I'm working on. I'm unable to figure out how to use it in R. It's not included in the list on ?plotmath. Can anyone tell me how to use it? Its unicode is U+2113. This page has a list of various encodings of it: http://www.fileformat.info/info/unicode/char/2113/encoding.htm. Is there a way to include it by using one of these encodings somehow? - On 13/10/2013 22:06 Prof Brian Ripley responded: What do you want to do with it? plotmath is about plotting, but you have not otherwise mentioned that, let alone the device on which you want to plot. Read the help for plotmath: on some plot devices, just use \u2113. It is not AFAICS in the Adobe symbol encoding. -- Brian D. Ripley,                 ripley at 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, UK               Fax: +44 1865 272595 - My response: Thanks I worked out how to do it based on your mention of u2113. See below. I'm sorry if my information wasn't complete enough. I assumed that what I said, combined with the subject (How can I use a script l (LaTeX \ell) in mathematical annotation of plots?) would have been enough. I just wanted to be able to do this on the default device, which displays plots within the R session window. I have a simple path to go from there to .png form, which I include in LaTeX documents and for other purposes. I am using R version 3.0.1 in Windows 7, for which I believe the default plot device is windows. An example of the kind of thing I wanted to do is to include ylab = expression(hat(gamma)) (which is equivalent to the LaTex \hat{\gamma}}) among the base-graphics plot() arguments. That works. In LaTeX a script l is produced with \ell, but something like ylab = expression(ell) doesn't work in R. I wanted to be able to do the equivalent of that, but to obtain â. Here are a couple of examples using it that worked:  plot(1:10,xlab=\u2113)  plot(1:10,xlab=\u2113(\u2113 + 1)) The only (slight) problem with this is the minor aesthetic issue that the â one gets this way is in an obviously different font from what one gets using the LaTeX \lambda command/symbol. Strangely, earlier, when I tried  plot(1:10,xlab=expression(symbol(\u2113))) it did the same thing as  plot(1:10,xlab=expression(lambda)) So I got a lower-case greek lambda - λ, rather than â (script l). When I used the unicode representation for lowercase lambda - λ - as follows  plot(1:10,xlab=expression(symbol(\u03bb))) I got this for an x-axis label: Y+03BB. On the other hand, the following did work  plot(1:10,xlab=\u03bb), giving me an x-axis label of lambda - λ. [[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] Function not working as I'd like
Could you please show me what the code should be then? -- View this message in context: http://r.789695.n4.nabble.com/Function-not-working-as-I-d-like-tp4678878p4678898.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] Scripting call to R-Studio compile PDF
Thanks for the help guys. Sorry, I will not post further RStudio questions here. Yihui, thanks for the tip. Looks like these commands would do: grDevices::pdf.options(useDingbats = FALSE); require(knitr); opts_knit$set(concordance = TRUE); knit('filename.rnw', encoding='UTF-8') pdflatex filename.tex evince filename.pdf On Wed, Oct 23, 2013 at 2:20 PM, David Winsemius dwinsem...@comcast.netwrote: On Oct 23, 2013, at 10:48 AM, Adam Hughes wrote: Sorry, just to clarify: When I ask how to do this, I mean what does the RStudio compiler actually do? Are there a series of commands that are sent to the shell, similar to how compiling a .tex file is a call to the command line using pdflatex foofile.tex. I'm hoping to just copy these shell commands using a python script, which is easy. There is an RStudio mailing list or forum for support of that product. On Wed, Oct 23, 2013 at 1:39 PM, Adam Hughes hughesada...@gmail.com wrote: Hey everyone, I have several RStudio (.rnw) files that I am using a script to assemble into a composite document. For this purpose, it would be helpful if the script could automatcially make a call to whatever is called when a user opens up one of these files and manually clicks Compile PDF. Basically, this would allow me to refresh all of the reports before assimilating their pdf's into a composite document. Does anyone know offhand how to do this, or if I'm offbase in even trying? Thanks -- David Winsemius Alameda, CA, USA [[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] Variable operations
Dear All: I have v = c(xy, xy^2, z) dotv = sum(v*v) I hope, I have the following result: dotv = x^2*y^2 + x^2*y^4 + z^2 (still in variable x, y and z, not numeric result) How to make simple script, so that I have: dotv = x^2*y^2 + x^2*y^4 + z^2 Thanks a lot for your help. Best regards, Rizal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Scripting call to R-Studio compile PDF
Yes, that is pretty much it. Setting the options useDingbats or concordance is optional. You may or may not really need them. What is essential is the knit() function. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Wed, Oct 23, 2013 at 6:02 PM, Adam Hughes hughesada...@gmail.com wrote: Thanks for the help guys. Sorry, I will not post further RStudio questions here. Yihui, thanks for the tip. Looks like these commands would do: grDevices::pdf.options(useDingbats = FALSE); require(knitr); opts_knit$set(concordance = TRUE); knit('filename.rnw', encoding='UTF-8') pdflatex filename.tex evince filename.pdf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] raster package: merge/mosaic
Hi, With the 'merge' function using different tolerance level, I've come up with a solution. For e.g. consider r1 and r2 as two raster layers, attributes are as follows: r1 - raster(xmx=-150, ymn=60, ncols=30, nrows=20) r1[]-1:ncell(r1) r1 class : RasterLayer dimensions : 20, 30, 600 (nrow, ncol, ncell) resolution : 1, 1.5 (x, y) extent : -180, -150, 60, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 data source : in memory names : layer values : 1, 600 (min, max) origin(r1) [1] 0 0 r2 - raster(xmn=-100, xmx=-50, ymx=50, ymn=30,ncols=25,nrows=30) res(r2)-c(xres(r1),yres(r1)) r2[]-1:ncell(r2) r2 class : RasterLayer dimensions : 13, 50, 650 (nrow, ncol, ncell) resolution : 1, 1.5 (x, y) extent : -100, -50, 30.5, 50 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 data source : in memory names : layer values : 1, 650 (min, max) origin(r2) [1] 0.0 0.5 If we try to merge r1 and r2, merge(r1,r2) Error in compareRaster(x, extent = FALSE, rowcol = FALSE, orig = TRUE, : different origin So, they have different origins. Here the default tolerance value was = 0.05, I've changed it to 0.5 after a few trial and error. So, finally, merge(r1,r2,tolerance=0.5) class : RasterLayer dimensions : 40, 130, 5200 (nrow, ncol, ncell) resolution : 1, 1.5 (x, y) extent : -180, -50, 30.5, 90.5 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 data source : in memory names : layer values : 1, 650 (min, max) Worked! Hope this might help you to solve your problem. And also see what others say... Regards, Halim --- Md. Abdul Halim Assistant Professor Department of Forestry and Environmental Science Shahjalal University of Science and Technology,Sylhet-3114, Bangladesh. On Wed, 23 Oct 2013 12:18:40 -0700 (PDT), Carl Witthoft wrote According to ?merge, you could try adjusting the default value of the tolerance argument. Nora Ernst wrote I'm working with raster data (satellite imagery) and the raster package. The idea is to merge two raster files that are partially overlaping, do have the same coordinate system and resolution but not the same origin. As expected, the functions mosaic(r1,r2) as well as merge(r1,r2)) give the error message: Error in compareRaster(x, extent = FALSE, rowcol = FALSE, orig = TRUE, : different origin origin(r1) [1] 5.582522e-05 1.124150e-03 origin(r2) [1] 0.001054868 -0.001124150 Can anyone tell me how it is possible to merge rasters with different origin? -- View this message in context: http://r.789695.n4.nabble.com/raster- package-merge-mosaic-tp4678890p4678899.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. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] problem with ecdf : missing C_R_approxfun message
Hi list, In June 2013, using R.2.15.1 (i386) on Windows 7, I calculated a set of ecdf which I stored in lists of records having a size.ecdf field, with following structure : [skip previous structure...] $ size.ecdf :function (v) ..- attr(*, class)= chr [1:3] ecdf stepfun function ..- attr(*, call)=length 2 ecdf(test.moms[, m.pxs]) .. ..- attr(*, srcref)=Class 'srcref' atomic [1:8] 12 1 12 36 1 36 12 12 .. .. .. ..- attr(*, srcfile)=Classes 'srcfilecopy', 'srcfile' environment: 0x07d7b3b0 [skip following structure...] In September I upgraded to R.3.0.1 under the same OS I need to use my previously recorded ecdfs again, and try to plot one as in : plot(first.list[[1]]$size.ecdf,col=couleurs[1],main=first ecdf) Which returns : Erreur dans x(0.5 * (ti.l + ti.r)) : objet 'C_R_approxfun' introuvable Sorry it's in French ;-) , it translates to error in x(0.5 * (ti.l + ti.r)) : missing object 'C_R_approxfun' The same message prints when trying to use other ecdf methods, or other records in my lists. I first searched the help and archives without success, here are four questions I cannot answer : What is this C_R_approxfun object and what is it intended to do ? What may have caused it is missing now (and was not in June) ? Does this mean that I should have recorded other useful parameters in June (such as environment parameters) ? Or anything else I cannot guess ? Thanks for helping, I'm stuck and I would prefer not to calculate all my old ecdfs again ! Regards, Olivier -- Olivier ETERRADOSSI Maître-Assistant, HDR Ecole des Mines d'Alès (C2MA, site de Pau) Ingénierie de l'aspect visuel et tactile des matériaux Pôle « Recherche sur les Interactions des Matériaux avec leur Environnement » (RIME) Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 Tel : 05 59 30 90 35 (direct) - 05 59 30 54 25 (std) Fax : 05 59 30 63 68 http://www.mines-ales.frhttp://www.mines-ales.fr/ http://www.mines-telecom.frhttp://www.mines-telecom.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] TR: problem with ecdf : missing C_R_approxfun message
Hi again, this is a follow-up of my previous post : I've noticed that attr(first.list[[1]]$size.ecdf,call) gives ecdf(test.moms[, m.pxs]) and that there is no test.moms field in my records (a local variable named test.moms was used inside a function, but it was stored under another name in the list, outside the function) May this be the answer (and I've been stupid not to see this before !) ? Anyway, trying to change test.moms to the real name of the corresponding record field, i.e. : attr(first.list[[1]]$size.ecdf,call)-ecdf(first.list[[1]]$true.varname[,m.pxs]) Does not fix the problem. Is changing the call attribute the thing to do, but done in a wrong way ? If yes, what is the good way ? If not, what can be done ? Thanks again, Olivier De : Olivier Eterradossi Envoyé : jeudi 24 octobre 2013 08:54 À : 'r-help@r-project.org' Objet : problem with ecdf : missing C_R_approxfun message Hi list, In June 2013, using R.2.15.1 (i386) on Windows 7, I calculated a set of ecdf which I stored in lists of records having a size.ecdf field, with following structure : [skip previous structure...] $ size.ecdf :function (v) ..- attr(*, class)= chr [1:3] ecdf stepfun function ..- attr(*, call)=length 2 ecdf(test.moms[, m.pxs]) .. ..- attr(*, srcref)=Class 'srcref' atomic [1:8] 12 1 12 36 1 36 12 12 .. .. .. ..- attr(*, srcfile)=Classes 'srcfilecopy', 'srcfile' environment: 0x07d7b3b0 [skip following structure...] In September I upgraded to R.3.0.1 under the same OS I need to use my previously recorded ecdfs again, and try to plot one as in : plot(first.list[[1]]$size.ecdf,col=couleurs[1],main=first ecdf) Which returns : Erreur dans x(0.5 * (ti.l + ti.r)) : objet 'C_R_approxfun' introuvable Sorry it's in French ;-) , it translates to error in x(0.5 * (ti.l + ti.r)) : missing object 'C_R_approxfun' The same message prints when trying to use other ecdf methods, or other records in my lists. I first searched the help and archives without success, here are four questions I cannot answer : What is this C_R_approxfun object and what is it intended to do ? What may have caused it is missing now (and was not in June) ? Does this mean that I should have recorded other useful parameters in June (such as environment parameters) ? Or anything else I cannot guess ? Thanks for helping, I'm stuck and I would prefer not to calculate all my old ecdfs again ! Regards, Olivier -- Olivier ETERRADOSSI Maître-Assistant, HDR Ecole des Mines d'Alès (C2MA, site de Pau) Ingénierie de l'aspect visuel et tactile des matériaux Pôle « Recherche sur les Interactions des Matériaux avec leur Environnement » (RIME) Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 Tel : 05 59 30 90 35 (direct) - 05 59 30 54 25 (std) Fax : 05 59 30 63 68 http://www.mines-ales.frhttp://www.mines-ales.fr/ http://www.mines-telecom.frhttp://www.mines-telecom.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.
Re: [R] problem with ecdf : missing C_R_approxfun message
On 24/10/2013 07:54, Olivier Eterradossi wrote: Hi list, In June 2013, using R.2.15.1 (i386) on Windows 7, I calculated a set of ecdf which I stored in lists of records having a size.ecdf field, with following structure : Note that R 2.15.1 was not current even then. [skip previous structure...] $ size.ecdf :function (v) ..- attr(*, class)= chr [1:3] ecdf stepfun function ..- attr(*, call)=length 2 ecdf(test.moms[, m.pxs]) .. ..- attr(*, srcref)=Class 'srcref' atomic [1:8] 12 1 12 36 1 36 12 12 .. .. .. ..- attr(*, srcfile)=Classes 'srcfilecopy', 'srcfile' environment: 0x07d7b3b0 [skip following structure...] In September I upgraded to R.3.0.1 under the same OS And R 3.0.2 has been out for nearly a month now: see the posting guide. I need to use my previously recorded ecdfs again, and try to plot one as in : plot(first.list[[1]]$size.ecdf,col=couleurs[1],main=first ecdf) Which returns : Erreur dans x(0.5 * (ti.l + ti.r)) : objet 'C_R_approxfun' introuvable Sorry it's in French ;-) , it translates to error in x(0.5 * (ti.l + ti.r)) : missing object 'C_R_approxfun' The same message prints when trying to use other ecdf methods, or other records in my lists. I first searched the help and archives without success, here are four questions I cannot answer : What is this C_R_approxfun object and what is it intended to do ? What may have caused it is missing now (and was not in June) ? Does this mean that I should have recorded other useful parameters in June (such as environment parameters) ? Or anything else I cannot guess ? Thanks for helping, I'm stuck and I would prefer not to calculate all my old ecdfs again ! You have to. The ones you have contain references to internal code found only in R 3.0.0. Note that storing objects in .RData is never intended to be a permanent form of storage, and you have done a *major* version update. You should expect to have to re-create objects from your scripts. It is actually rather easy to update the objects. Consider Fn12 from example(ecdf) (which is random, so your mileage will vary). The data are in the environment of Fn12, so Fn12 - eval(attr(Fn12, call), environment(Fn12)) recreates it. Regards, Olivier -- Olivier ETERRADOSSI Maître-Assistant, HDR Ecole des Mines d'Alès (C2MA, site de Pau) Ingénierie de l'aspect visuel et tactile des matériaux Pôle « Recherche sur les Interactions des Matériaux avec leur Environnement » (RIME) Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 Tel : 05 59 30 90 35 (direct) - 05 59 30 54 25 (std) Fax : 05 59 30 63 68 http://www.mines-ales.frhttp://www.mines-ales.fr/ http://www.mines-telecom.frhttp://www.mines-telecom.fr/ -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Course: Mixed modelling (with intro MCMC)
We would like to announce the following stats course; Course: Introduction to MCMC, Linear mixed effects models and GLMM with R When: 20-24 January, 2014 Where: Bangor University, UK Info: http://www.highstat.com/statscourse.htm Flyer: http://www.highstat.com/Courses/Flyer2014_02Bangor.pdf Kind regards, Alain -- Dr. Alain F. Zuur First author of: 1. Analysing Ecological Data (2007) 2. Mixed effects models and extensions in ecology with R (2009) 3. A Beginner's Guide to R (2009) 4. Zero Inflated Models and GLMM with R (2012) 5. A Beginner's Guide to GAM (2012) 6. A Beginner's Guide to GLM and GLMM (2013) Highland Statistics Ltd. 6 Laverock road UK - AB41 6FN Newburgh Tel: 0044 1358 788177 Email: highs...@highstat.com URL: www.highstat.com URL: www.brodgar.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 can I use a script l (LaTeX \ell) in mathematical annotation of plots?
this works for me: plot(1,main=\u2113) cheers Am 24.10.2013 01:39, schrieb Byron Dom: Original post: On 13/10/2013 18:53, Byron Dom wrote: Due to convention a script l - $$\ell$$ (LaTeX \ell) is used to represent a certain quantity in something I'm working on. I'm unable to figure out how to use it in R. It's not included in the list on ?plotmath. Can anyone tell me how to use it? Its unicode is U+2113. This page has a list of various encodings of it: http://www.fileformat.info/info/unicode/char/2113/encoding.htm. Is there a way to include it by using one of these encodings somehow? - On 13/10/2013 22:06 Prof Brian Ripley responded: What do you want to do with it? plotmath is about plotting, but you have not otherwise mentioned that, let alone the device on which you want to plot. Read the help for plotmath: on some plot devices, just use \u2113. It is not AFAICS in the Adobe symbol encoding. -- Brian D. Ripley, ripley at 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 - My response: Thanks I worked out how to do it based on your mention of u2113. See below. I'm sorry if my information wasn't complete enough. I assumed that what I said, combined with the subject (How can I use a script l (LaTeX \ell) in mathematical annotation of plots?) would have been enough. I just wanted to be able to do this on the default device, which displays plots within the R session window. I have a simple path to go from there to .png form, which I include in LaTeX documents and for other purposes. I am using R version 3.0.1 in Windows 7, for which I believe the default plot device is windows. An example of the kind of thing I wanted to do is to include ylab = expression(hat(gamma)) (which is equivalent to the LaTex \hat{\gamma}}) among the base-graphics plot() arguments. That works. In LaTeX a script l is produced with \ell, but something like ylab = expression(ell) doesn't work in R. I wanted to be able to do the equivalent of that, but to obtain ℓ. Here are a couple of examples using it that worked: plot(1:10,xlab=\u2113) plot(1:10,xlab=\u2113(\u2113 + 1)) The only (slight) problem with this is the minor aesthetic issue that the ℓ one gets this way is in an obviously different font from what one gets using the LaTeX \lambda command/symbol. Strangely, earlier, when I tried plot(1:10,xlab=expression(symbol(\u2113))) it did the same thing as plot(1:10,xlab=expression(lambda)) So I got a lower-case greek lambda - λ, rather than ℓ (script l). When I used the unicode representation for lowercase lambda - λ - as follows plot(1:10,xlab=expression(symbol(\u03bb))) I got this for an x-axis label: Y+03BB. On the other hand, the following did work plot(1:10,xlab=\u03bb), giving me an x-axis label of lambda - λ. [[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. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Besuchen Sie uns auf: www.uke.de _ Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Rainer Schoppik _ SAVE PAPER - THINK BEFORE PRINTING __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] labeling abscissa using a function of the plotted scale
Thanks Jim, maybe now I can start learning. Next I want to use my choice of n digits or width instead of round. -- View this message in context: http://r.789695.n4.nabble.com/labeling-abscissa-using-a-function-of-the-plotted-scale-tp4678075p4678946.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] RWeka and multicore package
Dear, Patrick. I'm using a workaround to work with RWeka and multicore package. The most important point is not loading the RWeka package and use the namespace in a encapsulated function. Take a look on this code: # C4.5 classifier. Return the prediction for a test dataset. cl.c45 = function(tran, test) { model = RWeka::J48(Species ~ ., tran); pred = predict(model, test[,-ncol(test)], type=class); names(pred) = row.names(test); return(pred); } library(multicore) aux = mclapply(1:1000, function(i) { cl.c45(iris, iris) }) Regards, Luis On Tue, Oct 22, 2013 at 7:11 AM, Patrick Connolly p_conno...@slingshot.co.nz wrote: On Thu, 17-Oct-2013 at 02:21PM -0300, Luís Paulo F. Garcia wrote: | I work very mutch with the packages RWeka and multicore. If you try to run | J48 or any tree of RWeka with multicore we hava some errors. | | Example I: | | library(RWeka); | library(multicore); | | mclapply(1:100, function(i) { | J48(Species ~., iris); | }); | | | Output: Error in .jcall(o, \Ljava/lang/Class;\, \getClass\) : \n | java.lang.ClassFormatError: Incompatible magic value 1347093252 in class | file java/lang/ProcessEnvironment$StringEnvironment\n | | | Example II: | | library(multicore); | | mclapply(1:100, function(i) { | RWeka::J48(Species ~., iris); | }); | | Output: Erro em .jcall(x$classifier, S, toString) : | RcallMethod: attempt to call a method of a NULL object. | | | Do you know some way to work with parallel processing and RWeka? I tried | MPI and SNOW without success. Not much help, but I too have not been able to get parallelling RWeka to work. OTOH, what RWeka can do is very fast compared with, say, gbm (which does work well with mclapply). I suspect that it has something to do with how Java is set up, but I know nothing about setting up Java. | | R version 3.0.2 (2013-09-25) -- Frisbee Sailing | Ubuntu 12.04 x64 | | | -- | Lu?s Paulo Faina Garcia | Engenheiro de Computa??o - Universidade de S?o Paulo | S?o Carlos - SP - Brasil | | [[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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. -- Luís Paulo Faina Garcia Engenheiro de Computação - Universidade de São Paulo São Carlos - SP - Brasil [[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] nls model definition help
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of wayne.w.jo...@shell.com Sent: 22 October 2013 18:52 To: R-help@r-project.org Subject: [R] nls model definition help Hi fellow R users, I'm trying to fit a model using nls with the following model definition: y(t+1)=(th1*x1 + R1*x2) * exp(a1*x3) + (1-th1*x1 + R1*x2)*y(t) ... Any ideas if this is achievable and if not any ideas on how to fit this model? I'm thinking not, as you have that (t+1) back-reference in there which makes the calculated y(t) part of the expression. Pretty sure nlm won't handle that in the formula interface. However, you could use nlm or optim if you write a function to predict y and then wrap that in a function to calculate the residual sum of squares (taking the parameter vector and y[obs] as parameters), then minimise the residual SS. The hessian from either can then be used to estimate standard errors using the usual least-squares formulae. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] data frame pointers?
Hi Arun, That seemed to do the trick - thanks!! Jonathan On Wed, Oct 23, 2013 at 11:12 PM, arun smartpink...@yahoo.com wrote: HI, Better would be: res1 - dcast(df,gene~case,value.var=issue,paste,collapse=,,fill=0) str(res1) #'data.frame':2 obs. of 4 variables: # $ gene : chr gene1 gene2 # $ case_1: chr nsyn,amp 0 # $ case_2: chr del 0 # $ case_3: chr 0 UTR write.table(res1,test.txt,sep=\t,quote=FALSE,row.names=FALSE) A.K. On , arun smartpink...@yahoo.com wrote: Hi Jonathan,If you look at the str() str(res) 'data.frame':2 obs. of 4 variables: $ gene : chr gene1 gene2 $ case_1:List of 2 ..$ : chr nsyn amp ..$ : chr $ case_2:List of 2 ..$ : chr del ..$ : chr $ case_3:List of 2 ..$ : chr ..$ : chr UTR In this case, capture.output(res,file=test.txt) #should work But, if you wanted to use ?write.table() and also to substitute zeros, perhaps: res[,2:4] - lapply(res[,2:4],function(x) {x1 -unlist(lapply(x,paste,collapse=,));x1[x1==] - 0; x1}) str(res) #'data.frame':2 obs. of 4 variables: # $ gene : chr gene1 gene2 # $ case_1: chr nsyn,amp 0 # $ case_2: chr del 0 # $ case_3: chr 0 UTR write.table(res,test.txt,sep=\t,quote=FALSE,row.names=FALSE) A.K. On Wednesday, October 23, 2013 10:44 PM, Jon BR jonsle...@gmail.com wrote: Hi Arun, Your suggestion using dcast is simple and worked splendidly! Unfortunately, the resulting data frame does not play nicely with write.table. Any idea how to could print this out to a tab-delimited text file, perhaps substituting zeros in for the empty cells? See the error below: write.table(res,test.txt) Error in .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol, : unimplemented type 'list' in 'EncodeElement' Best, Jonathan On Wed, Oct 23, 2013 at 9:50 PM, arun smartpink...@yahoo.com wrote: HI, You may try: library(reshape2) df - data.frame(case=c(case_1,case_1,case_2,case_3), gene=c(gene1,gene1,gene1,gene2), issue=c(nsyn,amp,del,UTR), stringsAsFactors=FALSE) res - dcast(df,gene~case,value.var=issue,list) res # genecase_1 case_2 case_3 #1 gene1 nsyn, ampdel #2 gene2 UTR A.K. On Wednesday, October 23, 2013 7:38 PM, Jon BR jonsle...@gmail.com wrote: Hello, I've been running several programs in the unix shell, and it's time to combine results from several different pipelines. I've been writing shell scripts with heavy use of awk and grep to make big text files, but I'm thinking it would be better to have all my data in one big structure in R so that I can query whatever attributes I like, and print several corresponding tables to separate files. I haven't used R in years, so I was hoping somebody might be able to suggest a solution or combinatin of functions that could help me get oriented.. Right now, I can import my data into a data frame that looks like this: df - data.frame(case=c(case_1,case_1,case_2,case_3),gene=c(gene1,gene1,gene1,gene2),issue=c(nsyn,amp,del,UTR)) df case gene issue 1 case_1 gene1 nsyn 2 case_1 gene1 amp 3 case_2 gene1 del 4 case_3 gene2 UTR I'd like to cook up some combination of functions/scripting that can convert a table like df to produce a list or a data frame/ matrix that looks like df2: df2 case_1 case_2 case_3 gene1 nsyn,ampdel 0 gene20 0UTR I can build df2 manually, like this: df2 -data.frame(case_1=c(nsyn,amp,0),case_2=c(del,0),case_3=c(0,UTR)) rownames(df2)-c(gene1,gene2) but obviously do not want to do this by hand; I want R to generate df2 from df. Any pointers/ideas would be most welcome! Thanks, Jonathan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Use R to plot a directory tree
Dear all, I was wondering whether (or better: how) I can use R to read recursively a directory to get all the sub-folders and files located in the root folder and put it into a tree like structure where the leaves are files and intermediate nodes are the directories? The idea is that I'd like to plot the structure of a certain root folder to be able to restructure the file system. Any ideas on that? I was googling a lot but apparently I did not use the right terms (R tree folder or R tree directory takes me mainly to pages about the R-tree a structure for spatial access methods [at least I learnt something new ;)]) Any pointer to the right function is highly appreciated. Cheers, Thorn Thaler NRC Lausanne Applied Mathematics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plot.raster hides the axis layer
Hi all, I am trying to plot a raster object (I can explain why but the point is that it would be a raster objeçt).. I have selected a small code to show you exactly the problem require(raster) test-matrix(data=runif(1),nrow=100) m-raster(test) plot(m,axes=FALSE) axis(1,at=c(0,1),labels=c(a,b)) # THIS DOES NOT CHANGE THE INVISIBLE AXIS WHILE plot(test,axes=FALSE) axis(1,at=c(0,1),labels=c(a,b)) # WHEN I AM PLOTTING A NON RASTER OBJECT THE AXIS APPEARS. Can someone explain me what I can do so a raster layer to show correctly the axis? Please remember that I have to do that on a raster object so coercing it will not help .. I would like to thank you in advance for your help Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Use R to plot a directory tree
A wild guess -- take a look at the CRAN phylohenetics task view, as that sounds like the sort of thing that might have tree generation and manipulation functions. ... but you may do better with some non-R tool out there. (Hopefully, you'll get a better response, though). Cheers, Bert On Thu, Oct 24, 2013 at 6:13 AM, Thaler,Thorn,LAUSANNE,Applied Mathematics thorn.tha...@rdls.nestle.com wrote: Dear all, I was wondering whether (or better: how) I can use R to read recursively a directory to get all the sub-folders and files located in the root folder and put it into a tree like structure where the leaves are files and intermediate nodes are the directories? The idea is that I'd like to plot the structure of a certain root folder to be able to restructure the file system. Any ideas on that? I was googling a lot but apparently I did not use the right terms (R tree folder or R tree directory takes me mainly to pages about the R-tree a structure for spatial access methods [at least I learnt something new ;)]) Any pointer to the right function is highly appreciated. Cheers, Thorn Thaler NRC Lausanne Applied Mathematics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] labeling abscissa using a function of the plotted scale
Thanks Jim, maybe now I can start learning. Here is a run of my trying to learn: xvalue-c(5.2,1.3,9.7,2.8,8.1,4.7,6.6,7.4) yvalue-c(9,3,4,7,2,5,3,6) plot(xvalue,yvalue) axis(1,at=NULL,labels=1/xvalue,digits=5) Error in axis(1, at = NULL, labels = 1/xvalue, digits = 5) : 'labels' is supplied and not 'at' In addition: Warning message: In axis(1, at = NULL, labels = 1/xvalue, digits = 5) : digits is not a graphical parameter Why can't R automatically compute the spacing when I use the formula? How can I specify n-digits or width instead of round or nothing? -- View this message in context: http://r.789695.n4.nabble.com/labeling-abscissa-using-a-function-of-the-plotted-scale-tp4678075p4678954.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] Use R to plot a directory tree
One R package that might be of interest would be 'diagram': http://cran.r-project.org/web/packages/diagram/ I would also agree with Bert here and would point you in the direction of PSTricks, which can handle these sorts of complex figures. It would of course require learning LaTeX, but that is a good thing. :-) More info here: http://tug.org/PSTricks/main.cgi/ and lots of examples with code here: http://tug.org/PSTricks/main.cgi?file=examples I use PSTricks for creating things like subject disposition flow charts for clinical study reports. Regards, Marc Schwartz On Oct 24, 2013, at 8:47 AM, Bert Gunter gunter.ber...@gene.com wrote: A wild guess -- take a look at the CRAN phylohenetics task view, as that sounds like the sort of thing that might have tree generation and manipulation functions. ... but you may do better with some non-R tool out there. (Hopefully, you'll get a better response, though). Cheers, Bert On Thu, Oct 24, 2013 at 6:13 AM, Thaler,Thorn,LAUSANNE,Applied Mathematics thorn.tha...@rdls.nestle.com wrote: Dear all, I was wondering whether (or better: how) I can use R to read recursively a directory to get all the sub-folders and files located in the root folder and put it into a tree like structure where the leaves are files and intermediate nodes are the directories? The idea is that I'd like to plot the structure of a certain root folder to be able to restructure the file system. Any ideas on that? I was googling a lot but apparently I did not use the right terms (R tree folder or R tree directory takes me mainly to pages about the R-tree a structure for spatial access methods [at least I learnt something new ;)]) Any pointer to the right function is highly appreciated. Cheers, Thorn Thaler NRC Lausanne Applied Mathematics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Use R to plot a directory tree
perhaps as a somewhat tamer guess than Bert's, it's probably not very hard to write a function that pieces together a dendrogram (S3 class provided by the stats package), using the list.dirs and list.files functions. This could then be plotted via the plot function, and you could even designate attributes such as colours, line thicknesses etc. to highlight e.g. the largest files. I'm not too sure, though, how useful this would be for plotting directory trees for restructuring them; any tree that's complex enough to require the use of such auxiliary tools will very likely have at least a few hundred files, and thus labels will end up either overlapping everywhere or illegibly small. Best regards, Jan On Thu, Oct 24, 2013 at 09:20:30AM -0500, Marc Schwartz wrote: One R package that might be of interest would be 'diagram': http://cran.r-project.org/web/packages/diagram/ I would also agree with Bert here and would point you in the direction of PSTricks, which can handle these sorts of complex figures. It would of course require learning LaTeX, but that is a good thing. :-) More info here: http://tug.org/PSTricks/main.cgi/ and lots of examples with code here: http://tug.org/PSTricks/main.cgi?file=examples I use PSTricks for creating things like subject disposition flow charts for clinical study reports. Regards, Marc Schwartz On Oct 24, 2013, at 8:47 AM, Bert Gunter gunter.ber...@gene.com wrote: A wild guess -- take a look at the CRAN phylohenetics task view, as that sounds like the sort of thing that might have tree generation and manipulation functions. ... but you may do better with some non-R tool out there. (Hopefully, you'll get a better response, though). Cheers, Bert On Thu, Oct 24, 2013 at 6:13 AM, Thaler,Thorn,LAUSANNE,Applied Mathematics thorn.tha...@rdls.nestle.com wrote: Dear all, I was wondering whether (or better: how) I can use R to read recursively a directory to get all the sub-folders and files located in the root folder and put it into a tree like structure where the leaves are files and intermediate nodes are the directories? The idea is that I'd like to plot the structure of a certain root folder to be able to restructure the file system. Any ideas on that? I was googling a lot but apparently I did not use the right terms (R tree folder or R tree directory takes me mainly to pages about the R-tree a structure for spatial access methods [at least I learnt something new ;)]) Any pointer to the right function is highly appreciated. Cheers, Thorn Thaler NRC Lausanne Applied Mathematics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- +- Jan T. Kim ---+ | email: jtt...@gmail.com| | WWW: http://www.jtkim.dreamhosters.com/ | *-= hierarchical systems are for files, not for humans =-* __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot.raster hides the axis layer
This is by no means an explanation, but as a possible approach to consider: plot(0:1, 0:1, xaxt='n', asp=1) axis(1,at=c(0,1),labels=c(a,b)) plot(m,add=TRUE) -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 10/24/13 6:28 AM, Alaios ala...@yahoo.com wrote: Hi all, I am trying to plot a raster object (I can explain why but the point is that it would be a raster objeçt).. I have selected a small code to show you exactly the problem require(raster) test-matrix(data=runif(1),nrow=100) m-raster(test) plot(m,axes=FALSE) axis(1,at=c(0,1),labels=c(a,b)) # THIS DOES NOT CHANGE THE INVISIBLE AXIS WHILE plot(test,axes=FALSE) axis(1,at=c(0,1),labels=c(a,b)) # WHEN I AM PLOTTING A NON RASTER OBJECT THE AXIS APPEARS. Can someone explain me what I can do so a raster layer to show correctly the axis? Please remember that I have to do that on a raster object so coercing it will not help .. I would like to thank you in advance for your help Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R: Optional argument to be used in a subset function
I'm writing a function that needs an optional variable. If the variable is given, then a subset must be made using that variable, but if the variable is not given the subset must be done using all the values for that variable (ignoring that variable). Something like this: *band - function(file, fruit = apple, optional=TRUE) {* *data - read.csv(file)* *a - nrow(subset(data, 'Column 1' == fruit 'Column 2'==hot 'Column 3'== optional))* *b - nrow(subset(data,'Column 1' == fruit 'Column 2'==cold 'Column 3'== optional)) * *z - a+b* * print(z)* * }* What I need is that the function *band(file,orange)*, subset the data frame using all possible values for Column 3 but is not doing it. All ideas are welcome. Thanks. David Mora [[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] bug in dummy.coef?
Dear all, Running the following code produces an error in dummy.coef. I guess it might be a bug.. ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2, 10, 20, labels = c(Ctl,Trt)) weight - c(ctl, trt) x - rnorm(length(weight)) lm.D9 - lm(weight ~ group + x + I(x^2)) dummy.coef(lm.D9) Error in rep.int(xl[[i]][1L], nl) : invalid 'times' value sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 [4] LC_NUMERIC=CLC_TIME=Danish_Denmark.1252 attached base packages: [1] parallel splines stats graphics grDevices utils datasets methods base other attached packages: [1] pbkrtest_0.3-5MASS_7.3-26 Hmisc_3.12-2 Formula_1.1-1 survival_2.37-4 numDeriv_2012.9-1 [7] lmerTest_2.0-1lme4_1.1-1Matrix_1.0-12 lattice_0.20-15 loaded via a namespace (and not attached): [1] cluster_1.14.4 gdata_2.13.2 gplots_2.11.3 grid_3.0.1 gtools_3.0.0 minqa_1.2.1nlme_3.1-109 [8] rpart_4.1-1tools_3.0.1 With best wishes, Alexandra [[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] ordinal data with binary response
Dear R-users, I am trying to analyze data with ordinal independent variables and binary response . Could some one suggest me an appropriate statistic for this kind of analysis. Thanks, Regards, Kishir __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] track on boats
Hi professors I'm finding the best package in R for manage a big database about vessels. I need to divided the travel of each boat into tracks. I have GPS points. I would join these points in a line on the map. I make that with the function lines, but I can't divided by vessel or by track, I saw several packages, for tracking animals but they had specifically variables. And I don't add others like type,destination or status. Can you give me a suggestion, please [[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] XML package not working
Berend Thanks. I am aware of the missing kb's in the download. However, my problem is that it only happens with this package. I download other packages manually and via command-line install.packages() and Do not have any problems with completing full downloads of the entire file. Perhaps, if someone has the complete download for the XML package, both in *.zip and *tar formats that they can either email to me or allow me to ftp from it would help me to move forward with this resolve. Thanks... Steven -Original Message- From: Berend Hasselman [mailto:b...@xs4all.nl] Sent: Tuesday, October 22, 2013 12:39 PM To: Steven Dwayne Randolph Cc: Ista Zahn; r-help@r-project.org; stevendrando...@aol.com; Piyush Singh - Network Subject: Re: [R] XML package not working On 22-10-2013, at 15:19, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Ista,... Thank you for your response. Here is what is occurring when I attempt to command-line install. -- install.packages('XML') Installing package into 'C:/Users/xxx/Documents/R/win-library/3.0' (as 'lib' is unspecified) trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.0/XML_3.98-1.1.zip' Content type 'application/zip' length 4287270 bytes (4.1 Mb) opened URL downloaded 4.1 Mb Warning in install.packages : downloaded length 4276224 != reported length 4287270 Look at what is reported here. The downloaded length is not equal to the reported (i.e. actual) length of the zip. What is the length if you download the .zip file manually? So something has gone wrong with the download. Can you open a .zip file in another program? If so see what happens if you open it in that program. You have to do detective work. Berend Warning in install.packages : error 1 in extracting from zip file Warning in install.packages : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection -- STeven -Original Message- From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Tuesday, October 22, 2013 8:09 AM To: Steven Dwayne Randolph Cc: Duncan Murdoch; r-help@r-project.org; stevendrando...@aol.com; Piyush Singh - Network Subject: Re: [R] XML package not working Hi Steven, I still don't understand why you are downloading it manually. What happens when you install.packages(XML) ? Best, Ista On Tue, Oct 22, 2013 at 8:03 AM, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Duncan... Thank you. 1. I am able to download the XML file via my corporate network, other packages without this same issue, even rcurl and bitops which are pre-requisites on the same page as XML. 2. I have attempted to download this from my own wifi at home using xfinity/Comcast to my personal pc and still get the same error on this package alone. 3. I am genuinely baffled by this package download and install experience. 4. I would gladly build this from source, If indeed I could find the source and then use RTools to compile it. That has been unsuccessful as well. Nightmare? Slightly. Thanks for your response. Steven -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, October 20, 2013 12:13 PM To: Steven Dwayne Randolph; r-help@r-project.org; Ista Zahn Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-20 9:23 AM, Steven Dwayne Randolph wrote: My apologies for not conforming to the posting guideline. Sys.info() sysname release version Windows 7 x64 build 7601, Service Pack 1 nodename machine login xxNU247BZ1S x86-64 XX user effective_user xxxxxx When I attempt to install a local copy of the xml.zip file: in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' I think it is pretty clear that the problem is at your end: you aren't downloading the file properly, even though everyone else is. Perhaps you are behind a firewall, or something
[R] Making a function and applying it over a list(?)
Hi All I've gotten some awesome help getting a formular that finds the intersection of two vectors. This works brilliantly, but I can't figure out how to make it run over another factor. A simple example looks likes this: df - data.frame( id = factor(rep(c(supply, demand), each = 10)), price= c(5,7,9,11,13,15,17,19,21,23,20,18,16,14,12,10,8,6,4,2 ), quantity = c(3,5,7,13,19,31,37,53,61,67,6,18,20,24,40,46,66,70,76,78) ) quantity_points - with( df, seq(min(quantity), max(quantity), length.out = 500) ) by_id - split(df[, c(price, quantity)], df$id) interpolated_price - lapply( by_id, function(x) { with( x, approx( quantity, price, xout = quantity_points ) )$y } ) index_of_equality - with(interpolated_price, which.min(abs(supply - demand))) quantity_points[index_of_equality] Question: I need to run this over a larger data frame, where I have the same data, but also a new factor variable (called hour). So if you have the original data frame and add: df - data.frame( hour = factor(seq(1:20)), id = factor(rep(c(supply, demand), each = 10)), price= c(5,7,9,11,13,15,17,19,21,23,20,18,16,14,12,10,8,6,4,2 ), quantity = c(3,5,7,13,19,31,37,53,61,67,6,18,20,24,40,46,66,70,76,78) ) How can I run it for each hour? I tried using: by_hour - split(df[, c(price, quantity)], df$hour) mapply(fx, by_hour) And gathering the above into a fx - function(){the neat code}, but I can't get it to work. Kind Regards, Lasse [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R: Optional argument to be used in a subset function
On 24-10-2013, at 16:15, David Mora dmv...@gmail.com wrote: I'm writing a function that needs an optional variable. If the variable is given, then a subset must be made using that variable, but if the variable is not given the subset must be done using all the values for that variable (ignoring that variable). Something like this: *band - function(file, fruit = apple, optional=TRUE) {* *data - read.csv(file)* *a - nrow(subset(data, 'Column 1' == fruit 'Column 2'==hot 'Column 3'== optional))* *b - nrow(subset(data,'Column 1' == fruit 'Column 2'==cold 'Column 3'== optional)) * *z - a+b* * print(z)* * }* What I need is that the function *band(file,orange)*, subset the data frame using all possible values for Column 3 but is not doing it. All ideas are welcome. Thanks. David Mora [[alternative HTML version deleted]] Please do not post in HTML. And make stuff bold: in plain text it is converted to things like this: * }* which nonsense for R. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ordinal data with binary response
Kishor, It sounds like you will need to use logistic regression. Although the following URL might help you better understand logistic regression, http://ww2.coastal.edu/kingw/statistics/R-tutorials/logistic.html it would probably be most helpful if you would see help from a local statistician. John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Kishor Tappita kishor.tapp...@gmail.com 10/24/2013 5:15 AM Dear R-users, I am trying to analyze data with ordinal independent variables and binary response . Could some one suggest me an appropriate statistic for this kind of analysis. Thanks, Regards, Kishir __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] track on boats
It is difficult to advise you when you don't provide reproducible data. For example, you could include the first 6 lines of your data using dput(head(mydata)) If you have GPS points stored as easting, northing, and if you have a variable that identifies the vessel, and if your data are sorted by date and time, then you might be able to get the plot you want using something like this: plot(easting[vessel=This One], northing[vessel=This One], type=l) Jean On Thu, Oct 24, 2013 at 4:40 AM, Marta Tobeña marta_...@hotmail.com wrote: Hi professors I'm finding the best package in R for manage a big database about vessels. I need to divided the travel of each boat into tracks. I have GPS points. I would join these points in a line on the map. I make that with the function lines, but I can't divided by vessel or by track, I saw several packages, for tracking animals but they had specifically variables. And I don't add others like type,destination or status. Can you give me a suggestion, please [[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] installing package from source
On Oct 23, 2013, at 7:53 PM, Long Vo wrote: Hi R users, Currently I want to fit a FIGARCH model to a dataset. The only package that allow for it that I could find is fGarch. However it seems that the FIGARCH model class fitting of this package has been moved to Oxmetrics. I tried to install the old versions of it using 'tar.gz' files from CRAN archive http://cran.r-project.org/src/contrib/Archive/fGarch/ http://cran.r-project.org/src/contrib/Archive/fGarch/ but not sure how it works. I tried install.packages(myfilepath\fGarch_260.71.tar.gz, repos = NULL, type=source) And received this error: Warning: invalid package './I:_R filesGarch_260.71.tar.gz' Error: ERROR: no packages specified Warning messages: 1: running command 'I:/01_RFI~1/INSTAL~1/R-30~1.1/bin/i386/R CMD INSTALL -l I:\01_R files\installment\R-3.0.1\library ./I:_R files Garch_260.71.tar.gz' had status 1 2: In install.packages(I:\001_R files\fGarch_260.71.tar.gz, repos = NULL, : installation of package ‘./I:_R filesGarch_260.71.tar.gz’ had non-zero exit status Any helps on this? I've aways specified the package names and their locations separately in my call to install.packages, but I don't know if that is always needed. It also appears that you have no / separator between your path and the file name. Regards, Long -- View this message in context: http://r.789695.n4.nabble.com/installing-package-from-source-tp4678928.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 Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ordinal data with binary response
Dear John, Thanks for the information. It is quite helpful. Regards, Kishor On Thu, Oct 24, 2013 at 9:24 PM, John Sorkin jsor...@grecc.umaryland.edu wrote: Kishor, It sounds like you will need to use logistic regression. Although the following URL might help you better understand logistic regression, http://ww2.coastal.edu/kingw/statistics/R-tutorials/logistic.html it would probably be most helpful if you would see help from a local statistician. John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Kishor Tappita kishor.tapp...@gmail.com 10/24/2013 5:15 AM Dear R-users, I am trying to analyze data with ordinal independent variables and binary response . Could some one suggest me an appropriate statistic for this kind of analysis. Thanks, Regards, Kishir __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Confidentiality Statement: This email message, including any attachments, is for ...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 in heatmap
Using your csv file, I get no error running the following code. SPIV2 - read.csv(C:/Temp/SPI V2.csv) heatmap(as.matrix(SPIV2), na.rm=TRUE) Perhaps you modified SPIV2 in some way prior to running heatmap()? Jean On Tue, Oct 22, 2013 at 10:29 AM, David Romero drom...@mda.cinvestav.mxwrote: Hi Jean ** ** Thank you for helping. No, there is no empty column or row. I join the data base. ** ** Regards ** ** David ** ** ** ** ** ** *De:* Adams, Jean [mailto:jvad...@usgs.gov] *Enviado el:* 22 de octubre de 2013 07:03 *Para:* David Romero *CC:* r-h...@stat.math.ethz.ch *Asunto:* Re: [R] Error in heatmap ** ** Do you have a row or column that is all missing? sum(apply(is.na(as.matrix(SPIV2)), 1, all)) 0 sum(apply(is.na(as.matrix(SPIV2)), 2, all)) 0 ** ** For example, this code m - as.matrix(mtcars) m[8, ] - NA heatmap(m, na.rm=TRUE) throws this error Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) ** ** Jean ** ** ** ** On Mon, Oct 21, 2013 at 1:04 PM, David Romero drom...@mda.cinvestav.mx wrote: Hi, Could you please help? Heatmap doesn't work with: heatmap(as.matrix(SPIV2),na.rm = T) Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) There are no 0 data rows or column Thanks a lot Regards --- David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Nonparametric k-way ANOVA
Sorry if this subject has been already dealt here. Which are some common tests for nonparametric k-way ANOVA? I have read about Kruskal-Wallis test as a kind of nonparametric one-way ANOVA, but I have not found anything about a general-setting (I mean k-way) nonparametric ANOVA. Can you recommend me a good R package (or other reliable software) for that? Looking forward to your answers, -- vicent @vginer_upv about.me/vginer_upv [[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] XML package not working
Have you tried to download from another CRAN mirror, e.g. http://cran.r-project.org/web/packages/XML/ More mirrors at http://cran.r-project.org/mirrors.html As already others said, it's very unlikely that this is not an issue on your end. /Henrik On Thu, Oct 24, 2013 at 4:54 AM, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Berend Thanks. I am aware of the missing kb's in the download. However, my problem is that it only happens with this package. I download other packages manually and via command-line install.packages() and Do not have any problems with completing full downloads of the entire file. Perhaps, if someone has the complete download for the XML package, both in *.zip and *tar formats that they can either email to me or allow me to ftp from it would help me to move forward with this resolve. Thanks... Steven -Original Message- From: Berend Hasselman [mailto:b...@xs4all.nl] Sent: Tuesday, October 22, 2013 12:39 PM To: Steven Dwayne Randolph Cc: Ista Zahn; r-help@r-project.org; stevendrando...@aol.com; Piyush Singh - Network Subject: Re: [R] XML package not working On 22-10-2013, at 15:19, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Ista,... Thank you for your response. Here is what is occurring when I attempt to command-line install. -- install.packages('XML') Installing package into 'C:/Users/xxx/Documents/R/win-library/3.0' (as 'lib' is unspecified) trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.0/XML_3.98-1.1.zip' Content type 'application/zip' length 4287270 bytes (4.1 Mb) opened URL downloaded 4.1 Mb Warning in install.packages : downloaded length 4276224 != reported length 4287270 Look at what is reported here. The downloaded length is not equal to the reported (i.e. actual) length of the zip. What is the length if you download the .zip file manually? So something has gone wrong with the download. Can you open a .zip file in another program? If so see what happens if you open it in that program. You have to do detective work. Berend Warning in install.packages : error 1 in extracting from zip file Warning in install.packages : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection -- STeven -Original Message- From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Tuesday, October 22, 2013 8:09 AM To: Steven Dwayne Randolph Cc: Duncan Murdoch; r-help@r-project.org; stevendrando...@aol.com; Piyush Singh - Network Subject: Re: [R] XML package not working Hi Steven, I still don't understand why you are downloading it manually. What happens when you install.packages(XML) ? Best, Ista On Tue, Oct 22, 2013 at 8:03 AM, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Duncan... Thank you. 1. I am able to download the XML file via my corporate network, other packages without this same issue, even rcurl and bitops which are pre-requisites on the same page as XML. 2. I have attempted to download this from my own wifi at home using xfinity/Comcast to my personal pc and still get the same error on this package alone. 3. I am genuinely baffled by this package download and install experience. 4. I would gladly build this from source, If indeed I could find the source and then use RTools to compile it. That has been unsuccessful as well. Nightmare? Slightly. Thanks for your response. Steven -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, October 20, 2013 12:13 PM To: Steven Dwayne Randolph; r-help@r-project.org; Ista Zahn Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-20 9:23 AM, Steven Dwayne Randolph wrote: My apologies for not conforming to the posting guideline. Sys.info() sysname release version Windows 7 x64 build 7601, Service Pack 1 nodename machine login xxNU247BZ1S x86-64 XX user effective_user xxxxxx When I attempt to install a local copy of the xml.zip file: in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In
Re: [R] installing package from source
On Oct 24, 2013, at 11:38 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 23, 2013, at 7:53 PM, Long Vo wrote: Hi R users, Currently I want to fit a FIGARCH model to a dataset. The only package that allow for it that I could find is fGarch. However it seems that the FIGARCH model class fitting of this package has been moved to Oxmetrics. I tried to install the old versions of it using 'tar.gz' files from CRAN archive http://cran.r-project.org/src/contrib/Archive/fGarch/ http://cran.r-project.org/src/contrib/Archive/fGarch/ but not sure how it works. I tried install.packages(myfilepath\fGarch_260.71.tar.gz, repos = NULL, type=source) And received this error: Warning: invalid package './I:_R filesGarch_260.71.tar.gz' Error: ERROR: no packages specified Warning messages: 1: running command 'I:/01_RFI~1/INSTAL~1/R-30~1.1/bin/i386/R CMD INSTALL -l I:\01_R files\installment\R-3.0.1\library ./I:_R files Garch_260.71.tar.gz' had status 1 2: In install.packages(I:\001_R files\fGarch_260.71.tar.gz, repos = NULL, : installation of package ‘./I:_R filesGarch_260.71.tar.gz’ had non-zero exit status Any helps on this? I've aways specified the package names and their locations separately in my call to install.packages, but I don't know if that is always needed. It also appears that you have no / separator between your path and the file name. Long is trying to install a rather old version of the source R package that contains FORTRAN code on Windows. Besides the immediate error in the way the path was constructed in the install.packages() call, using a single backslash, which needs to be escaped: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file there are likely to be issues from trying to install an old version of the package on a newer version of R, perhaps the lack of the requisite development tools for compiling FORTRAN: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-install-packages-into-libraries-in-this-version_003f and other issues as well. Depending upon how far back you need to go in package versions, there may be pre-compiled Windows binaries (.zip files) available in directories here: http://cran.r-project.org/bin/windows/contrib/ Regards, Marc Schwartz Regards, Long __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 coordinates when trying to draw lines into a raster (image) file
Rick, This uses a different approach than what you propose, but it gets the job done and perhaps you will find it helpful. Jean library(jpeg) # download image from internet for use in example # http://www.tootsie.com/wallpaper/wp_concord2_1344x1008.jpg img - readJPEG(c:/temp/wp_concord2_1344x1008.jpg) # define location of two yellow gumballs, could use locator() to get these coordinates px.x - c(172, 576) px.y - c(433, 657) # set up plot par(xaxs=i, yaxs=i) eqscplot(x, y, type=n, xlim=c(0, 1334), ylim=c(0, 1008)) # add image rasterImage(img, 0, 0, 1334, 1008) # add line connecting two yellow gumballs lines(px.x, px.y, lwd=5, col=yellow) On Mon, Oct 21, 2013 at 8:57 AM, Rick Turner ricktur...@btconnect.comwrote: Hi All, I am struggling with something, and could use some help I have a scenario where I need to draw lines onto a base image using R â briefly, the image has what amounts to an outline âmapâ of locations, and the lines will correspond to âroutesâ between two locations. The locations are known in terms of image pixel coordinates â letâs call them (px1, py1) and (px2, py2), but when I try and plot a line into the image using these coordinates, the visual positions are incorrect â the start and end points of the line are offset from the desired position, and the amount of offset changes as I resize the window. I've tried such things as normalising them into the [0,1] range used by the viewport but this does not correct the problem. So, I figured that I must have made some mistake with my scaling of coordinates from image to viewport, but I cannot find where or what. Iâve fiddled around a bit (well, a lot!) but cannot get the desired result. So, it is time to ask for help, hence this messageâ¦. Any suggestions gratefully received⦠Iâve done a fair amount of R programming, but have not used these extended graphics capabilities much at all, so I really am getting frustrated Regards and thanks in advance, Rick -- The code segment in question is: # load packages library(jpeg) library(grid) # read the image file baseimg - readJPEG(loc_map.jpg, native=FALSE) xsize - ncol(baseimg) # Get image size â this one is 1344 px wide ysize - nrow(baseimg) # and 1008 px high # create a viewport xrange - c(0, xsize)# set up the viewport range to match the image size yrange - c(0, ysize) vp - viewport(x=0.5, y=0.5, width=0.9, height=0.9, xscale=xrange, yscale=yrange) pushViewport(vp) grid.rect(gp=gpar(lty=dashed))# draw a dashed line around it. # display the base image grid.raster(baseimg) # First location â image pixel coordinates (748, 177). Normalise these to [0,1] to # match the viewpoint coordinate scheme. Note that we need to invert the # y coordinate as R coords run from bottom up, but image ones are top down px1 - (748/xsize)# 748/1344 ~= 0.556, so in range [0,1] py1 - (1.0 - (177/ysize)) # 1-(177/1008) ~= 0.824, so also in range [0,1] # position of the St Johns Hill enterance (image coords # [769, 892]) normalised to the viewport x2 - (769/xsize) y2 - (1.0 - (892/ysize)) # draw a line from pixel (px1,py1) to pixel (px2,py2) in blue xx - c(px1, px2) yy - c(py1, py2) grid.lines(xx, yy, gp=gpar(col=blue)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Nonparametric k-way ANOVA
On Oct 24, 2013, at 18:59 , Vicent Giner-Bosch wrote: Sorry if this subject has been already dealt here. Which are some common tests for nonparametric k-way ANOVA? I have read about Kruskal-Wallis test as a kind of nonparametric one-way ANOVA, but I have not found anything about a general-setting (I mean k-way) nonparametric ANOVA. Can you recommend me a good R package (or other reliable software) for that? Can you provide reliable _theory_ for it? Some people have tried just to do ANOVA decompositions after replacing observations by their ranks, and referring sums of squares to chi-squared distributions. However, that derivation only holds under the global null hypothesis. In general, it is problematic to define additivity and interaction in a nonparametric setting since there are no parameters that effects can be additive in! Stratified tests do exist and make OK sense. In those, you split data into groups and do the rank sums within groups, then look at a weighted sum of the group rank sums, work out the mean and variance assuming no effect in any group, etc. For a two-way layout without replications, this is friedman.test(). I believe the coin package implements some more general cases. -pd Looking forward to your answers, -- vicent @vginer_upv about.me/vginer_upv [[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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] installing package from source
On 24/10/2013 18:25, Marc Schwartz wrote: On Oct 24, 2013, at 11:38 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 23, 2013, at 7:53 PM, Long Vo wrote: Hi R users, Currently I want to fit a FIGARCH model to a dataset. The only package that allow for it that I could find is fGarch. However it seems that the FIGARCH model class fitting of this package has been moved to Oxmetrics. I tried to install the old versions of it using 'tar.gz' files from CRAN archive http://cran.r-project.org/src/contrib/Archive/fGarch/ http://cran.r-project.org/src/contrib/Archive/fGarch/ but not sure how it works. I tried install.packages(myfilepath\fGarch_260.71.tar.gz, repos = NULL, type=source) And received this error: Warning: invalid package './I:_R filesGarch_260.71.tar.gz' Error: ERROR: no packages specified Warning messages: 1: running command 'I:/01_RFI~1/INSTAL~1/R-30~1.1/bin/i386/R CMD INSTALL -l I:\01_R files\installment\R-3.0.1\library ./I:_R files Garch_260.71.tar.gz' had status 1 2: In install.packages(I:\001_R files\fGarch_260.71.tar.gz, repos = NULL, : installation of package ‘./I:_R filesGarch_260.71.tar.gz’ had non-zero exit status Any helps on this? I've aways specified the package names and their locations separately in my call to install.packages, but I don't know if that is always needed. It also appears that you have no / separator between your path and the file name. Long is trying to install a rather old version of the source R package that contains FORTRAN code on Windows. Besides the immediate error in the way the path was constructed in the install.packages() call, using a single backslash, which needs to be escaped: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file there are likely to be issues from trying to install an old version of the package on a newer version of R, perhaps the lack of the requisite development tools for compiling FORTRAN: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-install-packages-into-libraries-in-this-version_003f and other issues as well. Depending upon how far back you need to go in package versions, there may be pre-compiled Windows binaries (.zip files) available in directories here: http://cran.r-project.org/bin/windows/contrib/ I don't think so: see NEWS CHANGES IN R 3.0.0: SIGNIFICANT USER-VISIBLE CHANGES: • Packages need to be (re-)installed under this version (3.0.0) of R. so only those under bin/windows/contrib/3.0 will work, and there is only one for each package. -- 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] How can I use a script l (LaTeX \ell) in mathematical annotation of plots?
Thanks. That works for me too. I had worked that out based on Brian's response to my original post. If you read thru my response to him in detail, you'll see: Here are a couple of examples using it that worked: plot(1:10,xlab=\u2113) plot(1:10,xlab=\u2113(\u2113 + 1)) From: Eik Vettorazzi e.vettora...@uke.de To: Byron Dom byron_...@yahoo.com; r help r-help@r-project.org Cc: rip...@stats.ox.ac.uk rip...@stats.ox.ac.uk Sent: Thursday, October 24, 2013 2:50 AM Subject: Re: [R] How can I use a script l (LaTeX \ell) in mathematical annotation of plots? this works for me: plot(1,main=\u2113) cheers Am 24.10.2013 01:39, schrieb Byron Dom: Original post: On 13/10/2013 18:53, Byron Dom wrote: Due to convention a script l - $$\ell$$ (LaTeX \ell) is used to represent a certain quantity in something I'm working on. I'm unable to figure out how to use it in R. It's not included in the list on ?plotmath. Can anyone tell me how to use it? Its unicode is U+2113. This page has a list of various encodings of it: http://www.fileformat.info/info/unicode/char/2113/encoding.htm. Is there a way to include it by using one of these encodings somehow? - On 13/10/2013 22:06 Prof Brian Ripley responded: What do you want to do with it? plotmath is about plotting, but you have not otherwise mentioned that, let alone the device on which you want to plot. Read the help for plotmath: on some plot devices, just use \u2113. It is not AFAICS in the Adobe symbol encoding. -- Brian D. Ripley, ripley at 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, UK Fax: +44 1865 272595 - My response: Thanks I worked out how to do it based on your mention of u2113. See below. I'm sorry if my information wasn't complete enough. I assumed that what I said, combined with the subject (How can I use a script l (LaTeX \ell) in mathematical annotation of plots?) would have been enough. I just wanted to be able to do this on the default device, which displays plots within the R session window. I have a simple path to go from there to .png form, which I include in LaTeX documents and for other purposes. I am using R version 3.0.1 in Windows 7, for which I believe the default plot device is windows. An example of the kind of thing I wanted to do is to include ylab = expression(hat(gamma)) (which is equivalent to the LaTex \hat{\gamma}}) among the base-graphics plot() arguments. That works. In LaTeX a script l is produced with \ell, but something like ylab = expression(ell) doesn't work in R. I wanted to be able to do the equivalent of that, but to obtain ℓ. Here are a couple of examples using it that worked: plot(1:10,xlab=\u2113) plot(1:10,xlab=\u2113(\u2113 + 1)) The only (slight) problem with this is the minor aesthetic issue that the ℓ one gets this way is in an obviously different font from what one gets using the LaTeX \lambda command/symbol. Strangely, earlier, when I tried plot(1:10,xlab=expression(symbol(\u2113))) it did the same thing as plot(1:10,xlab=expression(lambda)) So I got a lower-case greek lambda - λ, rather than ℓ (script l). When I used the unicode representation for lowercase lambda - λ - as follows plot(1:10,xlab=expression(symbol(\u03bb))) I got this for an x-axis label: Y+03BB. On the other hand, the following did work plot(1:10,xlab=\u03bb), giving me an x-axis label of lambda - λ. [[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. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Besuchen Sie uns auf: www.uke.de _ Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Rainer Schoppik _ SAVE PAPER - THINK BEFORE PRINTING __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide
Re: [R] installing package from source
On Oct 24, 2013, at 1:11 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On 24/10/2013 18:25, Marc Schwartz wrote: On Oct 24, 2013, at 11:38 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 23, 2013, at 7:53 PM, Long Vo wrote: Hi R users, Currently I want to fit a FIGARCH model to a dataset. The only package that allow for it that I could find is fGarch. However it seems that the FIGARCH model class fitting of this package has been moved to Oxmetrics. I tried to install the old versions of it using 'tar.gz' files from CRAN archive http://cran.r-project.org/src/contrib/Archive/fGarch/ http://cran.r-project.org/src/contrib/Archive/fGarch/ but not sure how it works. I tried install.packages(myfilepath\fGarch_260.71.tar.gz, repos = NULL, type=source) And received this error: Warning: invalid package './I:_R filesGarch_260.71.tar.gz' Error: ERROR: no packages specified Warning messages: 1: running command 'I:/01_RFI~1/INSTAL~1/R-30~1.1/bin/i386/R CMD INSTALL -l I:\01_R files\installment\R-3.0.1\library ./I:_R files Garch_260.71.tar.gz' had status 1 2: In install.packages(I:\001_R files\fGarch_260.71.tar.gz, repos = NULL, : installation of package ‘./I:_R filesGarch_260.71.tar.gz’ had non-zero exit status Any helps on this? I've aways specified the package names and their locations separately in my call to install.packages, but I don't know if that is always needed. It also appears that you have no / separator between your path and the file name. Long is trying to install a rather old version of the source R package that contains FORTRAN code on Windows. Besides the immediate error in the way the path was constructed in the install.packages() call, using a single backslash, which needs to be escaped: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file there are likely to be issues from trying to install an old version of the package on a newer version of R, perhaps the lack of the requisite development tools for compiling FORTRAN: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-install-packages-into-libraries-in-this-version_003f and other issues as well. Depending upon how far back you need to go in package versions, there may be pre-compiled Windows binaries (.zip files) available in directories here: http://cran.r-project.org/bin/windows/contrib/ I don't think so: see NEWS CHANGES IN R 3.0.0: SIGNIFICANT USER-VISIBLE CHANGES: • Packages need to be (re-)installed under this version (3.0.0) of R. so only those under bin/windows/contrib/3.0 will work, and there is only one for each package. Ah, OK. Thanks for noting that Prof. Ripley. So, Long will need to make some decisions here and it may be worth contacting the fGARCH package maintainer to get any relevant insights into potential gotchas installing an older version of the package on a recent version of R, even from source after installing the needed tools, or having to revert to an older version of R to support the installation of the older package. Older Windows binaries of R releases are available from: http://cran.r-project.org/bin/windows/base/old/ and R 2.6.1 would be about the release that corresponds to the particular version of fGARCH being used above, which is late 2007. Regards, Marc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 in scan?
Obviously row 11 is incomplete. It may contain nothing more than a space or an EOL. Using the fill=TRUE argument to 'scan' or 'read.table' is your friend here. -- View this message in context: http://r.789695.n4.nabble.com/Error-in-scan-tp4678976p4678982.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] Text in a plot without x axis
Dear R users, Can I add a text to a plot without x axis? I saw a function that enables placing the text with mouse text(location, text to place, pos, ...) locator(1) but it did not work out. -- Ahmed M. Attia Research Assistant Dept. Of SoilCrop Sciences Texas AM University ahmed.at...@ag.tamu.edu Cell phone: 001-979-248-5215 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] test wilcoxon sur R help!
Hi, Try: fun1 - function(dat){ mat1 - combn(colnames(dat1),2) res - sapply(seq_len(ncol(mat1)),function(i) {x1- dat[,mat1[,i]]; wilcox.test(x1[,1],x1[,2])$p.value}) names(res) - apply(mat1,2,paste,collapse=_) res } set.seed(432) dat1 - as.data.frame(matrix(sample(18*10,18*10,replace=FALSE),ncol=18)) fun1(dat1) #gives the p-value for each pair of columns Hi, I want to make a wilcoxon test, i have 18 columns each column corresponds to a different sample and i want to compare one to each other with a wilcoxon test in one step this is possible ? or do i compare two by tow? Does it exist a code for automation this test? like this i dont have to type the code for each couple. thanks! denisse __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 in heatmap
David, You should cc r-help on all correspondence so others can follow the thread. The error appears to be a result of the missing values yielded by the dist() function on your matrix. See https://stat.ethz.ch/pipermail/r-help/2009-July/204443.html. Jean On Thu, Oct 24, 2013 at 1:25 PM, David Romero drom...@mda.cinvestav.mxwrote: Hi, ** ** The difference is: row.names=1 for csv reading. The first column is a numeric row name, it mustn't take part of the heatmap. ** ** I change it to text and try with and without row.names=1 Both give me error. ** ** Regards ** ** David ** ** *De:* Adams, Jean [mailto:jvad...@usgs.gov] *Enviado el:* 24 de octubre de 2013 11:52 *Para:* David Romero *CC:* R help *Asunto:* Re: [R] Error in heatmap ** ** Using your csv file, I get no error running the following code. SPIV2 - read.csv(C:/Temp/SPI V2.csv) heatmap(as.matrix(SPIV2), na.rm=TRUE) Perhaps you modified SPIV2 in some way prior to running heatmap()? ** ** Jean ** ** ** ** ** ** On Tue, Oct 22, 2013 at 10:29 AM, David Romero drom...@mda.cinvestav.mx wrote: Hi Jean Thank you for helping. No, there is no empty column or row. I join the data base. Regards David *De:* Adams, Jean [mailto:jvad...@usgs.gov] *Enviado el:* 22 de octubre de 2013 07:03 *Para:* David Romero *CC:* r-h...@stat.math.ethz.ch *Asunto:* Re: [R] Error in heatmap Do you have a row or column that is all missing? sum(apply(is.na(as.matrix(SPIV2)), 1, all)) 0 sum(apply(is.na(as.matrix(SPIV2)), 2, all)) 0 For example, this code m - as.matrix(mtcars) m[8, ] - NA heatmap(m, na.rm=TRUE) throws this error Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) Jean On Mon, Oct 21, 2013 at 1:04 PM, David Romero drom...@mda.cinvestav.mx wrote: Hi, Could you please help? Heatmap doesn't work with: heatmap(as.matrix(SPIV2),na.rm = T) Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) There are no 0 data rows or column Thanks a lot Regards --- David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Custom x axis in a boxplot
Dear R users, How can I customize x axis in a boxplot? xaxt=n to suppress x axis, but I would like to customize x axis for different groups. Thanks -- Ahmed M. Attia Research Assistant Dept. Of SoilCrop Sciences Texas AM University ahmed.at...@ag.tamu.edu Cell phone: 001-979-248-5215 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 k-way ANOVA
Depends on what the original poster really wants with a nonparametric k-way ANOVA. If what they are really looking for is an approach that has fewer distributional assumptions, then it is possible to perform permutation tests for linear models parameterized for k-way anova that would eliminated the normal distribution assumption for the error term but would certainly involve estimating parameters (including possible interactions.) Marti Anderson and Pierre Legendre have implemented these sorts of permutation tests for models involving means and I've implemented them for models of quantiles. Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: ca...@usgs.gov brian_c...@usgs.gov tel: 970 226-9326 On Thu, Oct 24, 2013 at 12:00 PM, peter dalgaard pda...@gmail.com wrote: On Oct 24, 2013, at 18:59 , Vicent Giner-Bosch wrote: Sorry if this subject has been already dealt here. Which are some common tests for nonparametric k-way ANOVA? I have read about Kruskal-Wallis test as a kind of nonparametric one-way ANOVA, but I have not found anything about a general-setting (I mean k-way) nonparametric ANOVA. Can you recommend me a good R package (or other reliable software) for that? Can you provide reliable _theory_ for it? Some people have tried just to do ANOVA decompositions after replacing observations by their ranks, and referring sums of squares to chi-squared distributions. However, that derivation only holds under the global null hypothesis. In general, it is problematic to define additivity and interaction in a nonparametric setting since there are no parameters that effects can be additive in! Stratified tests do exist and make OK sense. In those, you split data into groups and do the rank sums within groups, then look at a weighted sum of the group rank sums, work out the mean and variance assuming no effect in any group, etc. For a two-way layout without replications, this is friedman.test(). I believe the coin package implements some more general cases. -pd Looking forward to your answers, -- vicent @vginer_upv about.me/vginer_upv [[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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Text in a plot without x axis
You should provide an example of what you are trying to do. Try this plot(0, 1, xlab=, xaxt=n) text(locator(1), This is my text, xpd=TRUE) The xpd= parameter controls the clipping region. The default xpd=FALSE clips text to the plot region. You were not clear, but if you were trying to plot outside the axes, you need xpd=TRUE to clip to the figure region or xpd=NA to clip to the device region. - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ahmed Attia Sent: Thursday, October 24, 2013 2:10 PM To: r-help@r-project.org Subject: [R] Text in a plot without x axis Dear R users, Can I add a text to a plot without x axis? I saw a function that enables placing the text with mouse text(location, text to place, pos, ...) locator(1) but it did not work out. -- Ahmed M. Attia Research Assistant Dept. Of SoilCrop Sciences Texas AM University ahmed.at...@ag.tamu.edu Cell phone: 001-979-248-5215 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] labeling abscissa using a function of the plotted scale
On Oct 24, 2013, at 7:00 AM, Hurr wrote: Thanks Jim, maybe now I can start learning. Here is a run of my trying to learn: xvalue-c(5.2,1.3,9.7,2.8,8.1,4.7,6.6,7.4) yvalue-c(9,3,4,7,2,5,3,6) plot(xvalue,yvalue) axis(1,at=NULL,labels=1/xvalue,digits=5) Error in axis(1, at = NULL, labels = 1/xvalue, digits = 5) : 'labels' is supplied and not 'at' In addition: Warning message: In axis(1, at = NULL, labels = 1/xvalue, digits = 5) : digits is not a graphical parameter Why can't R automatically compute the spacing when I use the formula? I don't see any formula. If you are talking about the expression `1/xvalue`, it is going to be a decimal fraction and it will be coerced to a character value before being assigned to 'labels'. As explained in the help page for `axis`, when at is left as NULL, the positions will be computed from par(xaxt). But you gave only a numeric argument to labels and did not tell axis where you wanted these values were to be placed. If those values were interpreted as being positions they would have been off the left side of the paper. If you don't like the way 'axis' works, you are welcome to write a new axis function that processes numeric arguments to labels differently. But in this case you appear to think that R kept a record someplace of the argument to x in the preceding plot. _That_ is wishful thinking on your part. If you want a plotting paradigm that may record x and y values, then look at lattice or ggplot2. Base graphics is mostly ( memoryless ) ink-on-paper, although there may be some information accessible via `par`. How can I specify n-digits or width instead of round or nothing? ?sprintf ?formatC -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Custom x axis in a boxplot
?axis - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ahmed Attia Sent: Thursday, October 24, 2013 2:24 PM To: r-help@r-project.org Subject: [R] Custom x axis in a boxplot Dear R users, How can I customize x axis in a boxplot? xaxt=n to suppress x axis, but I would like to customize x axis for different groups. Thanks -- Ahmed M. Attia Research Assistant Dept. Of SoilCrop Sciences Texas AM University ahmed.at...@ag.tamu.edu Cell phone: 001-979-248-5215 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] test wilcoxon sur R help!
Hello, There's a bug in your function, it should be 'dat', not 'dat1'. In the line marked, below. fun1 - function(dat){ mat1 - combn(colnames(dat),2) # Here, 'dat' not 'dat1' res - sapply(seq_len(ncol(mat1)),function(i) {x1- dat[,mat1[,i]]; wilcox.test(x1[,1],x1[,2])$p.value}) names(res) - apply(mat1,2,paste,collapse=_) res } Hope this helps, Rui Barradas Em 24-10-2013 20:16, arun escreveu: Hi, Try: fun1 - function(dat){ mat1 - combn(colnames(dat1),2) res - sapply(seq_len(ncol(mat1)),function(i) {x1- dat[,mat1[,i]]; wilcox.test(x1[,1],x1[,2])$p.value}) names(res) - apply(mat1,2,paste,collapse=_) res } set.seed(432) dat1 - as.data.frame(matrix(sample(18*10,18*10,replace=FALSE),ncol=18)) fun1(dat1) #gives the p-value for each pair of columns Hi, I want to make a wilcoxon test, i have 18 columns each column corresponds to a different sample and i want to compare one to each other with a wilcoxon test in one step this is possible ? or do i compare two by tow? Does it exist a code for automation this test? like this i dont have to type the code for each couple. thanks! denisse __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 parsing from .txt
Hi, You may try: ?list.files() nm1 - list.files(pattern=.txt) res - lapply(nm1,function(x) { ln1 - readLines(x) indx1 - grep(DATE PROCESSED,ln1) indx2 - grep([A-Z],ln1) ln2 - if(max(indx2)==indx1) ln1[1:length(ln1)] else ln1[1:(indx2[match(indx1,indx2)+1]-1)] ln2 - ln2[ln2!=] indx3 - grepl([A-Z],ln2) indx4 - cumsum(c(TRUE,diff(which(!indx3))1)) mat1 - do.call(cbind, split(ln2[!indx3],indx4)) colnames(mat1) - ln2[indx3][-1] write.table(mat1,paste0(ln2[indx3][1],.txt),row.names=FALSE,quote=FALSE,sep=\t)}) A.K. I have a number of .txt files (1,200) from which I need to parse a number of pieces of information. The files are read into R as such: TITLE EXAMPLE example 1 example 2 RELATED TITLE related title 1 DATE PROCESSED 06/12/2011 Some of the files have examples 1-4, others 1-12 and beyond. How can I create a script that will grab the information from the different .txt files, put it in a matrix, and spit it out in a .csv file with appropriately named columns (the column titles are in CAPS above, where the information that will in the column is lower case). Thanks in advance. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] track on boats
There are several packages for track data on CRAN and they don't all force the data to have specific variables beyond position, date-time, track ID. With trip you can do this easily enough, but depending on your needs adehabitatLT or move might be better. I wrote trip so I know that you can do this (pseudo code that assumes columns X, Y, date, ID for the obvious components), you get plot control of separate lines and basic data QC for free (welcome or not): library(trip) d - read.csv(myfile.csv) ## sort out date-times d$datetime - as.POSIXct(d$date, [format etc]) ## specify the X/Y coordinates (use your relevant column names) coordinates(d) - c(X, Y) ## create trip object tr - trip(d, c(datetime, ID)) (If your data are out of order by ID,time or if there are duplicates or missing values or other problems that will complain and not make assumptions, but these are things that should be dealt with explicitly IMO.) ## then you can plot the separate tracks in a minimal way plot(tr) lines(tr) There is general support for reading and manipulating spatial data with packages sp, raster, maptools and friends. See the Spatial and SpatioTemporal Task Views, and consider R-Sig-Geo rather than R-help for questions like this. I agree that Animal Tracking is too specific for your needs, but there's certainly room for generalizing this to other domains easily enough. The trip package is too simple and awkward for many things, but for basic use there's no built-in assumptions that track data are from animals (though the label on the lid does specify that). HTH On Fri, Oct 25, 2013 at 3:08 AM, Adams, Jean jvad...@usgs.gov wrote: It is difficult to advise you when you don't provide reproducible data. For example, you could include the first 6 lines of your data using dput(head(mydata)) If you have GPS points stored as easting, northing, and if you have a variable that identifies the vessel, and if your data are sorted by date and time, then you might be able to get the plot you want using something like this: plot(easting[vessel=This One], northing[vessel=This One], type=l) Jean On Thu, Oct 24, 2013 at 4:40 AM, Marta Tobeña marta_...@hotmail.com wrote: Hi professors I'm finding the best package in R for manage a big database about vessels. I need to divided the travel of each boat into tracks. I have GPS points. I would join these points in a line on the map. I make that with the function lines, but I can't divided by vessel or by track, I saw several packages, for tracking animals but they had specifically variables. And I don't add others like type,destination or status. Can you give me a suggestion, please [[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. -- Michael Sumner Hobart, Australia e-mail: mdsum...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] track on boats
A good choice might be to store your data in objects of class SpatialLinesDataFrame Then you can assign any attributes you want to each line, such as your vessel, type, destination, or status. This will make it relatively easy to, for example, plot subsets of tracks specified by different attributes. SpatialLinesDataFrame objects are defined in the sp package. For further help, I would suggest the r-sig-geo mailing list. Also look at the CRAN Task View Spatial. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 10/24/13 2:40 AM, Marta Tobeña marta_...@hotmail.com wrote: Hi professors I'm finding the best package in R for manage a big database about vessels. I need to divided the travel of each boat into tracks. I have GPS points. I would join these points in a line on the map. I make that with the function lines, but I can't divided by vessel or by track, I saw several packages, for tracking animals but they had specifically variables. And I don't add others like type,destination or status. Can you give me a suggestion, please [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to calculate running 8-hour averages of temperature
Hi, You may try ?rollmean from library(zoo) ?SMA from library(TTR) dat1 - structure(... library(zoo) res1 - rollmean(dat1[-c(1:5),2],8) library(TTR) res2 - SMA(dat1[-c(1:5),2],8) all.equal(res1,res2[!is.na(res2)]) #[1] TRUE A.K. Hi, How can I calculate running 8-hour averages of temperature values that start at specific date and time? In the example data set shown below I want to start the calculation on May 31, at 5pm (row 6). Reproducible data is provided. Thanks structure(list(date = structure(c(644148000, 644151600, 644155200, 644158800, 644162400, 644166000, 644169600, 644173200, 644176800, 644180400, 644184000, 644187600, 644191200, 644194800, 644198400, 644202000, 644205600, 644209200, 644212800, 644216400, 64422, 644223600, 644227200, 644230800, 644234400, 644238000, 644241600, 644245200, 644248800, 644252400, 644256000), class = c(POSIXct, POSIXt), tzone = ), temp = c(17.7, 18.3, 18.9, 19.7, 19.5, 19, 18.8, 18, 16.3, 15.1, 13.9, 12.7, 11.9, 10.6, 10, 8.7, 7.8, 8.0, 9.2, 12.4, 14.5, 15.9, 17.4, 18.6, 18.3, 18.4, 18.5, 20.4, 19.7, 18.9, 18.1)), .Names = c(date, temp), row.names = 3613:3643, class = data.frame) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] bug in dummy.coef?
I agree that this seems to be a bug, but OTOH the help for dummy.coef() *does* say: The method used has some limitations, and will give incomplete results for terms such as |poly(x, 2)|. (Note that it says it will give incomplete results not throw an error!) Looking into the code of dummy.coef.lm() I find that the problem seems to reside in all.vars(). When all.vars(Terms) is applied inside dummy.coef.lm() it returns [1] group x rather than [1] group x I(x^2) which is what I think it should return. The workings of all.vars() are buried in the bowels of the internal structure, so I can take it no farther. Whether there is a practical way to make all.vars() do the right thing in this setting I know not. Perhaps one of the Big Guns can provide some insight. As a workaround, you can do: x2 - x^2 lm.D9 - lm(weight ~ group + x + x2) dummy.coef(lm.D9) This worked for me, at least. cheers, Rolf Turner On 10/24/13 21:51, Alexandra Kuznetsova wrote: Dear all, Running the following code produces an error in dummy.coef. I guess it might be a bug.. ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2, 10, 20, labels = c(Ctl,Trt)) weight - c(ctl, trt) x - rnorm(length(weight)) lm.D9 - lm(weight ~ group + x + I(x^2)) dummy.coef(lm.D9) Error in rep.int(xl[[i]][1L], nl) : invalid 'times' value sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 [4] LC_NUMERIC=CLC_TIME=Danish_Denmark.1252 attached base packages: [1] parallel splines stats graphics grDevices utils datasets methods base other attached packages: [1] pbkrtest_0.3-5MASS_7.3-26 Hmisc_3.12-2 Formula_1.1-1 survival_2.37-4 numDeriv_2012.9-1 [7] lmerTest_2.0-1lme4_1.1-1Matrix_1.0-12 lattice_0.20-15 loaded via a namespace (and not attached): [1] cluster_1.14.4 gdata_2.13.2 gplots_2.11.3 grid_3.0.1 gtools_3.0.0 minqa_1.2.1nlme_3.1-109 [8] rpart_4.1-1tools_3.0.1 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] labeling abscissa using a function of the plotted scale
On 10/25/2013 01:00 AM, Hurr wrote: Thanks Jim, maybe now I can start learning. Here is a run of my trying to learn: xvalue-c(5.2,1.3,9.7,2.8,8.1,4.7,6.6,7.4) yvalue-c(9,3,4,7,2,5,3,6) plot(xvalue,yvalue) axis(1,at=NULL,labels=1/xvalue,digits=5) Error in axis(1, at = NULL, labels = 1/xvalue, digits = 5) : 'labels' is supplied and not 'at' In addition: Warning message: In axis(1, at = NULL, labels = 1/xvalue, digits = 5) : digits is not a graphical parameter Why can't R automatically compute the spacing when I use the formula? How can I specify n-digits or width instead of round or nothing? Hi Hurr, Let's see, suppose I answered your message like this: answer1-NULL You would be in the same position as the axis function. You have to tell the axis function where the labels are to be placed, or it can't place them there. Now for your second question. Suppose my answer was something like this: answer2-wpsovmeksjhfhtieur # language = Magungian You might well respond that you don't understand Magungian. The argument digits doesn't tell the axis function anything useful. If you want labels with a certain number of digits, create them before you call the axis function: mylabels-round(1/xvalue,digits=5) The round function understands Magungian. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] labeling abscissa using a function of the plotted scale
Thanks David, did I use incorrect english to call labels = 1/xvalue a formula or function? Seems to me an obvious first try would be to place the labels where they would have been placed without the formula. I haven't yet, but I will study from your suggestions. -- View this message in context: http://r.789695.n4.nabble.com/labeling-abscissa-using-a-function-of-the-plotted-scale-tp4678075p4679004.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] bug in dummy.coef?
On Oct 24, 2013, at 1:51 AM, Alexandra Kuznetsova wrote: Dear all, Running the following code produces an error in dummy.coef. I guess it might be a bug.. ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2, 10, 20, labels = c(Ctl,Trt)) weight - c(ctl, trt) x - rnorm(length(weight)) lm.D9 - lm(weight ~ group + x + I(x^2)) dummy.coef(lm.D9) Error in rep.int(xl[[i]][1L], nl) : invalid 'times' value As Rolf Turner pointed out the help page says there are limitations to that function and its only desiged for specific purposes. What are you trying to accomplish? -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] labeling abscissa using a function of the plotted scale
On Oct 24, 2013, at 3:56 PM, Hurr wrote: Thanks David, did I use incorrect english to call e a formula or function? Incorrect R terminology. A function in R is a specific sort of object and a formula is a different sort of object. R terminology for the use of labels = 1/xvalue inside the arguments to a function may be something along the lines of assignment in a pairlist. I was rather loosely calling it an expression. Seems to me an obvious first try would be to place the labels where they would have been placed without the formula. And as I said in the context you have failed to include was that R does not rememeber or store the locations where where they would have been placed without the formula. It doesn't have access to the arguments used in the prior plot call. I haven't yet, but I will study from your suggestions. -- View this message in context: http://r.789695.n4.nabble.com/labeling-abscissa-using-a-function-of-the-plotted-scale-tp4678075p4679004.html Sent from the R help mailing list archive at Nabble.com. Nabble is not R-help. Please read the Posting Guide that Nabble suppresses in its effort to masquerade as Rhelp. This should have appeared at the bottom of every posting were it not for Nabble suppressing it: R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Making a function and applying it over a list(?)
You could store your first approach in a function and lapply it to your by_hour variable: df - data.frame( hour = factor(rep(1:5,4)), id = factor(rep(c(supply, demand), each = 10)), price= c(5,7,9,11,13,15,17,19,21,23, 20,18,16,14,12,10,8,6,4,2 ), quantity = c(3,5,7,13,19,31,37,53,61,67,6,18,20,24,40,46,66,70,76,78) ) myfu - function(x){ df - x # for simplicity quantity_points - with( df, seq(min(quantity), max(quantity), length.out = 500) ) by_id - split(df[, c(price, quantity)], df$id) interpolated_price - lapply( by_id, function(x) { with( x, approx( quantity, price, xout = quantity_points ) )$y } ) index_of_equality - with(interpolated_price, which.min(abs(supply - demand))) quantity_points[index_of_equality] } by_hour - split(df,df$hour) lapply(by_hour,myfu) Was that what you were looking for? Cheers, Christoph 2013/10/24 Lasse Thorst l...@energidanmark.dk: Hi All I've gotten some awesome help getting a formular that finds the intersection of two vectors. This works brilliantly, but I can't figure out how to make it run over another factor. A simple example looks likes this: df - data.frame( id = factor(rep(c(supply, demand), each = 10)), price= c(5,7,9,11,13,15,17,19,21,23,20,18,16,14,12,10,8,6,4,2 ), quantity = c(3,5,7,13,19,31,37,53,61,67,6,18,20,24,40,46,66,70,76,78) ) quantity_points - with( df, seq(min(quantity), max(quantity), length.out = 500) ) by_id - split(df[, c(price, quantity)], df$id) interpolated_price - lapply( by_id, function(x) { with( x, approx( quantity, price, xout = quantity_points ) )$y } ) index_of_equality - with(interpolated_price, which.min(abs(supply - demand))) quantity_points[index_of_equality] Question: I need to run this over a larger data frame, where I have the same data, but also a new factor variable (called hour). So if you have the original data frame and add: df - data.frame( hour = factor(seq(1:20)), id = factor(rep(c(supply, demand), each = 10)), price= c(5,7,9,11,13,15,17,19,21,23,20,18,16,14,12,10,8,6,4,2 ), quantity = c(3,5,7,13,19,31,37,53,61,67,6,18,20,24,40,46,66,70,76,78) ) How can I run it for each hour? I tried using: by_hour - split(df[, c(price, quantity)], df$hour) mapply(fx, by_hour) And gathering the above into a fx - function(){the neat code}, but I can't get it to work. Kind Regards, Lasse [[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] bug in dummy.coef?
Dear all, Running the following code produces an error in dummy.coef. I guess it might be a bug.. ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2, 10, 20, labels = c(Ctl,Trt)) weight - c(ctl, trt) x - rnorm(length(weight)) lm.D9 - lm(weight ~ group + x + I(x^2)) dummy.coef(lm.D9) Error in rep.int(xl[[i]][1L], nl) : invalid 'times' value sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 [4] LC_NUMERIC=CLC_TIME=Danish_Denmark.1252 attached base packages: [1] parallel splines stats graphics grDevices utils datasets methods base other attached packages: [1] pbkrtest_0.3-5MASS_7.3-26 Hmisc_3.12-2 Formula_1.1-1 survival_2.37-4 numDeriv_2012.9-1 [7] lmerTest_2.0-1lme4_1.1-1Matrix_1.0-12 lattice_0.20-15 loaded via a namespace (and not attached): [1] cluster_1.14.4 gdata_2.13.2 gplots_2.11.3 grid_3.0.1 gtools_3.0.0 minqa_1.2.1nlme_3.1-109 [8] rpart_4.1-1tools_3.0.1 With best wishes, Alexandra From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of Alexandra Kuznetsova [a...@dtu.dk] Sent: Thursday, October 24, 2013 10:51 AM To: r-help@r-project.org Subject: [R] bug in dummy.coef? Dear all, Running the following code produces an error in dummy.coef. I guess it might be a bug.. ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2, 10, 20, labels = c(Ctl,Trt)) weight - c(ctl, trt) x - rnorm(length(weight)) lm.D9 - lm(weight ~ group + x + I(x^2)) dummy.coef(lm.D9) Error in rep.int(xl[[i]][1L], nl) : invalid 'times' value sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 [4] LC_NUMERIC=CLC_TIME=Danish_Denmark.1252 attached base packages: [1] parallel splines stats graphics grDevices utils datasets methods base other attached packages: [1] pbkrtest_0.3-5MASS_7.3-26 Hmisc_3.12-2 Formula_1.1-1 survival_2.37-4 numDeriv_2012.9-1 [7] lmerTest_2.0-1lme4_1.1-1Matrix_1.0-12 lattice_0.20-15 loaded via a namespace (and not attached): [1] cluster_1.14.4 gdata_2.13.2 gplots_2.11.3 grid_3.0.1 gtools_3.0.0 minqa_1.2.1nlme_3.1-109 [8] rpart_4.1-1tools_3.0.1 With best wishes, Alexandra [[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] Error in heatmap
Hi Jean, Problem result: the 1st column value must be complete for heatmap to run correctly. This solved the same problem I had with vegdist. Thank you for your help. Regards David De: Adams, Jean [mailto:jvad...@usgs.gov] Enviado el: 24 de octubre de 2013 14:12 Para: David Romero CC: R help Asunto: Re: [R] Error in heatmap David, You should cc r-help on all correspondence so others can follow the thread. The error appears to be a result of the missing values yielded by the dist() function on your matrix. See https://stat.ethz.ch/pipermail/r-help/2009-July/204443.html. Jean On Thu, Oct 24, 2013 at 1:25 PM, David Romero drom...@mda.cinvestav.mx wrote: Hi, The difference is: row.names=1 for csv reading. The first column is a numeric row name, it mustn't take part of the heatmap. I change it to text and try with and without row.names=1 Both give me error. Regards David De: Adams, Jean [mailto:jvad...@usgs.gov] Enviado el: 24 de octubre de 2013 11:52 Para: David Romero CC: R help Asunto: Re: [R] Error in heatmap Using your csv file, I get no error running the following code. SPIV2 - read.csv(C:/Temp/SPI V2.csv) heatmap(as.matrix(SPIV2), na.rm=TRUE) Perhaps you modified SPIV2 in some way prior to running heatmap()? Jean On Tue, Oct 22, 2013 at 10:29 AM, David Romero drom...@mda.cinvestav.mx wrote: Hi Jean Thank you for helping. No, there is no empty column or row. I join the data base. Regards David De: Adams, Jean [mailto:jvad...@usgs.gov] Enviado el: 22 de octubre de 2013 07:03 Para: David Romero CC: r-h...@stat.math.ethz.ch Asunto: Re: [R] Error in heatmap Do you have a row or column that is all missing? sum(apply(is.na(as.matrix(SPIV2)), 1, all)) 0 sum(apply(is.na(as.matrix(SPIV2)), 2, all)) 0 For example, this code m - as.matrix(mtcars) m[8, ] - NA heatmap(m, na.rm=TRUE) throws this error Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) Jean On Mon, Oct 21, 2013 at 1:04 PM, David Romero drom...@mda.cinvestav.mx wrote: Hi, Could you please help? Heatmap doesn't work with: heatmap(as.matrix(SPIV2),na.rm = T) Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) There are no 0 data rows or column Thanks a lot Regards --- David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Optional argument to be used in a subset function
Sorry for the html code: I'm writing a function that needs an optional variable. If the variable is given, then a subset must be made using that variable, but if the variable is not given the subset must be done using all the values for that variable (ignoring that variable). Something like this: band - function(file, fruit = apple, optional=TRUE) { data - read.csv(file) a - nrow(subset(data, 'Column 1' == fruit 'Column 2'==hot 'Column 3'== optional)) b - nrow(subset(data,'Column 1' == fruit 'Column 2'==cold 'Column 3'== optional)) z - a+b print(z) } * * What I need is that the function band(file,orange), subset the data frame using all possible values for Column 3 but is not doing it. All ideas are welcome. Thanks. David Mora On Thu, Oct 24, 2013 at 8:15 AM, David Mora dmv...@gmail.com wrote: I'm writing a function that needs an optional variable. If the variable is given, then a subset must be made using that variable, but if the variable is not given the subset must be done using all the values for that variable (ignoring that variable). Something like this: *band - function(file, fruit = apple, optional=TRUE) {* *data - read.csv(file)* *a - nrow(subset(data, 'Column 1' == fruit 'Column 2'==hot 'Column 3'== optional))* *b - nrow(subset(data,'Column 1' == fruit 'Column 2'==cold 'Column 3'== optional)) * *z - a+b* * print(z)* * }* What I need is that the function *band(file,orange)*, subset the data frame using all possible values for Column 3 but is not doing it. All ideas are welcome. Thanks. David Mora [[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] 'yum install R' failing with tcl/tk issue
Hi, I'm trying to install R on CentOS 6.4. Following some instructions online, I've done this: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm yum install R But yum fails, with this (full output below): Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtcl8.4.so()(64bit) Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtk8.4.so()(64bit) I have tcl/tk 8.5 already installed. Does anyone have any suggestion? Thanks! Full output: [root@picsl-cluster ~]# yum install R Repository base is listed more than once in the configuration Rocks-6.1 | 1.9 kB 00:00 base | 3.7 kB 00:00 Setting up Install Process Resolving Dependencies -- Running transaction check --- Package R.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libRmath-devel = 2.10.0-2.el5 for package: R-2.10.0-2.el5.x86_64 -- Processing Dependency: R-devel = 2.10.0-2.el5 for package: R-2.10.0-2.el5.x86_64 -- Running transaction check --- Package R-devel.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: R-core = 2.10.0-2.el5 for package: R-devel-2.10.0-2.el5.x86_64 --- Package libRmath-devel.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libRmath = 2.10.0-2.el5 for package: libRmath-devel-2.10.0-2.el5.x86_64 -- Running transaction check --- Package R-core.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libtk8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libtcl8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libgfortran.so.1()(64bit) for package: R-core-2.10.0-2.el5.x86_64 --- Package libRmath.x86_64 0:2.10.0-2.el5 will be installed -- Running transaction check --- Package R-core.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libtk8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libtcl8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 --- Package compat-libgfortran-41.x86_64 0:4.1.2-39.el6 will be installed -- Finished Dependency Resolution Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtcl8.4.so()(64bit) Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtk8.4.so()(64bit) You could try using --skip-broken to work around the problem ** Found 57 pre-existing rpmdb problem(s), 'yum check' output follows: foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Client) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Core) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Delta) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Ra) 1:guestfish-1.7.17-26.el6.x86_64 has missing requires of libguestfs = ('1', '1.7.17', '26.el6') opt-perl-AcePerl-1.92-0.el6.x86_64 has missing requires of perl(Ace::Browser::LocalSiteDefs) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Apache::DBI) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::ASN1::EntrezGene) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::Contact) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::DataSet) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::Platform) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::Sample) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Factory) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Forest::Tree) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::IO) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Matrices) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Matrices::Datum) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Matrices::Matrix) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Convert::Binary::C) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(DBD::Pg) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(PostScript::TextBlock) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Test::Exception) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Test::Warn) opt-perl-BioPerl-DB-1.006900-0.el6.noarch has missing requires of perl(DBD::Oracle) opt-perl-BioPerl-Run-1.006900-0.el6.noarch has missing requires of perl(Bio::Tools::Run::StandAloneBlastPlus::BlastMethods) opt-perl-BioPerl-Run-1.006900-0.el6.noarch has missing requires of perl(Bio::Tools::Run::WrapperBase::CommandExts) opt-perl-Cache-Cache-1.06-0.el6.noarch has missing requires of perl(IPC::ShareLite) opt-perl-DBI-1.622-0.el6.x86_64 has missing requires of perl(Coro)
[R] moving points labels in ordinations
I'm trying to place labels so as to avoid covering points (and other labels) in an ordination plot. I've been trying to use orditkplot() for this purpose, but get an error message, even when I try to replicate the example: require(vegan) data(varespec) ord - cca(varespec) orditkplot(ord, mar = c(4,4,1,1)+.1, font=3) Error in structure(.External(.C_dotTclObjv, objv), class = tclObj) : [tcl] invalid command name tk. In addition: Warning message: In fun(libname, pkgname) : couldn't connect to display :0 Any ideas? Thanks, Pete __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] test wilcoxon sur R help!
Hi, Check out this function:- pairwise.wilcox.test {package=stats}. example(pairwise.wilcox.test) On Fri, Oct 25, 2013 at 2:15 AM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, There's a bug in your function, it should be 'dat', not 'dat1'. In the line marked, below. fun1 - function(dat){ mat1 - combn(colnames(dat),2) # Here, 'dat' not 'dat1' res - sapply(seq_len(ncol(mat1)),function(i) {x1- dat[,mat1[,i]]; wilcox.test(x1[,1],x1[,2])$p.value}) names(res) - apply(mat1,2,paste,collapse=_) res } Hope this helps, Rui Barradas Em 24-10-2013 20:16, arun escreveu: Hi, Try: fun1 - function(dat){ mat1 - combn(colnames(dat1),2) res - sapply(seq_len(ncol(mat1)),function(i) {x1- dat[,mat1[,i]]; wilcox.test(x1[,1],x1[,2])$p.value}) names(res) - apply(mat1,2,paste,collapse=_) res } set.seed(432) dat1 - as.data.frame(matrix(sample(18*10,18*10,replace=FALSE),ncol=18)) fun1(dat1) #gives the p-value for each pair of columns Hi, I want to make a wilcoxon test, i have 18 columns each column corresponds to a different sample and i want to compare one to each other with a wilcoxon test in one step this is possible ? or do i compare two by tow? Does it exist a code for automation this test? like this i dont have to type the code for each couple. thanks! denisse __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] test wilcoxon sur R help!
It looks much better than mine. with p value adjustment: p.adjust(fun1(dat1), method = holm, n = 153) # dat1$id - 1:10 library(reshape2) dat2 - melt(dat1,id.var=id) with(dat2,pairwise.wilcox.test(value,variable)) with(dat2,pairwise.wilcox.test(value,variable,p.adj=none)) A.K. On Friday, October 25, 2013 12:05 AM, vikram ranga babuaw...@gmail.com wrote: Hi, Check out this function:- pairwise.wilcox.test {package=stats}. example(pairwise.wilcox.test) On Fri, Oct 25, 2013 at 2:15 AM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, There's a bug in your function, it should be 'dat', not 'dat1'. In the line marked, below. fun1 - function(dat){ mat1 - combn(colnames(dat),2) # Here, 'dat' not 'dat1' res - sapply(seq_len(ncol(mat1)),function(i) {x1- dat[,mat1[,i]]; wilcox.test(x1[,1],x1[,2])$p.value}) names(res) - apply(mat1,2,paste,collapse=_) res } Hope this helps, Rui Barradas Em 24-10-2013 20:16, arun escreveu: Hi, Try: fun1 - function(dat){ mat1 - combn(colnames(dat1),2) res - sapply(seq_len(ncol(mat1)),function(i) {x1- dat[,mat1[,i]]; wilcox.test(x1[,1],x1[,2])$p.value}) names(res) - apply(mat1,2,paste,collapse=_) res } set.seed(432) dat1 - as.data.frame(matrix(sample(18*10,18*10,replace=FALSE),ncol=18)) fun1(dat1) #gives the p-value for each pair of columns Hi, I want to make a wilcoxon test, i have 18 columns each column corresponds to a different sample and i want to compare one to each other with a wilcoxon test in one step this is possible ? or do i compare two by tow? Does it exist a code for automation this test? like this i dont have to type the code for each couple. thanks! denisse __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'yum install R' failing with tcl/tk issue
Hello, Do you have headers installed (generally tcl-devel and tk-devel)? Regards, Pascal On 25 October 2013 10:33, Michael Stauffer mgsta...@gmail.com wrote: Hi, I'm trying to install R on CentOS 6.4. Following some instructions online, I've done this: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm yum install R But yum fails, with this (full output below): Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtcl8.4.so()(64bit) Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtk8.4.so()(64bit) I have tcl/tk 8.5 already installed. Does anyone have any suggestion? Thanks! Full output: [root@picsl-cluster ~]# yum install R Repository base is listed more than once in the configuration Rocks-6.1 | 1.9 kB 00:00 base | 3.7 kB 00:00 Setting up Install Process Resolving Dependencies -- Running transaction check --- Package R.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libRmath-devel = 2.10.0-2.el5 for package: R-2.10.0-2.el5.x86_64 -- Processing Dependency: R-devel = 2.10.0-2.el5 for package: R-2.10.0-2.el5.x86_64 -- Running transaction check --- Package R-devel.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: R-core = 2.10.0-2.el5 for package: R-devel-2.10.0-2.el5.x86_64 --- Package libRmath-devel.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libRmath = 2.10.0-2.el5 for package: libRmath-devel-2.10.0-2.el5.x86_64 -- Running transaction check --- Package R-core.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libtk8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libtcl8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libgfortran.so.1()(64bit) for package: R-core-2.10.0-2.el5.x86_64 --- Package libRmath.x86_64 0:2.10.0-2.el5 will be installed -- Running transaction check --- Package R-core.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libtk8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libtcl8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 --- Package compat-libgfortran-41.x86_64 0:4.1.2-39.el6 will be installed -- Finished Dependency Resolution Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtcl8.4.so()(64bit) Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtk8.4.so()(64bit) You could try using --skip-broken to work around the problem ** Found 57 pre-existing rpmdb problem(s), 'yum check' output follows: foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Client) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Core) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Delta) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Ra) 1:guestfish-1.7.17-26.el6.x86_64 has missing requires of libguestfs = ('1', '1.7.17', '26.el6') opt-perl-AcePerl-1.92-0.el6.x86_64 has missing requires of perl(Ace::Browser::LocalSiteDefs) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Apache::DBI) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::ASN1::EntrezGene) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::Contact) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::DataSet) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::Platform) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Expression::Sample) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Factory) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Forest::Tree) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::IO) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Matrices) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Matrices::Datum) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Bio::Phylo::Matrices::Matrix) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Convert::Binary::C) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(DBD::Pg) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(PostScript::TextBlock) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Test::Exception) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing requires of perl(Test::Warn) opt-perl-BioPerl-DB-1.006900-0.el6.noarch has missing requires of perl(DBD::Oracle) opt-perl-BioPerl-Run-1.006900-0.el6.noarch has missing requires of perl(Bio::Tools::Run::StandAloneBlastPlus::BlastMethods)