Re: [R] poisson fit for histogram
What does fit.dist do that fitdistr (MASS) does not in this context? (It plots, but that is very easy to do in base R. However, to see if a Poisson fits you need a test of goodness-of-fit.) BTW, `decompress and store the files in your library folder' is on no OS (you did not mention one but Thomas did) the way to install a package. Even on Windows (where it might just work) there are simpler and better ways to do it, like using a menu. Note that Lindsey does not provide pre-compiled packages for MacOS X, the platform Thomas is using (and as they use Fortran, people have reported that they are tricky to install on MacOS X), and your recipe is `seriously' misleading there. On Fri, 22 Jul 2005, Francisco J. Zagmutt wrote: I would first reccomend you to update your version of R. Then download the libraries rmutil and gnlm from Jim Lindsey at http://www.luc.ac.be/~jlindsey/rcode.html decompress and store the files in your library folder. Sorry but you will have to donwload a package unless you seriously want to re-invent the wheel. Finally try library(gnlm) ?fit.dist() Cheers Francisco From: Thomas Isenbarger [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] poisson fit for histogram Date: Wed, 20 Jul 2005 10:40:51 -0500 I haven't been an R lister for a bit, but I hope to enlist someone's help here. I think this is a simple question, so I hope the answer is not much trouble. Can you please respond directly to this email address in addition to the list (if responding to the list is warranted)? I have a histogram and I want to see if the data fit a Poisson distribution. How do I do this? It is preferable if it could be done without having to install any or many packages. I use R Version 1.12 (1622) on OS X Thank-you very much, Tom Isenbarger -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice: reversing order of panel placement in conditional histograms
From what I understand, you want to set up a factor with the levels reversed. It is not that `5 is larger than 1', but that you created a factor with the levels in alphabetic order. Lattice plots in the order of the levels. Something like f - factor(f, levels=rev(levels(f))) will do this. For the horizontal factor, give the levels in the order you want them to appear (which might not be the reverse of alphabetic). On Sat, 23 Jul 2005, Sam Ferguson wrote: I have a question about lattice in general, and histogram specfically. How do you control the ordering of factors that controls the placement of the conditional panels. I have a dataset with factors that go 'Q1','Q2',Q3','Q5' and of course I want the plot to place Question Q1 at the top and Question Q5 at the bottom of the graphical output. histogram() does the opposite as 5 is larger than 1. Similarly my 'AlertFormat' factor is a textual category, and I need the data to read from left to right (representing old to new) , with 'New A V' on the right, and 'Pre-existing A V' on the left, which is the opposite to how histogram plots. The current lattice output from what's below is here:- http://www.arch.usyd.edu.au/~sfer9710/latticeoutput.pdf All I really want to do is reverse the placement entirely from what I have received above. I've checked the help to no avail, and have looked through the r-help archive. I love lattice, but always have problems of this nature. I hope someone can help me solve them. -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] about nnet package
Wensui Liu wrote: you might need quit(yes) when you exit R. I think nobody want to save the whole workspace if just one object is of interest, hence you save(), as already mentioned in a former post. Uwe Ligges On 7/22/05, Baoqiang Cao [EMAIL PROTECTED] wrote: Hello Uwe Ligges, I might misdiscribe my question. What I thought is that, after nnetObject-nnet(...), this nnetObject will be gone after I exit R. Since I need the trained nnetObject for next time without training it again, how can I save this nnetObject (to some files I guess)? Thanks. Best regards, Baoqiang Cao === At 2005-07-22, 11:17:37 you wrote: === Baoqiang Cao wrote: Dear All, I'm learning to train a neural network with my training data by using nnet package, then evaluate it with a evaluation set. My problem here is that, I need the trained network to be used in future, so, what should I store? and How? Any other options other than nnet package? Any example will be highly appreciated! Best, Baoqiang Cao See ?nnet which point you to its predict method. You say nnetObject - nnet(.) Now store the nnetObject and use it later as in: predict(nnetObject, newdata) Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html . = = = = = = = = = = = = = = = = = = = = __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] cor(X) with P-Value
Friends I am new to R (and statistics) so am struggling a bit. Briefly... I am interested in getting the P-Value from cor(X) where X is a matrix. I have found cor.test. Verbosely... I have 4 vectors and can generate the corellation matrix... cor(cbind(X1, X2, X3, X4)) X1 X2 X3 X4 X1 1. -0.06190365 -0.156972795 0.182547517 X2 -0.06190365 1. 0.264352860 0.146750844 X3 -0.15697279 0.26435286 1.0 -0.006380052 X4 0.18254752 0.14675084 -0.006380052 1.0 But I want the P-Values (gives me the significance I belive). cor.test(X2, X3) Pearson's product-moment correlation data: X2 and X3 t = 3.3346, df = 148, p-value = 0.001080 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.1086963 0.4073565 sample estimates: cor 0.2643529 is very cool. Just what I want. But there is too much information for too little data. What I would like to do is some thing like... cor_with_p_test(cbind(X1, X2, X3, X4)) X1 X2 X3 X11 -0.06190365 -0.1569728... P0.4517 0.05507 ... X2 -0.06190365 10.2643529 ... P 0.45170.001080 ... : : I think I could write a function for it if such a function does not exist if I could do... CT23 - cor.test(X2, X3) CT23$P 0.001080 CT23$V 0.2643529 But I do not know how. cheers Worik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cor(X) with P-Value
These functions are based on posts to either R-Help or S-News by Gabor Grothendieck and Bill Venables. # pairwise sample size # Gabor G - 11/23/2004 R-help List pn - function(X){crossprod(!is.na(X))} cor.prob - function(X){ # Correlations Below Main Diagonal # Significance Tests with Pairwise Deletion # Above Main Diagonal # Believe part of this came from Bill Venables pair.SampSize - pn(X) above1 - row(pair.SampSize) col(pair.SampSize) pair.df - pair.SampSize[above1] - 2 R - cor(X, use=pair) above2 - row(R) col(R) r2 - R[above2]^2 Fstat - (r2 * pair.df)/(1 - r2) R[above2] - 1 - pf(Fstat, 1, pair.df) R } mydata - matrix(rnorm(1000), ncol=10) cor.prob(mydata) Worik Turei stanton wrote: Friends I am new to R (and statistics) so am struggling a bit. Briefly... I am interested in getting the P-Value from cor(X) where X is a matrix. I have found cor.test. Verbosely... I have 4 vectors and can generate the corellation matrix... cor(cbind(X1, X2, X3, X4)) X1 X2 X3 X4 X1 1. -0.06190365 -0.156972795 0.182547517 X2 -0.06190365 1. 0.264352860 0.146750844 X3 -0.15697279 0.26435286 1.0 -0.006380052 X4 0.18254752 0.14675084 -0.006380052 1.0 But I want the P-Values (gives me the significance I belive). cor.test(X2, X3) Pearson's product-moment correlation data: X2 and X3 t = 3.3346, df = 148, p-value = 0.001080 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.1086963 0.4073565 sample estimates: cor 0.2643529 is very cool. Just what I want. But there is too much information for too little data. What I would like to do is some thing like... cor_with_p_test(cbind(X1, X2, X3, X4)) X1 X2 X3 X11 -0.06190365 -0.1569728... P0.4517 0.05507 ... X2 -0.06190365 10.2643529 ... P 0.45170.001080 ... : : I think I could write a function for it if such a function does not exist if I could do... CT23 - cor.test(X2, X3) CT23$P 0.001080 CT23$V 0.2643529 But I do not know how. cheers Worik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] The steps of building library in R 2.1.1
Nick Drew wrote: Agreed, It takes a lot of work for one to create his/her first package. And there are many opportunities to get it wrong. I just created my first package, with thanks to Gabor, Peter Rossi (and his excellent document at http://gsbwww.uchicago.edu/fac/peter.rossi/research/bayes%20book/bayesm/Maki ng%20R%20Packages%20Under%20Windows.pdf ), and the guys who developed http://www.maths.bris.ac.uk/~maman/computerstuff/Rhelp/Rpackages.html . I could not have done it without them!!! Could you point out the specific bits that are missing from the R-Admin manual (and perhaps supply them)? It won't get better unless someone improves it. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cor(X) with P-Value
Worik Turei stanton wrote: Friends I am new to R (and statistics) so am struggling a bit. Briefly... I am interested in getting the P-Value from cor(X) where X is a matrix. I have found cor.test. Verbosely... I have 4 vectors and can generate the corellation matrix... cor(cbind(X1, X2, X3, X4)) X1 X2 X3 X4 X1 1. -0.06190365 -0.156972795 0.182547517 X2 -0.06190365 1. 0.264352860 0.146750844 X3 -0.15697279 0.26435286 1.0 -0.006380052 X4 0.18254752 0.14675084 -0.006380052 1.0 But I want the P-Values (gives me the significance I belive). cor.test(X2, X3) Pearson's product-moment correlation data: X2 and X3 t = 3.3346, df = 148, p-value = 0.001080 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.1086963 0.4073565 sample estimates: cor 0.2643529 is very cool. Just what I want. But there is too much information for too little data. What I would like to do is some thing like... cor_with_p_test(cbind(X1, X2, X3, X4)) X1 X2 X3 X11 -0.06190365 -0.1569728... P0.4517 0.05507 ... X2 -0.06190365 10.2643529 ... P 0.45170.001080 ... : : I think I could write a function for it if such a function does not exist if I could do... CT23 - cor.test(X2, X3) CT23$P 0.001080 CT23$V 0.2643529 But I do not know how. cheers Worik library(Hmisc) rcorr(cbind(. . . .)) -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Package libblas.so.3 not found installing R2.1.1 on Linux FC4
I am trying to install R.2.1.1 under Linux FC4 using RPM. During the installation I get the following message: The following package could not be found on your system. Installation cannot continue until it is installed. The package in question of libblas.so.3. Does anyone know where I can get the package? Can I use RPM to intall the package? Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC and University of Maryland School of Medicine Claude Pepper OAIC University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 410-605-7119 - NOTE NEW EMAIL ADDRESS: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Package libblas.so.3 not found installing R2.1.1 on Linux FC4
John Sorkin [EMAIL PROTECTED] writes: I am trying to install R.2.1.1 under Linux FC4 using RPM. During the installation I get the following message: The following package could not be found on your system. Installation cannot continue until it is installed. The package in question of libblas.so.3. Does anyone know where I can get the package? Can I use RPM to intall the package? Thanks, John [EMAIL PROTECTED] standalone]$ locate libblas.so.3 /usr/lib/libblas.so.3 /usr/lib/libblas.so.3.0.3 /usr/lib/libblas.so.3.0 [EMAIL PROTECTED] standalone]$ rpm -qf /usr/lib/libblas.so.3 blas-3.0-29 Guess... ;-) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Question about 'text' (add lm summary to a plot)
On Fri, 22 Jul 2005, Marc Schwartz (via MN) wrote: Ok guys, So I played around with this a bit, going back to Dan's original requirements and using Thomas' do.call() approach with legend(). Gabor's approach using sapply() will also work here. I have the following: # Note the leading spaces here for alignment in the table # This could be automated with formatC() or sprintf() my.slope.1 -3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua - 0.97 plot(1:5) L - list(Intercept:, Slope:, bquote(paste(R^2, :)), bquote(.(my.inter.1) %+-% .(my.inter.2)), bquote(.(my.slope.1) %+-% .(my.slope.2)), bquote(.(my.Rsqua))) par(family = mono) legend(topleft, legend = do.call(expression, L), ncol = 2) Note however, that while using the mono font helps with vertical alignment of numbers, the +/- sign still comes out in the default font, which is bold[er] than the text. If one uses the default font, which is variable spaced, it is problematic to get the proper alignment for the numbers. I even tried using phantom(), but that didn't quite get it, since the spacing is variable, as opposed to LaTeX's mono numeric spacing with default fonts. Also, note that I am only using two columns, rather than three, since trying to place the : as a middle column results in spacing that is too wide, given that the text.width argument is a scalar and is set to the maximum width of the character vectors. Note also that even with mono spaced fonts, the exponent in R^2 is still horizontally smaller than the other characters. Thus, spacing on that line may also be affected depending upon what else one might attempt. Not sure where else to go from here. Ahh... So lovely! Thank you all so much! I made a couple of tweeks to improve the overall appearance, using x.intersp = 0.1 tightens up the overall appearance, and using pch=c('','','',':',':',':') adds the (aligned!) colons. Here is the beauty... my.slope.1 - 3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua - 0.97 plot(1:5) L - list(Intercept, Slope, bquote(paste(R^2)), bquote(.(my.inter.1) %+-% .(my.inter.2)), bquote(.(my.slope.1) %+-% .(my.slope.2)), bquote(.(my.Rsqua))) par(family = mono) legend(topleft, #inset=-1, legend = do.call(expression, L), bg='white', ncol = 2, pch=c('','','',':',':',':'), x.intersp = 0.1, title=Yay! Thank You! ) However (the final gripe ;) it seems 'inset=' dosn't work. Setting this to anything (including the default) seems to surpress the legend without error. But hey! Thanks again, HTH, Marc Schwartz On Fri, 2005-07-22 at 14:01 -0400, Gabor Grothendieck wrote: You are right. One would have to use do.call as you did or the sapply method of one of my previous posts: a - 7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=sapply(L, as.expression)) On 7/22/05, Thomas Lumley [EMAIL PROTECTED] wrote: On Fri, 22 Jul 2005, Gabor Grothendieck wrote: I think legend accepts a list argument directly so that could be simplified to just: a-7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=L) Except that it wouldn't then work: the mathematical stuff comes out as text. The same comment seems to apply to my prior suggestion about as.expression(bquote(...)), namely that one can just write the following as text also supports a list argument: And this doesn't work either: you end up with %+-% rather than the plus-or-minus symbol. The reason I gave the do.call() version is that I had tried these simpler versions and they didn't work. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Question about 'text' (add lm summary to a plot)
On Sat, 23 Jul 2005, Dan Bolser wrote: On Fri, 22 Jul 2005, Marc Schwartz (via MN) wrote: Ok guys, So I played around with this a bit, going back to Dan's original requirements and using Thomas' do.call() approach with legend(). Gabor's approach using sapply() will also work here. I have the following: # Note the leading spaces here for alignment in the table # This could be automated with formatC() or sprintf() my.slope.1 -3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua - 0.97 plot(1:5) L - list(Intercept:, Slope:, bquote(paste(R^2, :)), bquote(.(my.inter.1) %+-% .(my.inter.2)), bquote(.(my.slope.1) %+-% .(my.slope.2)), bquote(.(my.Rsqua))) par(family = mono) legend(topleft, legend = do.call(expression, L), ncol = 2) Note however, that while using the mono font helps with vertical alignment of numbers, the +/- sign still comes out in the default font, which is bold[er] than the text. If one uses the default font, which is variable spaced, it is problematic to get the proper alignment for the numbers. I even tried using phantom(), but that didn't quite get it, since the spacing is variable, as opposed to LaTeX's mono numeric spacing with default fonts. Also, note that I am only using two columns, rather than three, since trying to place the : as a middle column results in spacing that is too wide, given that the text.width argument is a scalar and is set to the maximum width of the character vectors. Note also that even with mono spaced fonts, the exponent in R^2 is still horizontally smaller than the other characters. Thus, spacing on that line may also be affected depending upon what else one might attempt. Not sure where else to go from here. Ahh... So lovely! Thank you all so much! I made a couple of tweeks to improve the overall appearance, using x.intersp = 0.1 tightens up the overall appearance, and using pch=c('','','',':',':',':') adds the (aligned!) colons. Here is the beauty... my.slope.1 - 3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua - 0.97 plot(1:5) L - list(Intercept, Slope, bquote(paste(R^2)), bquote(.(my.inter.1) %+-% .(my.inter.2)), bquote(.(my.slope.1) %+-% .(my.slope.2)), bquote(.(my.Rsqua))) par(family = mono) legend(topleft, #inset=-1, legend = do.call(expression, L), bg='white', ncol = 2, pch=c('','','',':',':',':'), x.intersp = 0.1, title=Yay! Thank You! ) However (the final gripe ;) it seems 'inset=' dosn't work. Setting this to anything (including the default) seems to surpress the legend without error. But hey! Oh Error in strwidth(legend, units = user, cex = cex) : family mono not included in PostScript device Execution halted Thanks again, HTH, Marc Schwartz On Fri, 2005-07-22 at 14:01 -0400, Gabor Grothendieck wrote: You are right. One would have to use do.call as you did or the sapply method of one of my previous posts: a - 7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=sapply(L, as.expression)) On 7/22/05, Thomas Lumley [EMAIL PROTECTED] wrote: On Fri, 22 Jul 2005, Gabor Grothendieck wrote: I think legend accepts a list argument directly so that could be simplified to just: a-7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=L) Except that it wouldn't then work: the mathematical stuff comes out as text. The same comment seems to apply to my prior suggestion about as.expression(bquote(...)), namely that one can just write the following as text also supports a list argument: And this doesn't work either: you end up with %+-% rather than the plus-or-minus symbol. The reason I gave the do.call() version is that I had tried these simpler versions and they didn't work. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PBSmapping and shapefiles
On Fri, 22 Jul 2005, Denis Chabot wrote: Hi, I got no reply to this: Le 16-Jul-05 à 2:42 PM, Denis Chabot a écrit : Hi, Is there a way, preferably with R, to read shapefiles and transform them in a format that I could then use with package PBSmapping? I have been able to read such files into R with maptools' read.shape and plot it with plot.Map, but I'd like to bring the data to PBSmapping and plot from there. I also looked at the package shapefile, but it does not seem to do what I want either. Sincerely, Denis Chabot but I managed to progress somewhat on my own. Although it does not allow one to use shapefiles in PBSmapping, maptools at least makes it possible to read such files. In some cases I can extract the information I want from not-too-complex shapefiles. For instance, to extract all the lines corresponding to 60-m isobath in a shapefile, I was able to do: library(maptools) test - read.shape(bathy.shp) test2 - Map2lines(test) bathy60 - subset(test2, test$att.data$Z == 60) I do not quite understand the structure of bathy60 (list of lists I think) but at this point I resorted to printing bathy60 on the console and imported that text into Excel for further cleaning, which is easy enough. I'd like to complete the process within R to save time and to circumvent Excel's limit of around 64000 lines. But I have a hard time figuring out loops in R, coming from a background of observation based programs such as SAS. The output of bathy60 looks like this: [[1]] [,1] [,2] [1,] -55.99805 51.68817 [2,] -56.00222 51.68911 [3,] -56.01694 51.68911 [4,] -56.03781 51.68606 [5,] -56.04639 51.68759 [6,] -56.04637 51.69445 [7,] -56.03777 51.70207 [8,] -56.02301 51.70892 [9,] -56.01317 51.71578 [10,] -56.00330 51.73481 [11,] -55.99805 51.73840 attr(,pstart) attr(,pstart)$from [1] 1 attr(,pstart)$to [1] 11 attr(,nParts) [1] 1 attr(,shpID) [1] NA [[2]] [,1] [,2] [1,] -57.76294 50.88770 [2,] -57.76292 50.88693 [3,] -57.76033 50.88163 [4,] -57.75668 50.88091 [5,] -57.75551 50.88169 [6,] -57.75562 50.88550 [7,] -57.75932 50.88775 [8,] -57.76294 50.88770 attr(,pstart) attr(,pstart)$from [1] 1 attr(,pstart)$to [1] 8 attr(,nParts) [1] 1 attr(,shpID) [1] NA What I need to produce for PBSmapping is a file where each block of coordinates shares one ID number, called PID, and a variable POS indicating the number of each coordinate within a shape. All other lines must disappear. So the above would become: PID X Y 1 1 -55.99805 51.68817 1 2 -56.00222 51.68911 1 3 -56.01694 51.68911 1 4 -56.03781 51.68606 1 5 -56.04639 51.68759 1 6 -56.04637 51.69445 1 7 -56.03777 51.70207 1 8 -56.02301 51.70892 1 9 -56.01317 51.71578 1 10 -56.00330 51.73481 1 11 -55.99805 51.73840 2 1 -57.76294 50.88770 2 2 -57.76292 50.88693 2 3 -57.76033 50.88163 2 4 -57.75668 50.88091 2 5 -57.75551 50.88169 2 6 -57.75562 50.88550 2 7 -57.75932 50.88775 2 8 -57.76294 50.88770 I don't know how to do this in R. My algorithm would involve looking at the structure of a line, discarding it if not including coordinates, and then creating PID and POS for lines with coordinates, depending on the content of lines i and i-1. In R? The way to do it would be to manipulate the Map$Shapes object directly, making sure that the Map$att.data records stay associated with them. If you could send me (off-list) a small sample shapefile, I'll see if there are obvious solutions - they'll probably be through the sp package. Roger Bivand Thanks in advance, Denis Chabot __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Question about 'text' (add lm summary to a plot)
Here are a few tweaks. We form a matrix and use round and format to automatically get the right number of decimals and widths right. We have added extra digits to show that they do not affect the result. Also the paste in the R^2 line was eliminated. nn - matrix(c(-10.661, 1.961,# intercept 3.221, 0.131,# slope 0.971, NA), 3, 2, byrow = TRUE) # Rsquared nnf - apply(round(nn,2), 2, format) plot(1:5) L - list(Intercept, Slope, bquote(R^2), bquote(.(nnf[1,1]) %+-% .(nnf[1,2])), bquote(.(nnf[2,1]) %+-% .(nnf[2,2])), bquote(.(nnf[3,1]))) par(family = mono) legend(topleft, #inset=-1, legend = do.call(expression, L), bg='white', ncol = 2, pch=c('','','',':',':',':'), x.intersp = 0.4, title=Yay! Thank You! ) On 7/23/05, Dan Bolser [EMAIL PROTECTED] wrote: On Fri, 22 Jul 2005, Marc Schwartz (via MN) wrote: Ok guys, So I played around with this a bit, going back to Dan's original requirements and using Thomas' do.call() approach with legend(). Gabor's approach using sapply() will also work here. I have the following: # Note the leading spaces here for alignment in the table # This could be automated with formatC() or sprintf() my.slope.1 -3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua - 0.97 plot(1:5) L - list(Intercept:, Slope:, bquote(paste(R^2, :)), bquote(.(my.inter.1) %+-% .(my.inter.2)), bquote(.(my.slope.1) %+-% .(my.slope.2)), bquote(.(my.Rsqua))) par(family = mono) legend(topleft, legend = do.call(expression, L), ncol = 2) Note however, that while using the mono font helps with vertical alignment of numbers, the +/- sign still comes out in the default font, which is bold[er] than the text. If one uses the default font, which is variable spaced, it is problematic to get the proper alignment for the numbers. I even tried using phantom(), but that didn't quite get it, since the spacing is variable, as opposed to LaTeX's mono numeric spacing with default fonts. Also, note that I am only using two columns, rather than three, since trying to place the : as a middle column results in spacing that is too wide, given that the text.width argument is a scalar and is set to the maximum width of the character vectors. Note also that even with mono spaced fonts, the exponent in R^2 is still horizontally smaller than the other characters. Thus, spacing on that line may also be affected depending upon what else one might attempt. Not sure where else to go from here. Ahh... So lovely! Thank you all so much! I made a couple of tweeks to improve the overall appearance, using x.intersp = 0.1 tightens up the overall appearance, and using pch=c('','','',':',':',':') adds the (aligned!) colons. Here is the beauty... my.slope.1 - 3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua - 0.97 plot(1:5) L - list(Intercept, Slope, bquote(paste(R^2)), bquote(.(my.inter.1) %+-% .(my.inter.2)), bquote(.(my.slope.1) %+-% .(my.slope.2)), bquote(.(my.Rsqua))) par(family = mono) legend(topleft, #inset=-1, legend = do.call(expression, L), bg='white', ncol = 2, pch=c('','','',':',':',':'), x.intersp = 0.1, title=Yay! Thank You! ) However (the final gripe ;) it seems 'inset=' dosn't work. Setting this to anything (including the default) seems to surpress the legend without error. But hey! Thanks again, HTH, Marc Schwartz On Fri, 2005-07-22 at 14:01 -0400, Gabor Grothendieck wrote: You are right. One would have to use do.call as you did or the sapply method of one of my previous posts: a - 7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=sapply(L, as.expression)) On 7/22/05, Thomas Lumley [EMAIL PROTECTED] wrote: On Fri, 22 Jul 2005, Gabor Grothendieck wrote: I think legend accepts a list argument directly so that could be simplified to just: a-7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=L) Except that it wouldn't then work: the mathematical stuff comes out as text. The same comment seems to apply to my prior suggestion about as.expression(bquote(...)), namely that one can just write the following as text also supports a list argument: And this doesn't work either: you end up with %+-% rather than the plus-or-minus symbol. The reason I gave the do.call() version is that I had tried these simpler versions and they didn't work. -thomas __ R-help@stat.math.ethz.ch mailing list
[R] %03d in the pdf command
The pdf man page contains the following text: pdf(file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf), width = 6, height = 6, onefile = TRUE, family = Helvetica, title = R Graphics Output, fonts = NULL, version = 1.1, paper, encoding, bg, fg, pointsize) I am creating multi-page graphics in which each page is saved as a separate file. If I invoke onefile=T and I include %03d in the filename, each page is saved as a separate file. However, I don't understand the %03d. Can someone explain? Am I calling a register that contains the page number? Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [R-pkgs] tseriesChaos ver. 0.1
Dear all, I have uploaded to CRAN a new package: tseriesChaos. This is an early version (0.1) with basic tools for the explorative analysis of nonlinear time series motivated by chaos theory. Until now, the package is largely inspired by the TISEAN project (by Rainer Hegger, Holger Kantz and Thomas Schreiber: http://www.mpipks-dresden.mpg.de/~tisean/ ). This version includes: - Method of false nearest neighbours for the choice of the embedding dimension. - Tools for the estimation of the correlation dimension. - Kantz algorithm for the estimation of the largest Lyapunov exponent. - (naif) mutual information index estimation. - Space-time separation plot. - Recurrence plot. - Simulation of noise-free continuous dynamic systems. At the present time, algorithms are not too much optimized for speed, we are working on optimizing the codes. Future versions will (hopefully) include also code inspired from the book of Chan and Tong (2001) (Chaos: A Statistical perspective) by Springer as well as other contributions. Checking was mainly done by comparing results with those available in literature. Any kind of feedback/help would be greatly appreciated. Antonio, Fabio Di Narzo. ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] %03d in the pdf command
On Sat, 23 Jul 2005, Dennis Fisher wrote: The pdf man page contains the following text: pdf(file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf), width = 6, height = 6, onefile = TRUE, family = Helvetica, title = R Graphics Output, fonts = NULL, version = 1.1, paper, encoding, bg, fg, pointsize) I am creating multi-page graphics in which each page is saved as a separate file. If I invoke onefile=T and I include %03d in the filename, each page is saved as a separate file. However, I don't understand the %03d. Can someone explain? Am I calling a register that contains the page number? See ?sprintf, or man printf on your system. It formats the page number in that C format. -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] %03d in the pdf command
On 23-Jul-05 Prof Brian Ripley wrote: On Sat, 23 Jul 2005, Dennis Fisher wrote: The pdf man page contains the following text: pdf(file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf), width = 6, height = 6, onefile = TRUE, family = Helvetica, title = R Graphics Output, fonts = NULL, version = 1.1, paper, encoding, bg, fg, pointsize) I am creating multi-page graphics in which each page is saved as a separate file. If I invoke onefile=T and I include %03d in the filename, each page is saved as a separate file. However, I don't understand the %03d. Can someone explain? Am I calling a register that contains the page number? See ?sprintf, or man printf on your system. It formats the page number in that C format. If it's still obscure, the effect of the format string Rplot%03d.pdf is that a string is generated consisting of the characters Rplot followed by an integer of width 3 digits (padded to the left with zeros if required to make the width equal to 3), followed by the characters d.pdf where the value to be inserted in place of %3d will be derived from somewhere -- not specified in the command itself but deducible from ?pdf: If onefile=TRUE then you get all figures in a single file whose name is Rplots.pdf, otherwise you get them succesively in separate files with names Rplot001.pdf Rplot002.pdf Rplot003.pdf Rplot004.pdf ... Rplot998.pdf Rplot999.pdf after which you run out of road. Hoping this helps, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 23-Jul-05 Time: 22:22:15 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] calling R from C or C++
Hi, I have C/C++ code from which I wish I could call R to do something useful. I saw a 2003 message by Thomas saying that You can compile R as a shared library, which allows you to construct and evaluate R expressions from C. Any more information would be helpful. I am looking for some documentation that has a more step by step like instructions. Anyone who has experience, please point me to some resources. ps. There is a document on CRAN named Writing R extensions which seems relevant, but it was too difficult for me to understand. Thanks in advance! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] calling R from C or C++
Hi, I have C/C++ code from which I wish I could call R to do something useful. By calling I mean linking with the R shared library, instead of R BATCH. In particular, I want to use regression functions such as ridge and locfit. I saw a 2003 message by Thomas saying that You can compile R as a shared library, which allows you to construct and evaluate R expressions from C. Any more information would be helpful. I am looking for some documentation that has a more step by step like instructions. Anyone who has experience, please point me to some resources. ps. There is a document on CRAN named Writing R extensions which seems relevant, but it was too difficult for me to understand. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] imbalanced data set
Hi, I have a question of classification on imbalanced dataset. I am wondering if there is a package which can solve this problem via sampling approach, like one-sided selection. A follow-up question is, how to select those 'representative' samples and remove noise/borderlines and redundancy in order to increase classification accuracy. Is there any work which has been implemented in R or some GNU softwares? Thanks, weiwei -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html