Re: [R] failure to replayPlot() a recordedplot object saved in a previous session?
It might worth checking out this nice workaround of JJ: https://github.com/Rapporter/pander/blob/master/R/evals.R#L1135 Best, Gergely On 25 September 2013 02:35, Paul Murrell p...@stat.auckland.ac.nz wrote: Hi Attempting to use a display list snapshot (as created by recordPlot()) between R sessions has always been strongly discouraged, but as of about R 3.0.0 it has become impossible (due to internal changes, which was part of the reason for strongly discouraging this in the first place). Sorry to be the bearer of bad news. Paul On 09/13/13 10:54, MacQueen, Don wrote: I have the following experience. If I use, for example, tmp - recordPlot() in a session, then immediately the saved plot replays successfully using replayPlot() in the same session. But not in the next R session. See examples below, copy/pasted from my shell window. The first R session is brand new; no saved objects left over from a previous session. I also have the same experience with R 3.0.1 patched on a linux machine (RHEL). Is this a known or expected behavior? Thanks -Don R session #1 mydir[42]% R R version 3.0.1 Patched (2013-08-13 r63562) -- Good Sport Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin10.8.0 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. x11() plot(1:2) tmp - recordPlot() replayPlot(tmp) q() Save workspace image? [y/n/c]: y R session #2 mydir[43]% R R version 3.0.1 Patched (2013-08-13 r63562) -- Good Sport Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin10.8.0 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] ls() [1] tmp class(tmp) [1] recordedplot x11() replayPlot(tmp) Error: NULL value passed as symbol address sessionInfo() R version 3.0.1 Patched (2013-08-13 r63562) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] C attached base packages: [1] stats graphics grDevices utils datasets methods base -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.**nz/~paul/http://www.stat.auckland.ac.nz/~paul/ __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] How can I draw a 3D diagram (persp) with these Infos
I want to have a 3D diagramm. My Information are: - x:Time - it could be 1:n (integer number) - Y:Frequency ---it could be 1:n like x z:the value of z come from a function *fft_amplitude - function(x) {sqrt((Re(fft(x)))^2+(Im(fft(x)))^2)}* ** The input values for this function should be read from a CSV file. How can I draw a 3D diagram* *perspwith this infos? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How can I draw a 3D diagram (persp) with these Infos
Hello, This request looks very similar to: http://stackoverflow.com/questions/18982662/showing-a-3d-diagram-in-r http://stackoverflow.com/questions/18913143/non-numeric-argument-error-while-running-fft-on-a-matrix Regards, Pascal 2013/9/25 Babak Bastan babak...@gmail.com I want to have a 3D diagramm. My Information are: - x:Time - it could be 1:n (integer number) - Y:Frequency ---it could be 1:n like x z:the value of z come from a function *fft_amplitude - function(x) {sqrt((Re(fft(x)))^2+(Im(fft(x)))^2)}* ** The input values for this function should be read from a CSV file. How can I draw a 3D diagram* *perspwith this infos? [[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. -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan [[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] Computing calculation among two vectors
Hi, Try: x- 1:4 y- c(*,/,-,+) res-sapply(y,function(i) {x1-expand.grid(x,x); unlist(lapply(paste0(x1[,1],i,x1[,2]),function(u) eval(parse(text=u}) row.names(res)- as.character(interaction(expand.grid(x,x),sep=_)) head(res) # * / - + #1_1 1 1.0 0 2 #2_1 2 2.0 1 3 #3_1 3 3.0 2 4 #4_1 4 4.0 3 5 #1_2 2 0.5 -1 3 #2_2 4 1.0 0 4 A.K. I have two vectors one numeric and another with operand. Eg: x - 1,2,3,4 and y-*, /, -, + I need to calculate all the possible two combinations in x with each of operand in y. As example, 1*2, 1/2, 1-2, 1+2, 1*3, 1/3 Any help appreciated. Regards Hussain __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Space between x-axis ticks
Hi, I am trying to clearly show the values in the x-axis in the attached graph. The tick marks are too close and the labels are blurred. plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col=green,type=o,ylab=Number of connections,las=2,lwd=2.5,xaxt=n,xlab=IP) axis(1,at=data$Var1,labels=data$Var1,las = 2,cex.axis=0.7,las=2) title(Estimation of concurrent connections,cex.main=1.8,line=1) Thanks, Mohan This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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] Graph is without line
Hi It is mostly question of personal preference. Factors have some nice features when manipulating with levels, sorting, and/or using numeric annotation. However when you want to add some new value to factor it is trickier than with plain string vectors. Maybe it is time to look into R-intro explanation of object differences. Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of mohan.radhakrish...@polarisft.com Sent: Wednesday, September 25, 2013 6:13 AM To: Jim Lemon Cc: r-help@r-project.org Subject: Re: [R] Graph is without line Hi, Yes. It worked. Is 'stringAsFactors=FALSE' the switch to use when reading data into a frame ? All the values I use are either numbers or dates or strings. Sometimes while I manipulate the data by filtering, the values seem to become factors ? Thanks, Mohan From: Jim Lemon j...@bitwrit.com.au To: mohan.radhakrish...@polarisft.com Cc: r-help@r-project.org Date: 09/25/2013 05:56 AM Subject:Re: [R] Graph is without line On 09/24/2013 10:46 PM, mohan.radhakrish...@polarisft.com wrote: Hi, Sometimes I get a graph like the attached one. The data type could have something to do with it. This graph does not use the color and does not draw a line. Earlier I used to convert the factors in the data frame to another data type and drew the correct graphs. Any idea why this happens ? Thanks, Mohan Var1 Freq 1 10.1.17.10 205 2 10.1.17.15 216 3 10.1.17.17 79 4 10.1.17.23 76 5 10.1.17.24 209 6 10.1.17.5 244 7 10.1.17.6 178 8 10.1.17.7 165 9 10.1.17.8 146 #prints factor print(class(data$Var1)) plot(data$Var1,data$Freq,ylim=c(0,700),col=green,type=o,ylab=,xla b=,las=2,lwd=2.5,xaxt=n) title(Estimation of concurrent connections,cex.main=3) library(plotrix) staxlab(at=data$Var1, labels=as.character(data$Var1),nlines=3,srt=90) Hi Mohan, If you pass a factor as the x value to plot, it assumes that the values of the factor are nominal or at best ordinal and does not try to connect them into a metric scale. You can get a line with: plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col=green,type=o , ylab=,xlab=,las=2,lwd=2.5,xaxt=n) ... but think carefully about whether this means anything sensible. Jim This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e- mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Confusing behaviour in data.table: unexpectedly changing variable
Very sorry to hear this bit you. If you need a copy of names before changing them by reference : oldnames - copy(names(DT)) This will be documented and it's on the bug list to do so. copy is needed in other circumstances too, see ?copy. More details here : http://stackoverflow.com/questions/18662715/colnames-being-dropped-in-data-table-in-r http://stackoverflow.com/questions/15913417/why-does-data-table-update-namesdt-by-reference-even-if-i-assign-to-another-v Btw, the r-help posting guide says (last time I looked) you should only post to r-help about packages if you have tried the maintainer first but didn't hear from them; i.e., r-help isn't for support about packages. I don't follow r-help, so please continue to cc me if you reply. Matthew On 25/09/13 00:47, Jonathan Dushoff wrote: I got bitten badly when a variable I created for the purpose of recording an old set of names changed when I didn't think I was going near it. I'm not sure if this is a desired behaviour, or documented, or warned about. I read the data.table intro and the FAQ, and also ?setnames. Ben Bolker created a minimal reproducible example: library(data.table) DT = data.table(x=rep(c(a,b,c),each=3), y=c(1,3,6), v=1:9) names(DT) ## [1] x y v oldnames - names(DT) print(oldnames) ## [1] x y v setnames(DT, LETTERS[1:3]) print(oldnames) ## [1] A B C __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rmpfr question
Michel michelgo...@free.fr on Tue, 24 Sep 2013 12:22:10 +0200 writes: Hello, Thanks for your answer The file does not contains numbers in high precision but all the calculation applied to these data will be In attachment a text file containing some lines And her few values: 1.0054014388224326026488598,-68239.4114845811819662912967033,10053.1824584878233990181684021 3.05363891777017837760380136736,-1.40443175474415104684797195311,1.36766960877453817890022497172 (two lines, typically split by mail writers/readers) Aha! But these actually *ARE* of 'high precision', i.e. you cannot store them as usual double precision numbers in full accuracy. So, I've prepared the following -- 100% reproducible -- script to show you how to get such numbers into an Rmpfr matrix : ## MM: Reproducible example set.seed(17); x - mpfr(matrix(rnorm(28), 7, 4), precBits=128) x - x^2 mfile - tempfile() write.table(array(format(x), dim=dim(x)), file = mfile, row.names=FALSE, col.names=FALSE, sep=,) ## to check: writeLines(readLines(mfile) [1:2]) ## Now, let's assume mfile contains the high precision matrix we want to get as ## mpfrMatrix : ## 1) Assume you know the number of columns, then this is fastest : m.ncol - 4 chmat - matrix(scan(mfile, , sep=,), ncol = m.ncol ) ## 2) Nothing is known, ... ok, why not make the detour via read.table(): chmat - as.matrix(read.table(mfile, colClasses=character, sep=,)) ## in both cases: require(Rmpfr)# the package M - mpfr(chmat)#- determines precision *from* the input, here 133 .. 143 bits ## or set the precision yourself, high enough: M - mpfr(chmat, precBits = 144) ## and e.g. this works: crossprod(M) ## == M'M --- Hoping this helps, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Space between x-axis ticks
Looks like graph cannot be attached. Mohan From: mohan.radhakrish...@polarisft.com To: r-help@r-project.org Date: 09/25/2013 12:41 PM Subject:[R] Space between x-axis ticks Sent by:r-help-boun...@r-project.org Hi, I am trying to clearly show the values in the x-axis in the attached graph. The tick marks are too close and the labels are blurred. plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col=green,type=o,ylab=Number of connections,las=2,lwd=2.5,xaxt=n,xlab=IP) axis(1,at=data$Var1,labels=data$Var1,las = 2,cex.axis=0.7,las=2) title(Estimation of concurrent connections,cex.main=1.8,line=1) Thanks, Mohan This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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 e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rmpfr question
Martin Maechler maech...@lynne.ethz.ch on Wed, 25 Sep 2013 11:08:07 +0200 writes: Michel michelgo...@free.fr on Tue, 24 Sep 2013 12:22:10 +0200 writes: Hello, Thanks for your answer The file does not contains numbers in high precision but all the calculation applied to these data will be In attachment a text file containing some lines And her few values: 1.0054014388224326026488598,-68239.4114845811819662912967033,10053.1824584878233990181684021 3.05363891777017837760380136736,-1.40443175474415104684797195311,1.36766960877453817890022497172 (two lines, typically split by mail writers/readers) Aha! But these actually *ARE* of 'high precision', i.e. you cannot store them as usual double precision numbers in full accuracy. So, I've prepared the following -- 100% reproducible -- script to show you how to get such numbers into an Rmpfr matrix : ## MM: Reproducible example set.seed(17); x - mpfr(matrix(rnorm(28), 7, 4), precBits=128) x - x^2 mfile - tempfile() write.table(array(format(x), dim=dim(x)), file = mfile, row.names=FALSE, col.names=FALSE, sep=,) ## to check: writeLines(readLines(mfile) [1:2]) ## Now, let's assume mfile contains the high precision matrix we want to get as ## mpfrMatrix : ## 1) Assume you know the number of columns, then this is fastest : m.ncol - 4 chmat - matrix(scan(mfile, , sep=,), ncol = m.ncol ) and -- oops! - the above was missing the ominous 'byrow = TRUE' i.e. the above needs to be chmat - matrix(scan(mfile, , sep=,), ncol = m.ncol, byrow = TRUE) ... which makes the detour via read.table() even more attractive ... ## 2) Nothing is known, ... ok, why not make the detour via read.table(): chmat - as.matrix(read.table(mfile, colClasses=character, sep=,)) ## in both cases: require(Rmpfr)# the package M - mpfr(chmat)#- determines precision *from* the input, here 133 .. 143 bits ## or set the precision yourself, high enough: M - mpfr(chmat, precBits = 144) ## and e.g. this works: crossprod(M) ## == M'M --- Hoping this helps, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Space between x-axis ticks
Hi If you did PLEASE do read the posting guide http://www.R-project.org/posting- guide.html you could find No binary attachments except for PS, PDF, and some image and archive formats (others are automatically stripped off because they can contain malicious software). Files in other formats and larger ones should rather be put on the web and have only their URLs posted. This way a reader has the option to download them or not. So the best way is to post some data preferably by ?dput Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of mohan.radhakrish...@polarisft.com Sent: Wednesday, September 25, 2013 11:13 AM To: r-help@r-project.org Subject: Re: [R] Space between x-axis ticks Looks like graph cannot be attached. Mohan From: mohan.radhakrish...@polarisft.com To: r-help@r-project.org Date: 09/25/2013 12:41 PM Subject:[R] Space between x-axis ticks Sent by:r-help-boun...@r-project.org Hi, I am trying to clearly show the values in the x-axis in the attached graph. The tick marks are too close and the labels are blurred. plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col=green,type=o ,ylab=Number of connections,las=2,lwd=2.5,xaxt=n,xlab=IP) axis(1,at=data$Var1,labels=data$Var1,las = 2,cex.axis=0.7,las=2) title(Estimation of concurrent connections,cex.main=1.8,line=1) Thanks, Mohan This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e- mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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 e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e- mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 3.0.2 is released
The build system rolled up R-3.0.2.tar.gz (codename Frisbee Sailing) this morning. The list below details the changes in this release. You can get the source code from http://cran.r-project.org/src/base/R-3/R-3.0.2.tar.gz or wait for it to be mirrored at a CRAN site nearer to you. Binaries for various platforms will appear in due course. For the R Core Team Peter Dalgaard These are the md5sums for the freshly created files, in case you wish to check that they are uncorrupted: MD5 (AUTHORS) = cbf6da8f886ccd8d0dda0cc7ffd1b8ec MD5 (COPYING) = eb723b61539feef013de476e68b5c50a MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343 MD5 (FAQ) = 77da68a9d0abfa9121d54f6ff0bced33 MD5 (INSTALL) = 3964b9119adeaab9ceb633773fc94aac MD5 (NEWS) = e01b5a01aade71ccef967d39f3738e0a MD5 (NEWS.html) = 1925b57c75bd51373adb33a04e2c18f8 MD5 (R-latest.tar.gz) = f9a8374736e7650e4848f33e2e3bbee3 MD5 (README) = e259ae5dd943b8547f0b7719664e815b MD5 (RESOURCES) = c7cb32499ebbf85deb064aab282f93a4 MD5 (THANKS) = d4b45e302b7cad0fc4bb50d2cfe69649 MD5 (R-3/R-3.0.2.tar.gz) = f9a8374736e7650e4848f33e2e3bbee3 This is the relevant part of the NEWS file CHANGES IN R 3.0.2: NEW FEATURES: * The NEWS files have been re-organized. This file contains news for R = 3.0.0: news for the 0.x.y, 1.x.y and 2.x.y releases is in files NEWS.0, NEWS.1 and NEWS.2. The latter files are now installed when R is installed. An HTML version of news from 2.10.0 to 2.15.3 is available as doc/html/NEWS.2.html. * sum() for integer arguments now uses an integer accumulator of at least 64 bits and so will be more accurate in the very rare case that a cumulative sum exceeds 2^53 (necessarily summing more than 4 million elements). * The example() and tools::Rd2ex() functions now have parameters to allow them to ignore \dontrun markup in examples. (Suggested by Peter Solymos.) * str(x) is considerably faster for very large lists, or factors with 100,000 levels, the latter as in PR#15337. * col2rgb() now converts factors to character strings not integer codes (suggested by Bryan Hanson). * tail(warnings()) now works, via the new `[` method. * There is now support for the LaTeX style file zi4.sty which has in some distributions replaced inconsolata.sty. * unlist(x) now typically returns all non-list xs unchanged, not just the vector ones. Consequently, format(lst) now also works when the list lst has non-vector elements. * The tools::getVignetteInfo() function has been added to give information about installed vignettes. * New assertCondition(), etc. utilities in tools, useful for testing. * Profiling now records non-inlined calls from byte-compiled code to BUILTIN functions. * Various functions in stats and elsewhere that use non-standard evaluation are now more careful to follow the namespace scoping rules. E.g. stats::lm() can now find stats::model.frame() even if stats is not on the search path or if some package defines a function of that name. * If an invalid/corrupt .Random.seed object is encountered in the workspace it is ignored with a warning rather than giving an error. (This allows R itself to rely on a working RNG, e.g. to choose a random port.) * seq() and seq.int() give more explicit error messages if called with invalid (e.g. NaN) inputs. * When parse() finds a syntax error, it now makes partial parse information available up to the location of the error. (Request of Reijo Sund.) * Methods invoked by NextMethod() had a different dynamic parent to the generic. This was causing trouble where S3 methods invoked via lazy evaluation could lose track of their generic. (PR#15267) * Code for the negative binomial distribution now treats the case size == 0 as a one-point distribution at zero. * abbreviate() handles without warning non-ASCII input strings which require no abbreviation. * read.dcf() no longer has a limit of 8191 bytes per line. (Wish of PR#15250.) * formatC(x) no longer copies the class of x to the result, to avoid misuse creating invalid objects as in PR#15303. A warning is given if a class is discarded. * Dataset npk has been copied from MASS to allow more tests to be run without recommended packages being installed. * The initialization of the regression coefficients for non-degenerate differenced models in arima() has been changed and in some examples avoids a local maximum. (PR#15396) * termplot() now has an argument transform.x to control the display of individual terms in the plot. (PR#15329) * format() now supports digits = 0, to display nsmall decimal places. * There is a new read-only par() parameter called page, which returns a logical value
[R] Cosine window in r
Hi experts Can some one tell me, how can I implement Cosine window in r? Is there a function for that? [[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] Creating a new column to a data frame using a formula from another variable
Hi, Change: aa$z- eval(parse(text=bb)) aa # x y z #1 2 3 3 #2 4 5 7 #3 6 7 11 A.K. I want to create a new column to a data frame using a formula from another variable: Example: I have a data set aa is; x y 2 3 4 5 6 7 My R code is; bb - x+y-2 attach(aa) aa$z- bb detach(aa) the result is; x y z 2 3 x+y-2 4 5 x+y-2 6 7 x+y-2 but I want like; x y z 2 3 3 4 5 7 6 7 11 Could you please help me.. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating a new column to a data frame using a formula from another variable
Also, Instead of ?attach, you could try ?with or ?within aa$z- with(aa,eval(parse(text=bb))) aa$z #[1] 3 7 11 aa- within(aa,z- eval(parse(text=bb))) aa # x y z #1 2 3 3 #2 4 5 7 #3 6 7 11 A.K. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 8:47 AM Subject: Re: Re: Creating a new column to a data frame using a formula from another variable Hi, Change: aa$z- eval(parse(text=bb)) aa # x y z #1 2 3 3 #2 4 5 7 #3 6 7 11 A.K. I want to create a new column to a data frame using a formula from another variable: Example: I have a data set aa is; x y 2 3 4 5 6 7 My R code is; bb - x+y-2 attach(aa) aa$z- bb detach(aa) the result is; x y z 2 3 x+y-2 4 5 x+y-2 6 7 x+y-2 but I want like; x y z 2 3 3 4 5 7 6 7 11 Could you please help me.. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Confusing behaviour in data.table: unexpectedly changing variable
Thanks for your help, and sorry for mis-posting. JD On Wed, Sep 25, 2013 at 3:18 AM, Matthew Dowle mdo...@mdowle.plus.com wrote: Very sorry to hear this bit you. If you need a copy of names before changing them by reference : oldnames - copy(names(DT)) This will be documented and it's on the bug list to do so. copy is needed in other circumstances too, see ?copy. More details here : http://stackoverflow.com/questions/18662715/colnames-being-dropped-in-data-table-in-r http://stackoverflow.com/questions/15913417/why-does-data-table-update-namesdt-by-reference-even-if-i-assign-to-another-v __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Multiple vector elements into one character element
Hi all, I want to collapse multiple elements of a vector into a single comma-separated character element. I only know how to create a list of the original elements, but I have not managed to write this into a text file, which is necessary. To illustrate, let's use the airquality dataset and extract the Month and Day columns: library(datasets) x - data.frame(Month = airquality$Month, Day = as.character(airquality$Day)) Using the aggregate function y - aggregate(x$Day ~ x$Month, data = x, paste) only seemingly creates what I want because the list can't be written to a file. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 for the first row should actually be a character element. I've tried it but sapply, ascii, write.matrix don't seem get me there. Can someone please point me towards the function I need? Best wishes Haiko Haiko Lietz GESIS - Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8, D-50667 Köln Tel: + 49 (0) 221 / 476 94 -223 eMail: haiko.li...@gesis.orgmailto:haiko.li...@gesis.org Web: http://www.gesis.org [[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] MaxLik estimation issues
Hello everybody! I'm having some trouble to compute maximum likelihood estimations using maxLik package and I hope that you could give me a hint. The main problem is that I'm not able to get a result not even close to the ones given by glm() directly, and the second one is: Error in maxNRCompute(fn = logLikAttr, fnOrig = fn, gradOrig = grad, hessOrig = hess, : NA in gradient. The codes: loglike.GGompiMaxLik - function(theta,age,deaths,exposures) { alpha - exp(theta[1]) beta - exp(theta[2]) gamma - exp(theta[3]) first - alpha*exp(beta*age) second - 1+(((alpha*gamma)/beta)*(exp(beta*age)-1)) mu - first/second llk - -sum((deaths * log(mu)) + (- mu*exposures)) return(llk) } fit1 - maxLik(loglike.GGompiMaxLik, age=0:6, deaths=c(15545, 21278, 32444, 36201, 30360, 14201, 5198), exposures=c(935023.67, 819392.00, 724568.17, 470947.00, 231951.64, 69502.65, 15798.72), start=c(-4.1402817, -0.6375773, -1.6945914)) Do you know how I can solve this problem? Thanks in advance, Filipe [[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] grImport problems in Windows
Hello all, I'd like to use the Bioconductor motifStack function to align multiple DNA sequence motifs as PWMs (Position Weight Matrices). 1.Requires both ghostscript, and the R function grImport for converting. postscript files. - Have 64 bit GS 9.10 and R 3.01 is installed in 64 bit Windows 7. 2.Environment set as Sys.setenv(R_GSCMD=\C:\\Program Files\\gs\\gs9.10\\bin\\gswin64c.exe\)-can open gswin64c directly with this path in the Windows run command. 3. motifStack opens the R plotting window, followed by error messages in the R command line: Error in grImport::PostScriptTrace(paste(psfilename, .ps, sep = ), : status 1 in running command 'C:\Program Files\gs\gs9.10\bin\gswin64c.exe -q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=C:\Users\millsf\AppData\Local\Temp\RtmpWsUOwL\file1344455f4de4 -sstdout=C:/Users/millsf/AppData/Local/Temp/RtmpWsUOwL/file134475b7b9d.xml capturefile134475b7b9d.ps' In addition: Warning message: running command 'C:\Program Files\gs\gs9.10\bin\gswin64c.exe -q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=C:\Users\millsf\AppData\Local\Temp\RtmpWsUOwL\file1344455f4de4 -sstdout=C:/Users/millsf/AppData/Local/Temp/RtmpWsUOwL/file134475b7b9d.xml capturefile134475b7b9d.ps' had status 1 4. Entered the following directly in the gswin64 command line: q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=C:\Users\millsf\AppData\Local\Temp\RtmpWsUOwL\file1344455f4de4 -sstdout=C:/Users/millsf/AppData/Local/Temp/RtmpWsUOwL/file134475b7b9d.xml capturefile134475b7b9d.ps 5. And got following response in GS GS-q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=C:\Users\millsf\AppData\Lo cal\Temp\RtmpWsUOwL\file1344455f4de4 -sstdout=C:/Users/millsf/AppData/Local/Temp /RtmpWsUOwL/file134475b7b9d.xml capturefile134475b7b9d.ps Error: /undefined in -q Operand stack: Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval- - 2 %stopped_push --nostringval-- --nostringval-- %loop_continue --n ostringval-- --nostringval-- false 1 %stopped_push .runexec2 --nostr ingval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval -- Dictionary stack: --dict:1177/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)-- Current allocation mode is local Last OS error: No such file or directory Current file position is 3 GS 6. Found the postscript file 134475b7b9d.ps, and clicked on it. Adobe distiller launches, but doesn't convert the file, giving the following error message: ?xml version='1.0' encoding='ISO-8859-1' ? picture version='3' xmlns:rgml='http://r-project.org/RGML' source='C:/Users/millsf/AppData/Local/Temp/RtmpWsUOwL/file134475b7b9d.ps' date='2013-09-06 15:37:10' creator='R (3.0.1)' %%[ Error: undefinedfilename; OffendingCommand: run ]%%Stack: (C:/Users/millsf/AppData/Local/Temp/RtmpWsUOwL/file134475b7b9d.ps) %%[ Flushing: rest of job (to end-of-file) will be ignored ]%% %%[ Warning: PostScript error. No PDF file produced. ] %% 7. According to the following thread (http://r.789695.n4.nabble.com/Re-grImport-ghostscript-problems-td4673693.html), it looks like the Unix/Linux version of grImport works. Couldn't find a clear resolution of this problem for Windows. Many thanks, Fred Mills, Ph.D. Staff Scientist FDA, CDER Division of Therapeutic Proteins NIH Campus Bethesda, MD [[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] Checking a large data set for normality
It was just a question to see if it was possible on a large data set. I wasn't looking for a flame war. New strategy is simply new strategy. Half of my time spent on R is trying to find a better way. -- View this message in context: http://r.789695.n4.nabble.com/Checking-a-large-data-set-for-normality-tp4676858p4676917.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] Creating a new column to a data frame using a formula from another variable
DO NOT DO THIS! This is a complete misuse of R. R is not a macro/scripting language that constructs language expressions to be evaluated (although it can do this). Rather, it is a functional language that uses functions that build new objects from inputted objects and parameters. I would strongly suggest reading An Introduction to R or other R tutorial (there are many on the web) and perhaps relevant portions of the R Language Definition manual to better understand what this means.You are more or less wasting your time with R if you do not understand and use its underlying programming paradigm. The practical consequence of this dictum is that one should almost NEVER use eval(parse()) -- instead construct a function that does what is needed. In the present example, instead of doing what you and Arun have described, do something like: addthings - function(x,y,a) {x + y + a} ## the curly brackets are actually unnecessary aa - within(aa, z - addthings(x,y,-2) ) -- Bert On Wed, Sep 25, 2013 at 5:52 AM, arun smartpink...@yahoo.com wrote: Also, Instead of ?attach, you could try ?with or ?within aa$z- with(aa,eval(parse(text=bb))) aa$z #[1] 3 7 11 aa- within(aa,z- eval(parse(text=bb))) aa # x y z #1 2 3 3 #2 4 5 7 #3 6 7 11 A.K. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 8:47 AM Subject: Re: Re: Creating a new column to a data frame using a formula from another variable Hi, Change: aa$z- eval(parse(text=bb)) aa # x y z #1 2 3 3 #2 4 5 7 #3 6 7 11 A.K. I want to create a new column to a data frame using a formula from another variable: Example: I have a data set aa is; xy 23 45 67 My R code is; bb - x+y-2 attach(aa) aa$z- bb detach(aa) the result is; x y z 2 3 x+y-2 4 5 x+y-2 6 7 x+y-2 but I want like; x y z 2 3 3 4 5 7 6 7 11 Could you please help me.. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cosine window in r
x-seq(0,2*pi,by=0.01) y-cos(x) plot(x,y,type='l') On 25-09-2013 13:22, Babak Bastan wrote: Hi experts Can some one tell me, how can I implement Cosine window in r? Is there a function for that? [[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] Multiple vector elements into one character element
Perhaps ?dput -- Bert On Wed, Sep 25, 2013 at 6:10 AM, Lietz, Haiko haiko.li...@gesis.org wrote: Hi all, I want to collapse multiple elements of a vector into a single comma-separated character element. I only know how to create a list of the original elements, but I have not managed to write this into a text file, which is necessary. To illustrate, let's use the airquality dataset and extract the Month and Day columns: library(datasets) x - data.frame(Month = airquality$Month, Day = as.character(airquality$Day)) Using the aggregate function y - aggregate(x$Day ~ x$Month, data = x, paste) only seemingly creates what I want because the list can't be written to a file. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 for the first row should actually be a character element. I've tried it but sapply, ascii, write.matrix don't seem get me there. Can someone please point me towards the function I need? Best wishes Haiko Haiko Lietz GESIS - Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8, D-50667 Köln Tel: + 49 (0) 221 / 476 94 -223 eMail: haiko.li...@gesis.orgmailto:haiko.li...@gesis.org Web: http://www.gesis.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multiple vector elements into one character element
Hi, May be this helps: y- aggregate(Day~Month,data=x,paste,collapse=,) write.table(y,file.txt,quote=FALSE) A.K. - Original Message - From: Lietz, Haiko haiko.li...@gesis.org To: 'r-help@r-project.org' r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 9:10 AM Subject: [R] Multiple vector elements into one character element Hi all, I want to collapse multiple elements of a vector into a single comma-separated character element. I only know how to create a list of the original elements, but I have not managed to write this into a text file, which is necessary. To illustrate, let's use the airquality dataset and extract the Month and Day columns: library(datasets) x - data.frame(Month = airquality$Month, Day = as.character(airquality$Day)) Using the aggregate function y - aggregate(x$Day ~ x$Month, data = x, paste) only seemingly creates what I want because the list can't be written to a file. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 for the first row should actually be a character element. I've tried it but sapply, ascii, write.matrix don't seem get me there. Can someone please point me towards the function I need? Best wishes Haiko Haiko Lietz GESIS - Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8, D-50667 Köln Tel: + 49 (0) 221 / 476 94 -223 eMail: haiko.li...@gesis.orgmailto:haiko.li...@gesis.org Web: http://www.gesis.org [[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] Computing calculation among two vectors
Hi, You could also try: res1-sapply(y,function(i) {x1- expand.grid(x,x);fun1- function(a,op,b){ f1- match.fun(FUN=op); f1(a,b)};fun1(x1[,1],i,x1[,2])}) row.names(res1)- row.names(res) identical(res1,res) #[1] TRUE A.K. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 3:08 AM Subject: Re: Computing calculation among two vectors Hi, Try: x- 1:4 y- c(*,/,-,+) res-sapply(y,function(i) {x1-expand.grid(x,x); unlist(lapply(paste0(x1[,1],i,x1[,2]),function(u) eval(parse(text=u}) row.names(res)- as.character(interaction(expand.grid(x,x),sep=_)) head(res) # * / - + #1_1 1 1.0 0 2 #2_1 2 2.0 1 3 #3_1 3 3.0 2 4 #4_1 4 4.0 3 5 #1_2 2 0.5 -1 3 #2_2 4 1.0 0 4 A.K. I have two vectors one numeric and another with operand. Eg: x - 1,2,3,4 and y-*, /, -, + I need to calculate all the possible two combinations in x with each of operand in y. As example, 1*2, 1/2, 1-2, 1+2, 1*3, 1/3 Any help appreciated. Regards Hussain __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Computing calculation among two vectors
A cute problem. Is it homework? Hint: ?outer (will provide a much simpler solution than those given below) -- Bert On Wed, Sep 25, 2013 at 8:34 AM, arun smartpink...@yahoo.com wrote: Hi, You could also try: res1-sapply(y,function(i) {x1- expand.grid(x,x);fun1- function(a,op,b){ f1- match.fun(FUN=op); f1(a,b)};fun1(x1[,1],i,x1[,2])}) row.names(res1)- row.names(res) identical(res1,res) #[1] TRUE A.K. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 3:08 AM Subject: Re: Computing calculation among two vectors Hi, Try: x- 1:4 y- c(*,/,-,+) res-sapply(y,function(i) {x1-expand.grid(x,x); unlist(lapply(paste0(x1[,1],i,x1[,2]),function(u) eval(parse(text=u}) row.names(res)- as.character(interaction(expand.grid(x,x),sep=_)) head(res) #* / - + #1_1 1 1.0 0 2 #2_1 2 2.0 1 3 #3_1 3 3.0 2 4 #4_1 4 4.0 3 5 #1_2 2 0.5 -1 3 #2_2 4 1.0 0 4 A.K. I have two vectors one numeric and another with operand. Eg: x - 1,2,3,4 and y-*, /, -, + I need to calculate all the possible two combinations in x with each of operand in y. As example, 1*2, 1/2, 1-2, 1+2, 1*3, 1/3 Any help appreciated. Regards Hussain __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] animate dataframe
Hi, I'm running a code which does some alignment between data. Now I want to follow the alignment while looping over the data. I'm aware of the animation package, and saw the (easy) example where a plot is animated by calling 100 times plot. Is it possible to use this trick also for printing a dataframe to the graphics device? I tried already addtable2plot, but the table doesn't fit in the graphics device (or I'm doing something wrong). Here a simplified example of how the data looks and how it is filled: dat - data.frame(rows=rep(1:10, 15), columns=rep(1:15, each=10), result=NA) dat$result - NA i = 0 while (!all(!is.na(dat$result))) { i = i + 1 if (i==100) break dat$result[sample(1:nrow(dat),1)] - rnorm(1) } in each loop should be something like: print(as.data.frame(tapply(dat$result,list(rows=dat$rows,columns=dat$columns), function(x) paste(x[x!=],collapse=/ Thanks Bart PS: I know that I can use a for loop instead of the while and if (i==100) break construction, but hey, its an example, right? ;-) [[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] Animate dataframe
Hi, sorry for the double posting, but it seems my text was gone... I'm running a code which does some alignment between data. Now I want to follow the alignment while looping over the data. I'm aware of the animation package, and saw the (easy) example where a plot is animated by calling 100 times plot. Is it possible to use this trick also for printing a dataframe to the graphics device? I tried already addtable2plot, but the table doesn't fit in the graphics device (or I'm doing something wrong). Here a simplified example of how the data looks and how it is filled: dat - data.frame(rows=rep(1:10, 15), columns=rep(1:15, each=10), result=NA) dat$result - NA i = 0 while (!all(!is.na(dat$result))) { i = i + 1 if (i==100) break dat$result[sample(1:nrow(dat),1)] - rnorm(1) } in each loop should be something like: print(as.data.frame(tapply(dat$result,list(rows=dat$rows,columns=dat$columns), function(x) paste(x[x!=],collapse=/ Thanks Bart PS: I know that I can use a for loop instead of the while and if (i==100) break construction, but hey, its an example, right? ;-) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Computing calculation among two vectors
I guess you meant something like: res2- sapply(y,function(i) outer(x,x,i)) row.names(res2)- row.names(res) identical(res2,res) #[1] TRUE #or is there any shorter way? A.K. From: Bert Gunter gunter.ber...@gene.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, September 25, 2013 11:46 AM Subject: Re: [R] Computing calculation among two vectors A cute problem. Is it homework? Hint: ?outer (will provide a much simpler solution than those given below) -- Bert On Wed, Sep 25, 2013 at 8:34 AM, arun smartpink...@yahoo.com wrote: Hi, You could also try: res1-sapply(y,function(i) {x1- expand.grid(x,x);fun1- function(a,op,b){ f1- match.fun(FUN=op); f1(a,b)};fun1(x1[,1],i,x1[,2])}) row.names(res1)- row.names(res) identical(res1,res) #[1] TRUE A.K. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 3:08 AM Subject: Re: Computing calculation among two vectors Hi, Try: x- 1:4 y- c(*,/,-,+) res-sapply(y,function(i) {x1-expand.grid(x,x); unlist(lapply(paste0(x1[,1],i,x1[,2]),function(u) eval(parse(text=u}) row.names(res)- as.character(interaction(expand.grid(x,x),sep=_)) head(res) # * / - + #1_1 1 1.0 0 2 #2_1 2 2.0 1 3 #3_1 3 3.0 2 4 #4_1 4 4.0 3 5 #1_2 2 0.5 -1 3 #2_2 4 1.0 0 4 A.K. I have two vectors one numeric and another with operand. Eg: x - 1,2,3,4 and y-*, /, -, + I need to calculate all the possible two combinations in x with each of operand in y. As example, 1*2, 1/2, 1-2, 1+2, 1*3, 1/3 Any help appreciated. Regards Hussain __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error when using ps() function on categorical variables - re propensity score matching
Dear List, I am having difficulty running the ps() function when variables are stored as factors and was hoping someone could provide some advice on how to proceed. I am running propensity score matching as outlined in: Greg Ridgeway, Dan McCarey, Andrew Morral, Lane Burgette and Beth Ann Grin (May 3, 2013) Toolkit for Weighting and Analysis of Nonequivalent Groups: A tutorial for the twang package and have a question about using unordered categorical variables as a covariates. The tutorial indicates that: There is no need to create indicator, or dummy coded, variables to represent categorical covariates, provided the categorical variables are stored as a factor or as ordered However, when I run the ps() function after converting categorical variables to factors using the factor() function, I return the following warning: Warning in model.matrix(glm.object) * resid(glm.object, working) : longer object length is not a multiple of shorter object length and followed by an error: Error in x$fpc$sampsize[i, , drop = FALSE] : (subscript) logical subscript too long Interestingly, the code runs without warning or error when variables are not converted to factors. Thanks in advance! ANDREW H. KEMP, PhD Invited International Visiting Professor, University of São Paulo Associate Professor, University of Sydney __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] drc - package
Hi, my english is not the best, i hope its comprehensible. Can i ask here in german too? my problem: I have plottet a curve with weibull1.4. I want to define a value on the y-axis and get the value of the x-axis for the plotted curve. This is my command: library(drc) effect-c(0,22.84,40.74,54.63,62.04,59.26) conc-c(0,90,150,260,440,750) drm(effect~conc,fct=W1.4()) model-drm(effect~conc,fct=W1.4()) summary(model) plot(model) ED(model,c(50),interval='delta') With: ED(model,c(50),interval='delta') i get a value, but it is not on the fitted curve. What to do? Thanks Fabian -- View this message in context: http://r.789695.n4.nabble.com/drc-package-tp4676924.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 to fix col.regions mapping in multiple spplot?
Hello, I have a question on sp package. I drew pixel heat maps of continental U.S. using insurance litigation data. If an insurance claim is litigated at a certain location, 1 is assigned; otherwise 0 is assigned. I have assigned a value between 0 and 1 to each pixel on my map using inverse-distance weighting (spatial smoothing). I need to draw two pixel maps, one for period 2001-2006 and the other for period 2007-2010, to gauge the impacts of regulation changes in certain states. However, the same probability (eg. 10%) is mapped to two different colors in two plots, making the maps incomparable. So the mapping from data to colors is determined by the range of the data? Is it possible to fix the color mapping (from value to color) in advance, so that the two heat maps will share not only the same palette but also the same mapping? color palette: rbs - rainbow(100, start=.5, end=1) X - spplot(idw.out['litigated'], sp.layout=list('sp.polygons',STATE_SPL, first=FALSE), *col.regions=rbs*, main=list(label=expression( atop('Claim Litigation', atop(italic('notice date 2001 - 2006') ) )), cex=3), xlab = list('industry = construction', cex=2, col='blue') ) Thank you! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re: Multiple vector elements into one character element
Hi A.K., This is exactly what I needed: x - data.frame(Month = airquality$Month, Day = as.character(airquality$Day)) y - aggregate(x$Day ~ x$Month, data = x, paste, collapse = , ) write.table(y, y.txt, row.names = FALSE, quote = FALSE, sep = '\t') The trick is to use collapse in the aggregate function. Many thanks Haiko P.S.: Bert, dput writes R code so that's not what I needed. But many thanks also! Von: r-help-boun...@r-project.org [r-help-boun...@r-project.org]quot; im Auftrag von quot;arun [smartpink...@yahoo.com] Gesendet: Mittwoch, 25. September 2013 16:57 An: R help Betreff: Re: [R] Multiple vector elements into one character element Hi, May be this helps: y- aggregate(Day~Month,data=x,paste,collapse=,) write.table(y,file.txt,quote=FALSE) A.K. - Original Message - From: Lietz, Haiko haiko.li...@gesis.org To: 'r-help@r-project.org' r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 9:10 AM Subject: [R] Multiple vector elements into one character element Hi all, I want to collapse multiple elements of a vector into a single comma-separated character element. I only know how to create a list of the original elements, but I have not managed to write this into a text file, which is necessary. To illustrate, let's use the airquality dataset and extract the Month and Day columns: library(datasets) x - data.frame(Month = airquality$Month, Day = as.character(airquality$Day)) Using the aggregate function y - aggregate(x$Day ~ x$Month, data = x, paste) only seemingly creates what I want because the list can't be written to a file. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 for the first row should actually be a character element. I've tried it but sapply, ascii, write.matrix don't seem get me there. Can someone please point me towards the function I need? Best wishes Haiko Haiko Lietz GESIS - Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8, D-50667 Köln Tel: + 49 (0) 221 / 476 94 -223 eMail: haiko.li...@gesis.orgmailto:haiko.li...@gesis.org Web: http://www.gesis.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Slight misinformation in OSX version of R
I just installed R on a Mac without any traces of earlier versions. It exhibited a well know problem: WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work. Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly. The information needed is in section 7, not in section 9. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Best and worst values for each date
Hi, May be you can try this: obj_name- load(arun.RData) Pred1- get(obj_name[1]) Actual1- get(obj_name[2]) library(reshape2) dat-cbind(melt(Pred1,id.vars=S1),value2=melt(Actual1,id.vars=S1)[,3]) # to reshape to long form colnames(dat)[3:4]- c(Predict,Actual) dat$variable- as.character(dat$variable) #not that needed dat1- dat[!(is.na(dat$Predict)|is.na(dat$Actual)),] # removes the NA values in columns Predict and Actual res- do.call(rbind,lapply(split(dat1,dat1$S1),function(x){x1-x[order(x$Predict),] xlow-if(sum(x1$Predict0) 5){ #in cases where you don't have 5 negative numbers x1[x1$Predict0,] } else { x1[x1$Predict0,][1:5,] # select first five rows } xhigh- if(sum(x1$Predict0) 5){ #not having 5 postive numbers x1[x1$Predict0,]} else { tail(x1[x1$Predict0,],5) } rbind(xhigh[rev(order(xhigh$Predict)),],xlow)})) ##reverse the order of high values dim(res) #[1] 480 4 A.K. From: Ira Sharenow irasharenow...@yahoo.com To: arun smartpink...@yahoo.com Sent: Wednesday, September 25, 2013 12:55 PM Subject: Best and worst values for each date Arun, I hope you have been doing well. I have a new problem. I have two data frames, one for predictions and one for the actual returns. Each day I act on the returns that have the 5 highest values and the five lowest values. I then want to compare to the actual values. So I need to subset my two original data frames so that the stocks and their prices that remain after each day are the ones I want. At the end of filtering there will be one data frame for predictions and one data frame for actual values. Now for an enhancement. NA values cannot be part of the reduced data frames but will occur in great proportion in the original data frames. Each day I need to check that the top five are positive; otherwise I need to reduce that number as needed. Similarly I need for the bottom five are negative. At the end of 50 days each original data frame will have 5 * 2 * 50 = 500 rows, but this step may reduce that number. I attached a smallish file with the two data frames. The real ones have hundreds of columns and over 1,000 rows. Please aim for simplicity. If the solution is complex, please explain. Do you want me to use a different email address? Thanks. Ira Example. But the stocks are not set up this way. The highlighted stocks are in the first data frames. Predict Actual 1/3/2006 S1 3 -1.943 1/3/2006 S20 4 10.376 1/3/2006 S3 2 8.611 1/3/2006 S4 1 7.465 1/3/2006 S5 0 1.648 1/3/2006 S6 -1 5.36 1/3/2006 S7 -2 4.36 1/3/2006 S8 -3 3.574 1/3/2006 S9 -4 2.748 1/3/2006 S10 -5 1.933 1/3/2006 S11 -6 0.548 1/3/2006 S12 -7 -0.66 1/3/2006 S13 -8 -1.793 1/3/2006 S14 -9 -2.163 1/3/2006 S15 -10 -3.077 1/3/2006 S16 -11 -4.723 1/3/2006 S17 -12 -5.919 1/3/2006 S18 -13 -6.529 1/3/2006 S19 -14 -7.979 1/3/2006 S20 -15 -8.064 After making sure only positives are in for top 5 predictions and only negatives for the bottom 5 predictions 1/3/2006 S1 3 -1.943 1/3/2006 S20 4 10.376 1/3/2006 S3 2 8.611 1/3/2006 S4 1 7.465 1/3/2006 S16 -11 -4.723 1/3/2006 S17 -12 -5.919 1/3/2006 S18 -13 -6.529 1/3/2006 S19 -14 -7.979 1/3/2006 S20 -15 -8.064 Note that the next day different stocks may be selected. Also there cannot any NA in either the Predict or Actual columns. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] weighting in glmmadmb(family='nbinom') with RE
Hello, I was wondering if weighting has been added to glmmadmb as of yet? I found a post about a year ago that it it hadn't been implemented yet but I was hoping the documentation may just have not yet caught up. Thanks, Trevor Davies [[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] Slight misinformation in OSX version of R
Erich Neuwirth erich.neuwirth at univie.ac.at writes: I just installed R on a Mac without any traces of earlier versions. It exhibited a well know problem: WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work. Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly. The information needed is in section 7, not in section 9. You should probably post this to r-devel, where it is slightly more likely that an R-core member will see it and fix the docs. (Small fixes like this are apparently preferred on R-devel to in the R bug tracker .) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Slight misinformation in OSX version of R
On 25/09/2013 22:29, Ben Bolker wrote: Erich Neuwirth erich.neuwirth at univie.ac.at writes: I just installed R on a Mac without any traces of earlier versions. It exhibited a well know problem: Not 'well known' (sic) at all: most of us do not break our OS X. We don't have reproduction instructions (see the posting guide), but I bet this is from R.app and not R (see below). R.app is a separate project with separate maintainers. WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work. Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly. The information needed is in section 7, not in section 9. You should probably post this to r-devel, where it is slightly more likely that an R-core member will see it and fix the docs. (Small fixes like this are apparently preferred on R-devel to in the R bug tracker .) But actually R-sig-mac for issues with R.app: see the posting guide. (I don't think it is the docs which need fixing, but R.app itself. And that string is translated, so the translations need changing too.) -- 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] Checking a large data set for normality
On 09/25/13 16:10, David Winsemius wrote: SNIP There is quite a bit of misinformation about the need for normality, some of it presented by Six Sigma experts or even by college professors who should know better. One might even say that if you don't know how to check for normality then there is a high likelihood that you should not be doing so. Fortune nomination! cheers, Rolf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cosine window in r
I'm pretty sure that your answer has nothing to do with what the OP was asking about. OTOH it's up to the OP to make it clear what he ***is*** asking and he did not do that. cheers, Rolf Turner On 09/26/13 01:00, João Pedro Alves wrote: x-seq(0,2*pi,by=0.01) y-cos(x) plot(x,y,type='l') On 25-09-2013 13:22, Babak Bastan wrote: Hi experts Can some one tell me, how can I implement Cosine window in r? Is there a function for that? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Best and worst values for each date
Ira, You may try also with ?ddply() dat2- data.frame(S1=rep(Pred1[,1],ncol(Pred1)-1),variable=rep(colnames(Pred1)[-1],each=nrow(Pred1)),Predict=unlist(Pred1[,-1],use.names=FALSE),Actual=unlist(Actual1[,-1],use.names=FALSE),stringsAsFactors=FALSE) identical(dat,dat2) #[1] TRUE dat2New- dat2[!(is.na(dat2$Predict)|is.na(dat2$Actual)),] dat3- dat2New[order(dat2New$S1,dat2New$Predict),] library(plyr) res2- ddply(dat3,.(S1),summarize, cbind(c(head(rev(Predict),5),head(Predict,5)),c(head(rev(Actual),5),head(Actual,5 #in the example data this works res2New- data.frame(S1=res2[,1],Predict=res2[,2][,1],Actual=res2[,2][,2]) res3- res2New[res2New$Predict!=0,] row.names(res3)- 1:nrow(res3) identical(res3,res[,-2]) #[1] TRUE But, if you have fewer number of positive or negative values, then the loop method or trying individually with ?ddply would be appropriate. A.K. - Original Message - From: arun smartpink...@yahoo.com To: Ira Sharenow irasharenow...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, September 25, 2013 4:24 PM Subject: Re: Best and worst values for each date Hi, May be you can try this: obj_name- load(arun.RData) Pred1- get(obj_name[1]) Actual1- get(obj_name[2]) library(reshape2) dat-cbind(melt(Pred1,id.vars=S1),value2=melt(Actual1,id.vars=S1)[,3]) # to reshape to long form colnames(dat)[3:4]- c(Predict,Actual) dat$variable- as.character(dat$variable) #not that needed dat1- dat[!(is.na(dat$Predict)|is.na(dat$Actual)),] # removes the NA values in columns Predict and Actual res- do.call(rbind,lapply(split(dat1,dat1$S1),function(x){x1-x[order(x$Predict),] xlow-if(sum(x1$Predict0) 5){ #in cases where you don't have 5 negative numbers x1[x1$Predict0,] } else { x1[x1$Predict0,][1:5,] # select first five rows } xhigh- if(sum(x1$Predict0) 5){ #not having 5 postive numbers x1[x1$Predict0,]} else { tail(x1[x1$Predict0,],5) } rbind(xhigh[rev(order(xhigh$Predict)),],xlow)})) ##reverse the order of high values dim(res) #[1] 480 4 A.K. From: Ira Sharenow irasharenow...@yahoo.com To: arun smartpink...@yahoo.com Sent: Wednesday, September 25, 2013 12:55 PM Subject: Best and worst values for each date Arun, I hope you have been doing well. I have a new problem. I have two data frames, one for predictions and one for the actual returns. Each day I act on the returns that have the 5 highest values and the five lowest values. I then want to compare to the actual values. So I need to subset my two original data frames so that the stocks and their prices that remain after each day are the ones I want. At the end of filtering there will be one data frame for predictions and one data frame for actual values. Now for an enhancement. NA values cannot be part of the reduced data frames but will occur in great proportion in the original data frames. Each day I need to check that the top five are positive; otherwise I need to reduce that number as needed. Similarly I need for the bottom five are negative. At the end of 50 days each original data frame will have 5 * 2 * 50 = 500 rows, but this step may reduce that number. I attached a smallish file with the two data frames. The real ones have hundreds of columns and over 1,000 rows. Please aim for simplicity. If the solution is complex, please explain. Do you want me to use a different email address? Thanks. Ira Example. But the stocks are not set up this way. The highlighted stocks are in the first data frames. Predict Actual 1/3/2006 S1 3 -1.943 1/3/2006 S20 4 10.376 1/3/2006 S3 2 8.611 1/3/2006 S4 1 7.465 1/3/2006 S5 0 1.648 1/3/2006 S6 -1 5.36 1/3/2006 S7 -2 4.36 1/3/2006 S8 -3 3.574 1/3/2006 S9 -4 2.748 1/3/2006 S10 -5 1.933 1/3/2006 S11 -6 0.548 1/3/2006 S12 -7 -0.66 1/3/2006 S13 -8 -1.793 1/3/2006 S14 -9 -2.163 1/3/2006 S15 -10 -3.077 1/3/2006 S16 -11 -4.723 1/3/2006 S17 -12 -5.919 1/3/2006 S18 -13 -6.529 1/3/2006 S19 -14 -7.979 1/3/2006 S20 -15 -8.064 After making sure only positives are in for top 5 predictions and only negatives for the bottom 5 predictions 1/3/2006 S1 3 -1.943 1/3/2006 S20 4 10.376 1/3/2006 S3 2 8.611 1/3/2006 S4 1 7.465 1/3/2006 S16 -11 -4.723 1/3/2006 S17 -12 -5.919 1/3/2006 S18 -13 -6.529 1/3/2006 S19 -14 -7.979 1/3/2006 S20 -15 -8.064 Note that the next day different stocks may be selected. Also there cannot any NA in either the Predict or
Re: [R] Checking a large data set for normality
On Sep 25, 2013, at 5:55 AM, steric wrote: It was just a question to see if it was possible on a large data set. I wasn't looking for a flame war. New strategy is simply new strategy. Half of my time spent on R is trying to find a better way. If you say why you want to do a global test with such a function and what function you had in mind for a single vector, then perhaps: lapply( dfrm[sapply(dfrm, is.numeric)], your_preferred_normaility_check_fun) If you specify the statistical issues, then there might be a more specific response. There is a long history of people coming to Rhelp asking for tests of normality and being given similar advice as I gave. There are also many people who mistakenly believe that you need normality of predictor variables to do regression. There is en entire Task View on robust methods. There is also: install.packages(TeachingDemos) library(TeachingDemos) ?SnowsPenultimateNormalityTest You are asked in the Posting Guide to do some searching of the archives. I use Markmail for my searches but others use the Newcastle search site or Rseek. -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Besag endive data
Dear all, a few weeks ago I have seen a package containing the so called endive dataset first appeared in Besag (1978) Some Methods of Statistical Analysis for Spatial Data, Bulletin of the International Statistical Institute, 47, 77-92. Now I would need to use the dataset, but I can no longer find it. Does anybody know where I can find the dataset? Thanks, Marco -- * Marco Bee University of Trento - Department of Economics and Management via Inama, 5 - 38122 Trento, Italy Phone: +39-0461-282296, Fax: +39-0461-282241 E-mail: marco@unitn.it * [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Missing value handling for felm function in lfe package
megha patnaik wrote Dear All, I am trying to use the felm function in the lfe package. However it does not seem to deal with missing values the way the lm function does. I wish to tell it na.omit or na.action = na.omit but it does not recognize this. I need to allow for missing values as I have different specifications and don't want to remove observations for all. Help on this will be greatly appreciated! As the author of the lfe-package I will put this on my todo list. -- Simen Gaure -- View this message in context: http://r.789695.n4.nabble.com/Missing-value-handling-for-felm-function-in-lfe-package-tp4674948p4676941.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] Less than equal to symbol in ggplot2 legend text
Hello, I am trying to add a less than equal to symbol in a ggplot2 legend text. See sample code below. I have tried using the expression function and \u2264. I also tried adding labels to legend.text under theme. Neither of these 3 options work. Please help, Mahesh ++ Extra.column=ifelse(data[,covariate]cutpoint,1,0) Grp1 - \u2264 1.5 Grp2 - 1.5 Extra.column=factor(Extra.column,levels=c(0,1),labels=c(Grp1,Grp2)) data2=cbind.data.frame(data,Extra.column) df - ddply(data2, .(Time,Extra.column), summarize, N = length(Yvar), meanYvar=mean(Yvar), seYvar=sd(Yvar)/sqrt(length(Yvar))) df = df[df$N=10,] PLot=ggplot(df, aes(x=AVST, y=meanYvar, shape=Extra.column)) + scale_y_continuous(name=Mean Yvar ± SE )+ scale_x_continuous(name=Time (year))+ theme(axis.text.x = element_text(size=16,colour=black),legend.title = element_blank(), axis.text.y = element_text(size=16,colour=black),plot.title = element_text( face=bold,size=18), legend.justification=c(0,1), legend.position=c(0,1), axis.title.x = element_text(face=bold, colour=black, size=16,vjust=0), axis.title.y = element_text(face=bold, colour=black, size=16,vjust=0.3), legend.text = element_text(size = 12, face = bold )) + ggtitle(GGTitle)+ geom_line() + geom_point(size=5) + geom_errorbar(width=0.1, aes(ymin=meanYvar-seYvar, ymax=meanYvar+seYvar)) PLot [[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] Less than equal to symbol in ggplot2 legend text
Hello, Please post in plain text, as kindly requesting by the R-help posting guide. Your code is completely messy. Regards, Pascal 2013/9/26 mahesh samtani msamt...@gmail.com Hello, I am trying to add a less than equal to symbol in a ggplot2 legend text. See sample code below. I have tried using the expression function and \u2264. I also tried adding labels to legend.text under theme. Neither of these 3 options work. Please help, Mahesh ++ Extra.column=ifelse(data[,covariate]cutpoint,1,0) Grp1 - \u2264 1.5 Grp2 - 1.5 Extra.column=factor(Extra.column,levels=c(0,1),labels=c(Grp1,Grp2)) data2=cbind.data.frame(data,Extra.column) df - ddply(data2, .(Time,Extra.column), summarize, N = length(Yvar), meanYvar=mean(Yvar), seYvar=sd(Yvar)/sqrt(length(Yvar))) df = df[df$N=10,] PLot=ggplot(df, aes(x=AVST, y=meanYvar, shape=Extra.column)) + scale_y_continuous(name=Mean Yvar Ä SE )+ scale_x_continuous(name=Time (year))+ theme(axis.text.x = element_text(size=16,colour=black),legend.title = element_blank(), axis.text.y = element_text(size=16,colour=black),plot.title = element_text( face=bold,size=18), legend.justification=c(0,1), legend.position=c(0,1), axis.title.x = element_text(face=bold, colour=black, size=16,vjust=0), axis.title.y = element_text(face=bold, colour=black, size=16,vjust=0.3), legend.text = element_text(size = 12, face = bold )) + ggtitle(GGTitle)+ geom_line() + geom_point(size=5) + geom_errorbar(width=0.1, aes(ymin=meanYvar-seYvar, ymax=meanYvar+seYvar)) PLot [[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. -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan [[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] table of contents link style in R's PDF docs
Hello, I am mildly annoyed each time I use a PDF doc of an R package that the table of contents hyperlinks are *only* on the page numbers. To activate a hyperlink, one must carefully scan sideways from the text item wanted to the far right of the page and click on a tiny box. Multiply that mild annoyance by the large number of times I need to look up package help docs, and I find myself here writing this message. From my understanding (albeit poor), all of the R docs for packages are to be written in Rd format. From that they are converted by the functions in the tools package as required (to latex and PDF, or HTML, etc). So the only thing that controls in the PDF docs the hyperlinks one way or another is the latex style file used - in this case I believe it is Rd.sty (/usr/share/R/share/texmf/tex/latex/Rd.sty on my system). Line 303 of that file contains the single setting of the \hypersetup{} command for whether or not the text in the table of contents is hyperlinked, or the page number: linktocpage,% which causes it to implicitly be set to True. Setting it to false (or just commenting out that line I suppose as false is the default) would mean the *text* in the TOC is hyperlinked. So, is the desired behaviour intended to be that only the page numbers are hyperlinked (and therefore to annoy me), or has no-one really bothered themselves with it that much, or something else? Can I recreate all the documentation on my system after I make a change to Rd.sty? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MaxLik estimation issues
Dear Filipe On 25 September 2013 14:23, Filipe Ribeiro flipjribe...@hotmail.com wrote: Hello everybody! I'm having some trouble to compute maximum likelihood estimations using maxLik package and I hope that you could give me a hint. The main problem is that I'm not able to get a result not even close to the ones given by glm() directly, and the second one is: Error in maxNRCompute(fn = logLikAttr, fnOrig = fn, gradOrig = grad, hessOrig = hess, : NA in gradient. The codes: loglike.GGompiMaxLik - function(theta,age,deaths,exposures) { alpha - exp(theta[1]) beta - exp(theta[2]) gamma - exp(theta[3]) first - alpha*exp(beta*age) second - 1+(((alpha*gamma)/beta)*(exp(beta*age)-1)) mu - first/second llk - -sum((deaths * log(mu)) + (- mu*exposures)) return(llk) } fit1 - maxLik(loglike.GGompiMaxLik, age=0:6, deaths=c(15545, 21278, 32444, 36201, 30360, 14201, 5198), exposures=c(935023.67, 819392.00, 724568.17, 470947.00, 231951.64, 69502.65, 15798.72), start=c(-4.1402817, -0.6375773, -1.6945914)) Do you know how I can solve this problem? You did not write which model specification you want to estimate but I am pretty sure that something in your log-likelihood function is incorrect. The log-likelihood value at the starting values of the parameters is so large that R even cannot calculate the likelihood value: a - loglike.GGompiMaxLik(c(-4.1402817, -0.6375773, -1.6945914), age=0:6, + deaths=c(15545, 21278, 32444, 36201, 30360, 14201, 5198), + exposures=c(935023.67, 819392.00, 724568.17, 470947.00, + 231951.64, 69502.65, 15798.72)) a [1] 580365.2 exp(a) [1] Inf In the second iteration, the first parameter gets so small (large in absolute terms, -5e+10) that the log-likelihood value become extremely (numerically infinitely) large and the gradients cannot be computed (by the finite-difference method): fit1 - maxLik(loglike.GGompiMaxLik, + age=0:6, + deaths=c(15545, 21278, 32444, 36201, 30360, 14201, 5198), + exposures=c(935023.67, 819392.00, 724568.17, 470947.00, + 231951.64, 69502.65, 15798.72), + start=c(-4.1402817, -0.6375773, -1.6945914)) Iteration 2 Parameter: [1] -5.174233e+10 -3.839076e+02 5.988668e+00 Gradient: [,1] [,2] [,3] [1,] NaN NaN NaN Error in maxNRCompute(fn = logLikAttr, fnOrig = fn, gradOrig = grad, hessOrig = hess, : NA in gradient b - loglike.GGompiMaxLik(c(-5.174233e+10, -3.839076e+02, 5.988668e+00), age=0:6, + deaths=c(15545, 21278, 32444, 36201, 30360, 14201, 5198), + exposures=c(935023.67, 819392.00, 724568.17, 470947.00, + 231951.64, 69502.65, 15798.72)) b [1] Inf Please note that you can also find hints and ask questions about the maxLik package in the forums at maxLik's R-Forge site: https://r-forge.r-project.org/projects/maxlik/ ...and please do not forget to cite the maxLik package in your publications: http://cran.r-project.org/web/packages/maxLik/citation.html Best wishes, Arne -- Arne Henningsen http://www.arne-henningsen.name __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Importing, renaming columns and exporting mulitple csv files in R
Hi All, I have 1029 *.csv files that I would like read individually into R, delete some columns and rename others, and then export individually using the original file names. I have written some script to do this for an individual file (script below), but cannot get it to loop through all the files in the directory. name1-read.table(file=FID-AW1775_DV0228012H_ 20080518.csv,sep=,,header=TRUE) names(name1)[23]-Reef % cover # renames column 23 names(name1)[19]-Redundant # renames column 19 data - subset(name1, select=-c(31:38)) # deletes column 31-38 names(data)[31]-Comments # renames column 31 names(data)[11]-Confidence # renames column 11 names(data)[1]- # renames column 1 names(data)[22]- # renames column 22 names(data) # check correct columns have been deleted and renamed write.csv(data,file = FID-AW1775_DV0228012H_ 20080518_v2.csv,sep=,,col.names=TRUE,row.names=FALSE, na=) I have tried looping using For (i in 1:length(files)){... but it seams to read all the files into one massive file rather than process them individually. Any ideas on how to get this to loop on individual files and write them out again would be appreciated. Chrs, Jac -- View this message in context: http://r.789695.n4.nabble.com/Importing-renaming-columns-and-exporting-mulitple-csv-files-in-R-tp4676951.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] Importing, renaming columns and exporting mulitple csv files in R
Hi, Try: If the files are all in the same working directory, #for example list.files() # 3 files in my WD #[1] file1.csv file2.csv file3.csv lapply(list.files(),function(x) {names1-read.csv(x,header=TRUE); names(names1)[c(19,23)]- c(Redundant,Reef % cover); dat1- subset(names1,select=-c(31:38)); names(dat1)[c(1,11,22,31)]- c(,Confidence,,Comments); names(dat1);write.csv(dat1,paste0(Modified_,x),row.names=FALSE,na=) }) A.K. - Original Message - From: Jacquomo Monk jacquomo.m...@deakin.edu.au To: r-help@r-project.org Cc: Sent: Wednesday, September 25, 2013 9:13 PM Subject: [R] Importing, renaming columns and exporting mulitple csv files in R Hi All, I have 1029 *.csv files that I would like read individually into R, delete some columns and rename others, and then export individually using the original file names. I have written some script to do this for an individual file (script below), but cannot get it to loop through all the files in the directory. name1-read.table(file=FID-AW1775_DV0228012H_ 20080518.csv,sep=,,header=TRUE) names(name1)[23]-Reef % cover # renames column 23 names(name1)[19]-Redundant # renames column 19 data - subset(name1, select=-c(31:38)) # deletes column 31-38 names(data)[31]-Comments # renames column 31 names(data)[11]-Confidence # renames column 11 names(data)[1]- # renames column 1 names(data)[22]- # renames column 22 names(data) # check correct columns have been deleted and renamed write.csv(data,file = FID-AW1775_DV0228012H_ 20080518_v2.csv,sep=,,col.names=TRUE,row.names=FALSE, na=) I have tried looping using For (i in 1:length(files)){... but it seams to read all the files into one massive file rather than process them individually. Any ideas on how to get this to loop on individual files and write them out again would be appreciated. Chrs, Jac -- View this message in context: http://r.789695.n4.nabble.com/Importing-renaming-columns-and-exporting-mulitple-csv-files-in-R-tp4676951.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Importing, renaming columns and exporting mulitple csv files in R
A.K. Thanks for the reply. Will give it a try... Jac -- View this message in context: http://r.789695.n4.nabble.com/Importing-renaming-columns-and-exporting-mulitple-csv-files-in-R-tp4676951p4676959.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.