Re: [R] Overlaying a single contour from a new data array in levelplot
Dear Deepayan, Thank you once again. I needed to install the latest versions of R and lattice and now it all works fine and the border is in white, which is perfect. Thank you for all the support you offer users of lattice, Best Wishes, Jenny That should have been fixed by now. Is there anything that's not working as you expect? My code had: lapply(add.cl, panel.polygon, border = 'red') which should have made the borders red. If it doesn't, you probably need to upgrade to a recent version of R/lattice. If it does, changing it to border='white' should suffice. If that doesn't work, please provide a reproducible example. -Deepayan On 7/30/07, Jenny Barnes [EMAIL PROTECTED] wrote: Dear Deepayan Thank you for your response - it has proved very very helpful, I can't thank you enough! I have another question for you if you have time to reply. I know you have been asked about the colour of the polygon outline before (27 April 2007) and you replied that is a bug and the border can only be black or transparent... I was wondering if you have found a way to change the colour of the outline since this correspondence? If not please can you tell me how to get around this myself? You mentioned writing a replacement to lpolygon - I do not know how to do this - would it be possible for you to guide me further? I would really benefit from having the border of the polygon in white as it goes over the sea which is also white and would therefore only be seen over the land, much neater! Many thanks, Jenny On 7/24/07, Jenny Barnes jmb_at_mssl.ucl.ac.uk wrote: Dear R-Help community, I am trying to overlay a single contour line over a correlation plot using levelplot in the lattice package. These are the two arrays: 1) a correlation plot over Africa - so each grid square is a different colour dependent on correlation - this is in an array: result_cor with dim[465,465] 2) a single contour line from a ***different data source*** - this is from data related to the p-values for the above correlation plot - I want to overlay only the 95% confidence contour. The p-values are stored in an array: result.p.values with same dimensions as above. I have read about using panel.levelplot and panel.contourplot in the R-help mailing list but I don't know the right way to call two different data arrays, can anybody help me please? I appreciate your time and help with this question. I can think of a couple of different ways, but the simplest will probably be to compute the single contour beforehand and add it after the standard levelplot using a panel function. E.g., using the 'volcano' data for both matrices: ## you need the explicit x and y arguments because ## the default is different from levelplot. vcl - contourLines(x = seq_len(nrow(volcano)), y = seq_len(ncol(volcano)), z = volcano, levels = c(172, 182)) levelplot(volcano, add.cl = vcl, panel = function(..., add.cl) { panel.levelplot(...) lapply(add.cl, panel.polygon, border = 'red') }) -Deepayan ~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Overlaying a single contour from a new data array in levelplot
Dear Deepayan Thank you for your response - it has proved very very helpful, I can't thank you enough! I have another question for you if you have time to reply. I know you have been asked about the colour of the polygon outline before (27 April 2007) and you replied that is a bug and the border can only be black or transparent... I was wondering if you have found a way to change the colour of the outline since this correspondence? If not please can you tell me how to get around this myself? You mentioned writing a replacement to lpolygon - I do not know how to do this - would it be possible for you to guide me further? I would really benefit from having the border of the polygon in white as it goes over the sea which is also white and would therefore only be seen over the land, much neater! Many thanks, Jenny On 7/24/07, Jenny Barnes jmb_at_mssl.ucl.ac.uk wrote: Dear R-Help community, I am trying to overlay a single contour line over a correlation plot using levelplot in the lattice package. These are the two arrays: 1) a correlation plot over Africa - so each grid square is a different colour dependent on correlation - this is in an array: result_cor with dim[465,465] 2) a single contour line from a ***different data source*** - this is from data related to the p-values for the above correlation plot - I want to overlay only the 95% confidence contour. The p-values are stored in an array: result.p.values with same dimensions as above. I have read about using panel.levelplot and panel.contourplot in the R-help mailing list but I don't know the right way to call two different data arrays, can anybody help me please? I appreciate your time and help with this question. I can think of a couple of different ways, but the simplest will probably be to compute the single contour beforehand and add it after the standard levelplot using a panel function. E.g., using the 'volcano' data for both matrices: ## you need the explicit x and y arguments because ## the default is different from levelplot. vcl - contourLines(x = seq_len(nrow(volcano)), y = seq_len(ncol(volcano)), z = volcano, levels = c(172, 182)) levelplot(volcano, add.cl = vcl, panel = function(..., add.cl) { panel.levelplot(...) lapply(add.cl, panel.polygon, border = 'red') }) -Deepayan ~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Overlaying a single contour from a new data array in levelplot
Dear R-Help community, I am trying to overlay a single contour line over a correlation plot using levelplot in the lattice package. These are the two arrays: 1) a correlation plot over Africa - so each grid square is a different colour dependent on correlation - this is in an array: result_cor with dim[465,465] 2) a single contour line from a ***different data source*** - this is from data related to the p-values for the above correlation plot - I want to overlay only the 95% confidence contour. The p-values are stored in an array: result.p.values with same dimensions as above. I have read about using panel.levelplot and panel.contourplot in the R-help mailing list but I don't know the right way to call two different data arrays, can anybody help me please? I appreciate your time and help with this question. Many thanks, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] random numbers selection - simple example
Dear R-help, Which random number generator function would you recommend for simply picking 15 random numbers from the sequence 0-42? I want to use replacement (so that the same number could potentially be picked more than once). I have read the R-help archives and the statistics and computing book on modern Applied statistics with S but the advice seems to be for much form complicated examples, there must be a simpler way for what I am trying to do? If anybody can help me I would greatly appreciate your advice and time, Best Wishes, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] random numbers selection - simple example
You're all stars - thanks for the replies - I will go ahead and use sample... I need to do this about 10,000 times - any suggestions for this or simply put it in a loop 10,000 times outputting each time to an array? Best Wishes, Jenny use sample(c(0:42), 15, replace=T) hope it helps, kevin - Original Message - From: Jenny Barnes [EMAIL PROTECTED] Date: Wednesday, June 6, 2007 10:30 am Subject: [R] random numbers selection - simple example Dear R-help, Which random number generator function would you recommend for simply picking 15 random numbers from the sequence 0-42? I want to use replacement (so that the same number could potentially be picked more than once). I have read the R-help archives and the statistics and computing book on modern Applied statistics with S but the advice seems to be for much form complicated examples, there must be a simpler way for what I am trying to do? If anybody can help me I would greatly appreciate your advice and time, Best Wishes, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ 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.htmland provide commented, minimal, self-contained, reproducible code. ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] is there a function to give significance to correlation?
Dear R-Help, I am trying to find a function that will give me the significance of the correlation of 2 variables (in the same dimension arrays) correcting for serial autocorrelation. How can I view the function cor.test's code? I would like to know a lot more detail about the function than written in the documentation at http://finzi.psych.upenn.edu/R/library/stats/html/cor.test.html to see if this would do the job? I would gratefully appreciate any help you can offer me on these two interlinked issues, Many thanks for your time and consideration, Jenny PS. If you would like more detail I have two arrays both of dimensions [31,31,43]. 31x31 is latitude and longitude, 43 is years of rainfall data. I have produced a spearmans rank correlation map of these 2 arrays over this 43 year period. I now need to find the significance for each of the 31x31 grid points ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Problem installing R onto Solaris 2.10 system - need advice!!!!!
Dear R-Help friends, I am unable to get the latest version of R (2.4.1) to compile on my solaris 10 system - has anybody else experienced this problem and are you able to offer me any advice? I appreciate your time, many thanks, Jenny Barnes Here are my CURRENT specifications: platform sparc-sun-solaris2.10 arch sparc os solaris2.10 system sparc, solaris2.10 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing R onto Solaris 2.10 system - need advice!!!!!
Dear Andrew and R-help, Here is the error message that we got when trying to install R v2.4 (which we tried to install before this newer version 2.4.1 - I'm afrid I didn't save the error message from the latest attempt with the new version): configure make ... ... ... f90: CODE: 0 WORDS, DATA: 0 WORDS gcc -G -L/usr/local/lib -o stats.so init.o kmeans.o ansari.o bandwidths.o chisq sim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o swilk.o ksmooth .o loessc.o isoreg.o Srunmed.o Trunmed.o dblcen.o distance.o hclust-utils.o nl s.o HoltWinters.o PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o family.o sbart.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram.o si nerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o -L../../../.. /lib -lRblas -lg2c -lm -lgcc_s mkdir ../../../../library/stats/libs building package 'datasets' mkdir ../../../library/datasets mkdir ../../../library/datasets/R mkdir ../../../library/datasets/data Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/tmp/R-2.4.0/library/stats/libs/stats.so' : ld.so.1: R: fatal: relocation error: file /tmp/R-2.4.0/library/stats/libs/stat s.so: symbol __i_abs: referenced symbol not found Execution halted *** Error code 1 Many thanks, Jenny Hi Jenny, advice: try posting the error message accompanying the failure to compile. Cheers Andrew On Fri, Mar 16, 2007 at 09:19:24AM +, Jenny Barnes wrote: Dear R-Help friends, I am unable to get the latest version of R (2.4.1) to compile on my solaris 10 system - has anybody else experienced this problem and are you able to offer me any advice? I appreciate your time, many thanks, Jenny Barnes Here are my CURRENT specifications: platform sparc-sun-solaris2.10 arch sparc os solaris2.10 system sparc, solaris2.10 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] compiling latest version of R
Dear R-help community, I have had trouble in the past installing the latest version of R: we got the errors shown below (the computer specifications and version of R are below that). Does anybody have tips for compiling the latest version of R so that I can avoid these errors? configure make ... ... ... f90: CODE: 0 WORDS, DATA: 0 WORDS gcc -G -L/usr/local/lib -o stats.so init.o kmeans.o ansari.o bandwidths.o chisq sim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o swilk.o ksmooth .o loessc.o isoreg.o Srunmed.o Trunmed.o dblcen.o distance.o hclust-utils.o nl s.o HoltWinters.o PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o family.o sbart.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram.o si nerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o -L../../../.. /lib -lRblas -lg2c -lm -lgcc_s mkdir ../../../../library/stats/libs building package 'datasets' mkdir ../../../library/datasets mkdir ../../../library/datasets/R mkdir ../../../library/datasets/data Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/tmp/R-2.4.0/library/stats/libs/stats.so' : ld.so.1: R: fatal: relocation error: file /tmp/R-2.4.0/library/stats/libs/stat s.so: symbol __i_abs: referenced symbol not found Execution halted *** Error code 1 These are my specifications: platform sparc-sun-solaris2.10 arch sparc os solaris2.10 system sparc, solaris2.10 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) Many thanks for your time in reading this problem, I look forward to hearing your suggestions and advice, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend question
Hi folks, Do you mind if I ask a related question that I have been having trouble with - how do you put the legend outside of the plot area (to the bottom of the area - below the x-axis title)? Could anybody show me using the example given below: x - seq(-pi, pi, len = 65) plot(x, sin(x), type=l, col = 2) legend(x = -3, y = .9, legend text, pch = 1, xjust = 0.5) Thank you, I've not been able to do this simple bit of programming and it is very frustrating not to be able to add a simple key. Best Wishes, Jenny Hi Emili, Even though you are calling your horizontal coordinate y, and vertical coordinate z, the first and second arguments to legend(), namely x and y, should be the horizontal and vertical coordinates, respectively; and they are given in user coordinates (e.g., legend()'s x should be between 1960 and 1975 and legend()'s y should be between 1 and 4). If you want to use normalized coordinates (i.e. 0 to 1), you can scale as in this example: legend(x = par(usr)[1] + diff(par(usr)[1:2])*normalizedCoordX, y = par(usr)[3] + diff(par(usr)[3:4])*normalizedCoordY, ...) where normalizedCoordX and Y go from 0 to 1 (see ?par, par(usr) returns vector of c(xmin,xmax,ymin,ymax) of user coordinates on a plot) You can alternatively use legend(x = topleft,...) or bottomright, and so on to place your legend. If you want to add your legend outside of the plot, you should consider increasing the margins using the 'mar' argument in par(), and also setting par(xpd=TRUE) (so stuff can show up outside of the plotting region). Best regards, ST y-c(1960, 1965, 1970, 1975) z-c(1, 2, 3, 4) within the data limits of your x and y) --- Emili Tortosa-Ausina [EMAIL PROTECTED] wrote: Hi to all, I'm sorry for posting this question, I am sure I am missing something important but after reading the documentation I cannot find where the problem is. I want to add a legend to a figure. If I use a simple example drawn from the R Reference Manual such as, for instance: x - seq(-pi, pi, len = 65) plot(x, sin(x), type=l, col = 2) legend(x = -3, y = .9, legend text, pch = 1, xjust = 0.5) then everything works just fine. However, if I use other data such as, for instance: y-c(1960, 1965, 1970, 1975) z-c(1, 2, 3, 4) plot(y, z, type=l, col = 2) legend(x = -3, y = .9, legend text, pch = 1, xjust = 0.5) then the legend is not shown. Any hints? Thanks in advance, Emili __ 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 and provide commented, minimal, self-contained, reproducible code. Food fight? Enjoy some healthy debate __ 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 and provide commented, minimal, self-contained, reproducible code. - End Forwarded Message - ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] futures, investment, etc
Hi - you didn't give your name! http://finzi.psych.upenn.edu/search.html is a useful search engine from the help archives of R http://life.bio.sunysb.edu/~dstoebel/R/index.html is a mini-course in using R for statistical analysis http://www.stat.tamu.edu/~ljin/Finance/stat689-R.htm may be of more use to you as it is called Statistics and Finance: An Introduction in R Hope some of these links help you - R seems to be mostly about searching around on the internet (especially on that first search website) and finding your own way of doing things - it's so diverse (for example I am using R for climate and statistical analysis and producing graphs and maps). http://www.r-project.org/posting-guide.html This link is very useful (and I don't mean any offence) but it shows you how to ask good questions that are likely to prompt useful answers from this R-help mailing list.people on the mailing list are all very busy and involved in their own work, if you need help it can be very useful to write to this mailing list, but it pays to spend time writing the email using this posting guide - to get the best responses! Good luck, it's a steep learning curve :-) Jenny X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on hypatia.math.ethz.ch X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=5.0 tests=BAYES_60, BLANK_LINES_70_80, NO_REAL_NAME autolearn=no version=3.1.7 Date: Mon, 5 Feb 2007 07:33:45 +1100 (EST) From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at stat.math.ethz.ch X-Mailman-Approved-At: Mon, 05 Feb 2007 16:13:51 +0100 Subject: [R] futures, investment, etc X-BeenThere: r-help@stat.math.ethz.ch X-Mailman-Version: 2.1.9 List-Id: Main R Mailing List: Primary help r-help.stat.math.ethz.ch List-Unsubscribe: https://stat.ethz.ch/mailman/listinfo/r-help, mailto:[EMAIL PROTECTED] List-Archive: https://stat.ethz.ch/pipermail/r-help List-Post: mailto:r-help@stat.math.ethz.ch List-Help: mailto:[EMAIL PROTECTED] List-Subscribe: https://stat.ethz.ch/mailman/listinfo/r-help, mailto:[EMAIL PROTECTED] Content-Transfer-Encoding: 7bit X-MSSL-MailScanner-Information: Please contact the ISP for more information X-MSSL-MailScanner: No virus found X-MSSL-MailScanner-SpamCheck: not spam, SpamAssassin (score=-0.152, required 5, BAYES_01 -1.52, NO_REAL_NAME 0.16, PRIORITY_NO_NAME 1.21) Hi I am just starting to look at R and trading in futures, stock, etc Can anyone point me to useful background material? __ 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 and provide commented, minimal, self-contained, reproducible code. ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] correlation value and map
Dear R-help community, I have 2 different arrays of precipitation data each of the same dimensions of [longitude, latitude, time] dim=[30,32,43], called array1 and array2. I need to correlate them. This is the code I used to get one overall correlation value for the whole of the area of interest: result - cor(array1,array2,use=complete.obs) result This give me a single value but I'm not convinced it is actually a correlation value for the total area for the total time period of 43 yearscan anybody tell me if I am indeed wrong in my coding and/or indeed my low knowledge of the statistics of correlation. Also, I wanted to produce a correlation map over the 43 years. Could you also advise me if this is correct, I am more confident that this is than the above code: result - array(NA, c(30,32)) for(i in 1:30){ for(j in 1:32){ array1.ts - array1[i,j,] array2.ts - array2[i,j,] result[i,j] - cor(array1.ts,array2.ts,use= complete.obs) } } I appreciate your time very much. If I don't iron out this problem now the ground-work for my entire PhD will not be stable at all, Many thanks for reading my problem, happy 2007 :-) Jenny Barnes Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] correlation value and map
Hi Zoltan, Right, I have 30x32=960 data points per year (It is actually the mean febuary precipitation total in case you were wondering) at each grid point over the world, so I have 960 data points each of the 43 years. Therefore can I do anything with a trend and residuals? I don't think I can if it's just mean feb precipitation, one data point per grid square per year... I apreicate your help though very much.although I do still need to perform a spatial correlation if anyone else can help? Many thanks, Jenny Hi Jenny! So if i understand your datafile corect you have 960 case for a year. Any you have 43 years.. Yes? I'm not sure you should use correlation in this situation because of the autocorrelation of the data. There are big autocorrelation on spatial data's like what you use, and there are also a very big autocorrelation in time series data. I think you have to decompose your time series, and you have to cut down, the trend (and maybe some kind of sesonality), and than for the residuals you should do a correlation. You have to filter out the autocorrelation on the spatial data too, some way.. And because of the above problems, don't calculate correlation for the entierly databases! bye, Zoltan Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] loop is going to take 26 hours - needs to be quicker!
Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Dear R-help, I forgot to mention that I need the array in that format because I am going to do the same thing for another dataset of precipitation (ncep.data2) so they are both arrays of dimensions [144,72,46] so that I can correlate them globally and plot a visual image of the global correlations between the 2 datasets One of the datasets has a land mask applied to it already so it should be clear to see the land and pick ot the locations (i.e.over Europe) where there is strongest and weakest correlation.that is the ultimate goal. Following Rainer's response I should also point out that the columns in gpcc.data2 (with dimensions dim(gpcc.data2) = [476928,5]) are: [,1]=Year, [,2]=month (which is just january so always 1), [,3]=latitude, [,4]=longitude and [,5]=data. All I want in the gpcc.array is the data not the longitudes and latitude values...hope that helps clear it up a bit! I look forward to hearing any more ideas, thanks again for your time in reading this, Jenny Barnes Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } I don't know if it is faster - but adding three columns to qpcc.data, one for longitude, one for lattitude and one for year (using rep() as they are in sequence) and the using reshape() might be faster? So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)86 516 2782 Fax: +27 - (0)21 808 3304 (w) Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Dear R-help, Thank you for the responses off everyone- you'll be please to hear Duncan that using: gpcc.array - array(gpcc.data2[,5], c(144, 72, 46)) was spot-on, worked like a dream. The data is in the correct places as I checked with the text file. It took literally 2 seconds - quite an improvement time on the predicted 26 hours :-) I really really appreciate your help, you're all very very kind people. Merry Christmas, Jenny Barnes Date: Thu, 14 Dec 2006 08:17:24 -0500 From: Duncan Murdoch [EMAIL PROTECTED] User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Jenny Barnes [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] loop is going to take 26 hours - needs to be quicker! Content-Transfer-Encoding: 7bit X-MSSL-MailScanner-Information: Please contact the ISP for more information X-MSSL-MailScanner: No virus found X-MSSL-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.9, required 5, BAYES_00 -4.90) On 12/14/2006 7:56 AM, Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! I think the loop above is equivalent to gpcc.array - array(gpcc.data2[,5], c(144, 72, 46)) which would certainly be a lot quicker. You should check that the values are loaded in the right order (probably on a smaller example!). If not, you should change the order of indices when you create the array, and use the aperm() function to get them the way you want afterwards. Duncan Murdoch Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Dear Patrick, Thank you for the link - I'd advise anyone who's started using R to have a look at these as well - any help is always appreciated. I've downloaded the S Poetry and will hit the books tomorrow and get reading it! Jenny S Poetry may be of use to you -- especially the chapter on arrays which discusses 3 dimensional arrays in particular. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Jenny Barnes wrote: Dear R-help, I forgot to mention that I need the array in that format because I am going to do the same thing for another dataset of precipitation (ncep.data2) so they are both arrays of dimensions [144,72,46] so that I can correlate them globally and plot a visual image of the global correlations between the 2 datasets One of the datasets has a land mask applied to it already so it should be clear to see the land and pick ot the locations (i.e.over Europe) where there is strongest and weakest correlation.that is the ultimate goal. Following Rainer's response I should also point out that the columns in gpcc.data2 (with dimensions dim(gpcc.data2) = [476928,5]) are: [,1]=Year, [,2]=month (which is just january so always 1), [,3]=latitude, [,4]=longitude and [,5]=data. All I want in the gpcc.array is the data not the longitudes and latitude values...hope that helps clear it up a bit! I look forward to hearing any more ideas, thanks again for your time in reading this, Jenny Barnes Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } I don't know if it is faster - but adding three columns to qpcc.data, one for longitude, one for lattitude and one for year (using rep() as they are in sequence) and the using reshape() might be faster? So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)86 516 2782 Fax: +27 - (0)21 808 3304 (w) Cell:+27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] upside down image/data
Thomas, Thank you for this example, makes it easier to see what levelplot does - does this mean that EVERY time I want to plot with levelplot() I have to not only reverse the columns [,ncol(output.temp):1] but also have to transform the matrix as below? I am only suprised as I don't remember having read about this in the R-info in ?levelplot or R-help website and it seems like a fundamental thing to know if using levelplot! Thanks, Jenny rm(list=ls(all=TRUE)) graphics.off() # make a test matrix: nr- 3 nc- 4 # the data: ( m- matrix((1:(nr*nc)), nr, nc) ) [,1] [,2] [,3] [,4] [1,]147 10 [2,]258 11 [3,]369 12 # the way that levelplot (and image) displays the data: t(m)[dim(t(m))[1]:1, ] [,1] [,2] [,3] [1,] 10 11 12 [2,]789 [3,]456 [4,]123 # undo what levelplot does by performing the inverse transformation inverse- function(x) t(x[dim(x)[1]:1, ]) windows(); levelplot(m, main=levelplot(m)) windows(); levelplot(inverse(m), main=levelplot(inverse(m))) Message: 7 Date: Mon, 11 Dec 2006 12:28:17 + (GMT) From: Jenny Barnes [EMAIL PROTECTED] Subject: [R] upside down image/data To: r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: TEXT/plain; charset=us-ascii Dear R-community, I am looking for some simple advice - I have a matrix (therefore 2 dimensional) of global temperature. Having read R-help I think that when I ask R to image() or levelplot() my matrix will it actually appear upside down - I think I therefore need to use the line: levelplot(temperature.matrix[,ncol(output.temp):1], ) to get it looking like it was on the globe due to the matrix rows increasing in number down the matrix in its dimensions on longitude and latitude but the y-axis coordinates increase up the axis. Can anyone simply tell me whether this is correct as I find it very hard to know which way up my data should be and I cannot tell which is correct simply by looking at it! Many thanks for your time in reading this problem, Jenny Barnes Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] upside down image/data
Thanks Thomas, My data arrays each contain 0.5million data points so I couldn't really reproduce them unfortunately. Next time I will try and offer some exapmle code simplified with comments in order to help you and the others on R-help understand my problem more easily. I appreciate your help and advise and I know it will be very usefull in learning about handling these huge datasets more accurately. Jenny the transform that i provided orientates the data matrix so that when plotted with image or levelplot the result is isomorphic to what you see when you print the matrix at the r prompt. i don't know what your data look like---commented, minimal, self-contained, reproducible code would help---but you should be able to work out exactly what way you want your data to appear by playing with the example code. i would advise you to produce a data matrix the way you want to see it on the screen, just like the matrix m in the example code, and then view the output with levelplot(inverse(m)), in which case, the answer to your question is you only need to transform the data with inverse() once you get your data matrix to look the way you want at the r prompt. --- Jenny Barnes [EMAIL PROTECTED] wrote: Thomas, Thank you for this example, makes it easier to see what levelplot does - does this mean that EVERY time I want to plot with levelplot() I have to not only reverse the columns [,ncol(output.temp):1] but also have to transform the matrix as below? I am only suprised as I don't remember having read about this in the R-info in ?levelplot or R-help website and it seems like a fundamental thing to know if using levelplot! Thanks, Jenny rm(list=ls(all=TRUE)) graphics.off() # make a test matrix: nr- 3 nc- 4 # the data: ( m- matrix((1:(nr*nc)), nr, nc) ) [,1] [,2] [,3] [,4] [1,]147 10 [2,]258 11 [3,]369 12 # the way that levelplot (and image) displays the data: t(m)[dim(t(m))[1]:1, ] [,1] [,2] [,3] [1,] 10 11 12 [2,]789 [3,]456 [4,]123 # undo what levelplot does by performing the inverse transformation inverse- function(x) t(x[dim(x)[1]:1, ]) windows(); levelplot(m, main=levelplot(m)) windows(); levelplot(inverse(m), main=levelplot(inverse(m))) Message: 7 Date: Mon, 11 Dec 2006 12:28:17 + (GMT) From: Jenny Barnes [EMAIL PROTECTED] Subject: [R] upside down image/data To: r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: TEXT/plain; charset=us-ascii Dear R-community, I am looking for some simple advice - I have a matrix (therefore 2 dimensional) of global temperature. Having read R-help I think that when I ask R to image() or levelplot() my matrix will it actually appear upside down - I think I therefore need to use the line: levelplot(temperature.matrix[,ncol(output.temp):1], ) to get it looking like it was on the globe due to the matrix rows increasing in number down the matrix in its dimensions on longitude and latitude but the y-axis coordinates increase up the axis. Can anyone simply tell me whether this is correct as I find it very hard to know which way up my data should be and I cannot tell which is correct simply by looking at it! Many thanks for your time in reading this problem, Jenny Barnes Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] how do you interpolate a gaussian grid to a standard 2.5 degree grid?
Dear R-help community, I have looked on the R search site and archives but cannot find mention of a way of interpolating a gaussian distribution of data to a standard 2.5 degree grid. I have two global dataset and I need to correlate - unfortunately one is a 2.5 degree grid dim[longitude=144,latitude=72] and one is gaussian dim[longitude=192,latitude=94]. I would rally appreciate hearing back from any of you who may have wanted to interpolate your data is this way. If there is no ready-made function you know of but you are willing to share your own methods I would also appreciate any pointers. Many thanks for your time, Jenny Barnes Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how do you interpolate a gaussian grid to a standard 2.5 degreegrid?
Thanks Roger, I shall have a further look at expand.grid() and the fields package and see what I can do! Jenny Jenny: If you have two matrices, and know the grid values of the x and y sequences, you can use expand.grid() and some trial and error to make a data frame with longitude, latitude, and value. From there, I think Krig (or Tps) in the fields package will help, with the Distance= argument set to rdist.earth. The next release of the gstat package is also going to support Great Circle distances, but the fields package is written by scientists close to your interests, and is already available. You do need to know the latitude spacings, though. --- Roger Bivand, NHH, Helleveien 30, N-5045 Bergen, [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] on behalf of Jenny Barnes Sent: Tue 12.12.2006 11:12 To: r-help@stat.math.ethz.ch Subject: [R] how do you interpolate a gaussian grid to a standard 2.5 degreegrid? Dear R-help community, I have looked on the R search site and archives but cannot find mention of a way of interpolating a gaussian distribution of data to a standard 2.5 degree grid. I have two global dataset and I need to correlate - unfortunately one is a 2.5 degree grid dim[longitude=144,latitude=72] and one is gaussian dim[longitude=192,latitude=94]. I would rally appreciate hearing back from any of you who may have wanted to interpolate your data is this way. If there is no ready-made function you know of but you are willing to share your own methods I would also appreciate any pointers. Many thanks for your time, Jenny Barnes Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] how do you interpolate a gaussian grid to a standard 2.5 degree grid?
Zhuanshi Thanks for that! I've never seen that website before and it looks really useful! I think those functions look a lot more straight forward than any of the others I've seen today in my searching. I'll let you know if I get it sorted! Jenny Hi Jenny, Maybe the following links will be useful for you. Both of thoes are used in meteorological and climate research community. But u can used the codes to create the data values that you need. g2fsh : Interpolates a scalar quantity from a Gaussian grid to a fixed grid. http://www.ncl.ucar.edu/Document/Functions/Built-in/g2fsh.shtml g2fshv : Interpolates a vector quantity from a Gaussian grid to a fixed grid. http://www.ncl.ucar.edu/Document/Functions/Built-in/g2fshv.shtml In addition, both of those functions based on a package named SPHEREPACK (http://www.cisl.ucar.edu/css/software/spherepack/ ). you can write call subroutines shipped from SPHEREPACK to get values at your fixed grids. Good luck. Zhuanshi He On 12/12/06, Jenny Barnes [EMAIL PROTECTED] wrote: Dear R-help community, I have looked on the R search site and archives but cannot find mention of a way of interpolating a gaussian distribution of data to a standard 2.5 degree grid. I have two global dataset and I need to correlate - unfortunately one is a 2.5 degree grid dim[longitude=144,latitude=72] and one is gaussian dim[longitude=192,latitude=94]. I would rally appreciate hearing back from any of you who may have wanted to interpolate your data is this way. If there is no ready-made function you know of but you are willing to share your own methods I would also appreciate any pointers. Many thanks for your time, Jenny Barnes Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Zhuanshi He / Z. He (PhD) Waterloo Centre for Atmospheric Sciences (WCAS) Department of Chemistry Phy Bldg, Rm 2022 University of Waterloo, Waterloo, ON N2L 3G1 Canada Tel: +1-519-888-4567 ext 38053FAX: +1-519-746-0435 Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] upside down image/data
Dear R-community, I am looking for some simple advice - I have a matrix (therefore 2 dimensional) of global temperature. Having read R-help I think that when I ask R to image() or levelplot() my matrix will it actually appear upside down - I think I therefore need to use the line: levelplot(temperature.matrix[,ncol(output.temp):1], ) to get it looking like it was on the globe due to the matrix rows increasing in number down the matrix in its dimensions on longitude and latitude but the y-axis coordinates increase up the axis. Can anyone simply tell me whether this is correct as I find it very hard to know which way up my data should be and I cannot tell which is correct simply by looking at it! Many thanks for your time in reading this problem, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] reaccessing array at a later date - trying to write it to file
Dear R-help community I am trying to write an R object (data.out) to a file in order to re-access it later and not have to re-load up the array with data every time. Here is the form of data.out data.out - list(lats=seq(88.542, -88.542, length=94), lons=seq(0, 360-1.875, length=192), date=vector(length=nyr*12), data=array(NA, c(nyr*12, 94*192)) ) I tried save(data.out, file=/home/jenny/data/data.out.RData, ascii=TRUE) and combination of ways to re-access it but I couldn't reaccess it and therefore use the data within. I then tried dput(data.out,file=/home/jmb/sst_precip/gribdata/data.out.RData, control=showAttributes) #but the associated dget seemed to freeze my terminal window up and took much too long (I gave up after about 15 minutes) to read this file. Does anybody have an idea about another way (or a way within these methods) to come back to my data within the list data.out (with all of its associated data.out$lats, data.out$lons, data.out$date, data.out$data) at a later stage to use the data within it to actually get on with some analysis? I appreciate your time in reading this and look forward to hearing any suggestions, Sincerely, Jenny Barnes Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] reaccessing array at a later date - trying to write it to file
Thank you for your response Professor Ripley, Having tried again your suggestion of load() worked (well - it finished, which I assume it meant it worked). However not I am confused as to how I can check it has worked. I typed data.out$data which called up the data from the file - but I'm not sure if this is data from the file I have just restored as in my previously saved workspace restored data.out is still there so if I typed data.out$data I wouldn't know if it was coming from the newly loaded file or from previously. Is there an alternative way to check it has loaded properly? Also, is it normal that if I type data.out.RData it says Error: object data.out.RData not found Here are my details: platform sparc-sun-solaris2.10 arch sparc os solaris2.10 system sparc, solaris2.10 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) My computer shouldn't have a problem with dealing with this data. On Thu, 23 Nov 2006, Jenny Barnes wrote: Dear R-help community I am trying to write an R object (data.out) to a file in order to re-access it later and not have to re-load up the array with data every time. Here is the form of data.out data.out - list(lats=seq(88.542, -88.542, length=94), lons=seq(0, 360-1.875, length=192), date=vector(length=nyr*12), data=array(NA, c(nyr*12, 94*192)) ) I tried save(data.out, file=/home/jenny/data/data.out.RData, ascii=TRUE) and combination of ways to re-access it but I couldn't reaccess it and therefore use the data within. What stopped you re-accessing it? I would use save(data.out, file=/home/jenny/data/data.out.RData) load(/home/jenny/data/data.out.RData) If that does not work, we need to see the transcript to (perhaps) understand why (and all the usual details about your environment: it is possible to save really large objects that you cannot restore on a 32-bit machine). -- 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 Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] reaccessing array at a later date - trying to write it to file
Thank you Barry for your time in responding! I think that will really help - the difference between attach and load were not clear to me before your reply! Also I did not know about rm() - thank you for the detail, I know you took longer than you had planned but I do appreciate it, For those with a similar problems in the future please see the responses below: Jenny Barnes wrote: Having tried again your suggestion of load() worked (well - it finished, which I assume it meant it worked). However not I am confused as to how I can check it has worked. I typed data.out$data which called up the data from the file - but I'm not sure if this is data from the file I have just restored as in my previously saved workspace restored Remove it from your current workspace: rm(data.out) then do the load('whatever') again: load(/some/path/to/data.out.RData) then see if its magically re-appeared in your workspace: data.out$data But now if you quit and save your workspace it'll be in your workspace again when you start up. So you could consider 'attach' instead of 'load'... Remove data.out from your current workspace, save your current workspace (with 'save()' - just like that with nothing in the parentheses), then instead of load('/some/path/to/data.out.RData') use: attach('/some/path/to/data.out.RData') This makes R search for an object called 'data.out' in that file whenever you type 'data.out'. It will find it as long as there's not a thing called 'data.out' in your workspace. So if you do attach(...) and then do: str(data.out) you'll see info about your data.out object, but then do: data.out=99 str(data.out) you'll see info about '99'. Your data.out is still happily sitting in its .RData file, its just masked by the data.out we created and set to 99. Delete that, and your data.out comes back: rm(data.out) str(data.out) # - your data object again The advantage of this is that data.out wont be stored in your current workspace again. The disadvantage is that you have to do 'attach(...whatever...)' when you start R, and that data.out can be masked if you create something with that name in your workspace. It is a handy thing to do if you create large data objects that aren't going to change much. Also, is it normal that if I type data.out.RData it says Error: object data.out.RData not found Yes, because thats the name of the _file_ on your computer and not the R object. This should be in the R manuals and help files... and I've gone on much longer than I intended to in this email :) Barry Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.