Re: [R] Arguments of a function
You need to change your second line: range - c(0.1, 0.5) runif(1, range[1], range[2]) -- View this message in context: http://r.789695.n4.nabble.com/Arguments-of-a-function-tp3387643p3388400.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to label lines
Here is a working example that allows you to interactively label curves where you want: x - c(200,210,230) y1 - c(0.1, 0.13, 0.1) y2 - c(0.11, 0.15,0.1) y3 - c(0.12,0.17,0.12) df - data.frame(x, y1,y2,y3) lab - c(0.1 mg/l,0.2 mg/l,0.3 mg/l) plot(df$x, df$y1, type=l, col=blue, xlab=, ylim=c(0,.25)) points(df$x, df$y2, type=l, col=grey) points(df$x, df$y3, type=l, col=green) text(locator(3), lab, adj=0) -- View this message in context: http://r.789695.n4.nabble.com/how-to-label-lines-tp3350452p3351195.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calculate a mean for several months for several years
Yes John My editing mistake. Thanks!! -- View this message in context: http://r.789695.n4.nabble.com/Calculate-a-mean-for-several-months-for-several-years-tp3318363p3319272.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calculate a mean for several months for several years
Pete The original question I would like to calculate the average of the mean temperature for the summer months (Juli, August, September) for each of the 20 years Your codes gives mean for each of the 3 months, not for the 20 summers. Here is a way to get the summer average for each of the 20 years: set.seed = 1 d=data.frame(year=rep(1980:1999,each=12), month=rep(1:12,20), meanTemp = rnorm(240,10,5)) sum_d - subset(d, d[,2]=7 temp_df[,2] =9) aggregate(meanTemp ~ year, data = sum_d, mean) -- View this message in context: http://r.789695.n4.nabble.com/Calculate-a-mean-for-several-months-for-several-years-tp3318363p3318567.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] User input in R program
Christian Have you looked at the http://www.stats.gla.ac.uk/~adrian/rpanel/ rpanel package? I have a post which shows an example of interactive input that allows user to adjust plot parameters. http://chartsgraphs.wordpress.com/2009/05/08/rpanel-package-adds-interactive-capabilites-to-r/ link -- View this message in context: http://r.789695.n4.nabble.com/User-input-in-R-program-tp3229515p3229738.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Unexpected Gap in simple line plot
I am getting an unexpected gap in a simple plot of monthly data series. I have created a csv file of monthly climate observations that I store on-line. When I download the csv file and plot one of the series, I get a gap even though there is data for the missing point. Here is a snippet to show the problem. ## Strange plot results link - http://processtrends.com/files/RClimate_CTS_latest.csv; cts - read.csv(link, header=T) ## Simple line plot - gap for no reason plot(cts$yr_frac, cts$GISS, type=l, xlim=c(1982, 1983),xaxs=i, yaxs=i) ## May, 1982 observation missing ## Add points to plot in red, to see if May shows up points(cts$yr_frac, cts$GISS, type=p, col=red) ## yes, May shows up in points ## Look at cts data.frame. No obvious problems to me?? small - subset(cts, cts$yr_frac 1982 cts$yr_frac 1983) small[,c(1,3)] The same problem occurs in the other data vectors (HAD, NOAA, RSS, UAH, etc) I have not been able to figure why I am getting the gap and how to show a continuous line through May, 1982 data points. Any suggestions? D Kelly O'Day http://chartsgraphs.worpress.com http://chartsgraphs.wordprss.com -- View this message in context: http://r.789695.n4.nabble.com/Unexpected-Gap-in-simple-line-plot-tp3228853p3228853.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unexpected Gap in simple line plot
Bill Duncan Thanks for your quick reply. I would still be looking for days. Now I have to figure out how the bad data got into cts since I generate this file each month. -- View this message in context: http://r.789695.n4.nabble.com/Unexpected-Gap-in-simple-line-plot-tp3228853p3228920.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem downloading and opening netcdf file
I am trying to download and open an on-line netcdf file. I'm using Windows XP and R 2.11.1 Here's my script library(ncdf) link - http://ibis.grdl.noaa.gov/SAT/SeaLevelRise/slr/slr_sla_gbl_free_all_66.nc; dest - C:/temp/slr_sla_gbl_free_all_66.nc download.file(url=link,destfile=dest) nc1 - open.ncdf(dest) The file appears in my C:/temp directory, however I can not open() it, I get this error message: nc1 - open.ncdf(dest) Error in open.ncdf(dest) : Error in open.ncdf trying to open file C:/temp/slr_sla_gbl_free_all_66.nc I can manually download and save the netcdf file and then open it. I'd like to be able to automate the download and open process within my script. Any suggestions? -- View this message in context: http://r.789695.n4.nabble.com/Problem-downloading-and-opening-netcdf-file-tp3046897p3046897.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem downloading and opening netcdf file
Barry Prof Ripley: Thanks!! mode=wb solve the problem. BTW, it's he. D Kelly O'Day -- View this message in context: http://r.789695.n4.nabble.com/Problem-downloading-and-opening-netcdf-file-tp3046897p3047002.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plots inside a Plot
Here's a quick example I posted on my blog. http://chartsgraphs.wordpress.com/2009/05/06/r-lets-you-put-chart-inside-chart/ link Hope it helps. http://r.789695.n4.nabble.com/file/n3022363/chart_inside_chart.png -- View this message in context: http://r.789695.n4.nabble.com/Plots-inside-a-Plot-tp3021988p3022363.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plots inside a Plot
here's a second example using basic R graphics. I update this chart daily. http://processtrends.com/images/RClimate_UAH_Ch5_latest.png link http://r.789695.n4.nabble.com/file/n3022678/RClimate_UAH_Ch5_latest.png Here's what ?par says about par(fig) fig A numerical vector of the form c(x1, x2, y1, y2) which gives the (NDC) coordinates of the figure region in the display region of the device. If you set this, unlike S, you start a new plot, so to add to an existing plot use new=TRUE as well. -- View this message in context: http://r.789695.n4.nabble.com/Plots-inside-a-Plot-tp3021988p3022678.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: highlighting R code on WordPress.com blogs
Tali I am one of your estimated 29 Wordpress bloggers. Thanks for your RBloggers site!! I use Wordpress.com's site for my blog. I use a simple method to highlight my R script in Wordpress, example http://chartsgraphs.wordpress.com/2010/07/17/time-series-regression-of-temperature-anomaly-data-1-%E2%80%93-don%E2%80%99t-use-ols/#more-3390 here . I use pre Rscript /pre to set up my R script blocks. I purchased Wordpress' CSS service and customized the pre /pre tags to add a text box and pale yellow color scheme. I use SnagIt to make images of the console results. -- View this message in context: http://r.789695.n4.nabble.com/Help-request-highlighting-R-code-on-WordPress-com-blogs-tp2532433p2533842.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Axes=F and plotting dual y axes
Cedrick I used this script to produce a simple chart with no axes: series2 = c(1:50) series1 = rep(25:74) plot(series1, series2, main=Woo, col=red, xlab=, ylab=, axes=F, type=l) Works fine on Windows XP using R 2.11.1. -- View this message in context: http://r.789695.n4.nabble.com/Axes-F-and-plotting-dual-y-axes-tp2305230p2305290.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R cannot access the web?
I was also able to download the NYTimes page, using R2.10.1 on Windows XP. -- View this message in context: http://r.789695.n4.nabble.com/R-cannot-access-the-web-tp2215881p2216005.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R and Wordpress
I use Wordpress.com (free public version) and add my R scripts by using simple html pre ... / wrap around my script. Here's an example post with R Script. http://chartsgraphs.wordpress.com/2009/02/05/r-script-to-automatically-chart-web-based-global-temperature-data/ link D Kelly O'Day http://chartsgraphs.wordpress.com -- View this message in context: http://n4.nabble.com/R-and-Wordpress-tp1568499p1570653.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] iterative regressions, adding a new line of data each time
I used rpanel() to do an interactive regression of a time series. My use was not as involved as yours, but it might give you an idea of how to approach. Here's a http://chartsgraphs.wordpress.com/2009/05/08/rpanel-package-adds-interactive-capabilites-to-r/ link to my blog post. -- View this message in context: http://n4.nabble.com/iterative-regressions-adding-a-new-line-of-data-each-time-tp1457725p1459360.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot type any symbols?
Trafim Use the pch= argument within plot(). Try ?points to get details. Trafim wrote: Dear all, I have a question is there a possibility to plot points with different symbols like stars, crosses? I looked at different types for plot command and didn't find anything like that. Thanks a lot. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://n4.nabble.com/plot-type-any-symbols-tp1013838p1013849.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Working with source file
I am trying to build an easy to use climate data analysis tool kit that will let non-R users run my detailed r script with minimum R learning curve effort. Here's an example: link - http://chartsgraphs.wordpress.com/files/2010/01/nsidc_trend_plot_2.doc; source(link) This lets user run my R script stored at site 1 and work with data stored at site 2 without having to worry about links, R script details or downloading anything. They get the plot. What if they'd like to see R script or see contents of data frames, or change the plot parameters? My questions: 1. how can user get list of just data.frames to investigate the data? 2. how can user list my R script in the session so that he/she can adjust it? My R scripts retrieve raw data, process it and organize it for analysis. I'd like the users to be able to save the data, subset, modify data and make their own plots. I can't seem to find out any information on how to look at sourced R scripts. Suggestions on where to look will be appreciated. D Kelly O'Day http:chartsgraphs.wordpress.com -- View this message in context: http://n4.nabble.com/Working-with-source-file-tp1008337p1008337.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using zoo() to aggregate daily data to monthly means
I am trying to get monthly means for a daily data series using zoo(). I have found an odd problem, that seems to be caused by zoo()'s handling of leap years. Here's my R script with 2 methods (freq=365, 366) for aggregating the daily data to monthly series: library(zoo) J_link - http://www.ijis.iarc.uaf.edu/seaice/extent/plot.csv; JAXA_data - read.table(J_link, skip = 0, sep = ,, dec=., row.names = NULL, header = FALSE, as.is = T, colClasses = rep(numeric,4), comment.char = #, na.strings = c(*, -,-99.9, -), col.names = c(Mo, Day, Yr, Extent) ) ## Subset raw data to period: Jan,2003 to Dec, 2007 JAXA - subset(JAXA_data, JAXA_data$Yr =2003 JAXA_data$Yr =2007) ## create zoo object starting Jan, 2003 - use freq's of 365 and 366 JAXA_365 - as.zoo(ts(JAXA$Extent, start = c(2003,1,1),freq=365)) JAXA_366 - as.zoo(ts(JAXA$Extent, start = c(2003,1,1),freq=366)) ## aggregate to yearmon using JAXA_365 JAXA_366 zoo objects JAXA_mo_365 - aggregate(JAXA_365, mean, by=yearmon, na.rm=T) JAXA_mo_366 - aggregate(JAXA_366, mean, by=yearmon, na.rm=T) ## Compare last 6 records for JAXA_365 JAXA_366 tail(JAXA_mo_365) tail(JAXA_mo_366) When I compare the two tail reports, I get Jan, 2007 for last month for JAXA_365 and Dec, 2007 for JAXA_366. What is proper freq for daily data, 365 or 366 or other? I have seen many examples that use 365 for ts, I assumed zoo() worked the same. What am I missing? -- View this message in context: http://n4.nabble.com/Using-zoo-to-aggregate-daily-data-to-monthly-means-tp977263p977263.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using zoo() to aggregate daily data to monthly means
Z Thanks. I new I was missing something! Kelly Achim Zeileis wrote: On Tue, 22 Dec 2009, D Kelly O'Day wrote: I am trying to get monthly means for a daily data series using zoo(). I have found an odd problem, that seems to be caused by zoo()'s handling of leap years. It's not really zoo's odd handling, but yours ;-) More seriously, do not use ts() with either freq = 365 or 366 to represent daily observations. zoo with Date index is more suitable (or the corresponding xts). Here's my R script with 2 methods (freq=365, 366) for aggregating the daily data to monthly series: library(zoo) J_link - http://www.ijis.iarc.uaf.edu/seaice/extent/plot.csv; JAXA_data - read.table(J_link, skip = 0, sep = ,, dec=., row.names = NULL, header = FALSE, as.is = T, colClasses = rep(numeric,4), comment.char = #, na.strings = c(*, -,-99.9, -), col.names = c(Mo, Day, Yr, Extent) ) ## Subset raw data to period: Jan,2003 to Dec, 2007 JAXA - subset(JAXA_data, JAXA_data$Yr =2003 JAXA_data$Yr =2007) ## create zoo object starting Jan, 2003 - use freq's of 365 and 366 JAXA_365 - as.zoo(ts(JAXA$Extent, start = c(2003,1,1),freq=365)) JAXA_366 - as.zoo(ts(JAXA$Extent, start = c(2003,1,1),freq=366)) As explained above, I would use a Date index: JAXA_daily - with(JAXA_data, zoo(Extent, as.Date(paste(Yr, Mo, Day, sep = -))) ) and then you can do JAXA_monthly - aggregate(JAXA_daily, as.yearmon, mean, na.rm = TRUE) which should give what you expected. See zoo's package vignettes vignette(package = zoo) for more details. hth, Z ## aggregate to yearmon using JAXA_365 JAXA_366 zoo objects JAXA_mo_365 - aggregate(JAXA_365, mean, by=yearmon, na.rm=T) JAXA_mo_366 - aggregate(JAXA_366, mean, by=yearmon, na.rm=T) ## Compare last 6 records for JAXA_365 JAXA_366 tail(JAXA_mo_365) tail(JAXA_mo_366) When I compare the two tail reports, I get Jan, 2007 for last month for JAXA_365 and Dec, 2007 for JAXA_366. What is proper freq for daily data, 365 or 366 or other? I have seen many examples that use 365 for ts, I assumed zoo() worked the same. What am I missing? -- View this message in context: http://n4.nabble.com/Using-zoo-to-aggregate-daily-data-to-monthly-means-tp977263p977263.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://n4.nabble.com/Using-zoo-to-aggregate-daily-data-to-monthly-means-tp977263p977289.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Are there free R webinar recordings somewhere ?
Tal I have a series of basic introduction tutorials for new R users at this link. http://processtrends.com/Learn_R_Toolkit.htm http://processtrends.com/Learn_R_Toolkit.htm These videos are geared to Excel users who want to learn about R and see it in action. D Kelly O'Day http://procestrends.com http://chartsgraphs.wordpress.com Tal Galili wrote: Hi all, A friend just sent me this: http://www.mathworks.com/company/events/webinars/index.html?id=language=en http://www.mathworks.com/company/events/webinars/index.html?id=language=enAnd asked me if there is something of the like in the R community. Does anyone know of such a think ? Cheers, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com/ (English) -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://n4.nabble.com/Are-there-free-R-webinar-recordings-somewhere-tp954706p954772.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.