[R] confused with yearmon, xts and maybe zoo
R-listers, I am using xts with a yearmon index, but am getting some inconsistent results with the date index when i drop observations (for example by using na.omit). The issue is illustrated in the example below. If I start with a monthly zooreg series starting in 2009, yearmon converts this to Dec-2008. Not such a worry for my example, but strange. Having converted to xts, i drop the first observation. The index shows jan 2009. But if i create a new variable with this index, it shifts the series back to dec 2008. No doubt i am doing something wrong. very grateful for any tips library(xts) z - zooreg(1:24,frequency=12,start=c(2009,1)) # monthly data starting 2009 x - xts(z,as.yearmon(index(z)))# starts Dec 2008 xx - x[-1, ] # drop first obs (eg through na.omit) index(xx) # starts jan 2009 xxx - xts(NA[1:length(xx)],index(xx))# back to dec 2008 periodicity(x) periodicity(xx) periodicty(xxx) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] confused with yearmon, xts and maybe zoo
Hi Gabor Thats odd. I still get the same problem with the same versions of the software in your mail ... viz as.yearmon converts 2009(1) to Dec-2008 and although xts is indexed at Jan 2009 in xx, using it to create another xts object with that index reverts to Dec-2008. grateful for any suggestions ## code ## library(xts) z - zooreg(1:24,frequency=12,start=c(2009,1)) x - xts(z,as.yearmon(index(z))) xx - x[-1, ] index(xx) xxx - xts(NA[1:length(xx)],index(xx)) periodicity(x) periodicity(xx) periodicty(xxx)b ## results ### periodicity(x) Monthly periodicity from Dec 2008 to Nov 2010 periodicity(xx) Monthly periodicity from Jan 2009 to Nov 2010 periodicity(xxx) Monthly periodicity from Dec 2008 to Oct 2010 R.version.string [1] R version 2.10.1 (2009-12-14) win.version() [1] Windows XP (build 2600) Service Pack 3 packageDescription(xts)$Version [1] 0.7-0 Sys.time() [1] 2010-04-18 19:37:26 BST On Sun, Apr 18, 2010 at 1:25 PM, simeon duckworth simeonduckwo...@gmail.com wrote: R-listers, I am using xts with a yearmon index, but am getting some inconsistent results with the date index when i drop observations (for example by using na.omit). The issue is illustrated in the example below. If I start with a monthly zooreg series starting in 2009, yearmon converts this to Dec-2008. Not such a worry for my example, but strange. Having converted to xts, i drop the first observation. The index shows jan 2009. But if i create a new variable with this index, it shifts the series back to dec 2008. No doubt i am doing something wrong. very grateful for any tips library(xts) z - zooreg(1:24,frequency=12,start=c(2009,1)) # monthly data starting 2009 x - xts(z,as.yearmon(index(z)))# starts Dec 2008 xx - x[-1, ] # drop first obs (eg through na.omit) index(xx) # starts jan 2009 xxx - xts(NA[1:length(xx)],index(xx))# back to dec 2008 periodicity(x) periodicity(xx) periodicty(xxx) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] confused with yearmon, xts and maybe zoo
... forgot to post this back to the r-list. it seems that the problem is with xts rather than zoo and yearmon per se ie using yearmon to index xts gives inconsistent results. grateful for any help anyone can offer. thanks On Sun, Apr 18, 2010 at 8:15 PM, simeon duckworth simeonduckwo...@gmail.com wrote: Hi gabor It seems asthough the issue is in working with yearmon in xts. the command as.yearmon(index(z)) works in the same way as yours, but not when used to index the xts object. ## code library(xts) z - zooreg(1:24,frequency=12,start=c(2009,1)) x - xts(z,as.yearmon(index(z))) xx - x[-1, ] index(xx) xxx - xts(NA[1:length(xx)],index(xx)) index(z) as.yearmon(index(z)) head(x,3) head(xx,3) head(xxx,3) ## output index(z) [1] 2009.000 2009.083 2009.167 2009.250 2009.333 2009.417 2009.500 2009.583 [9] 2009.667 2009.750 2009.833 2009.917 2010.000 2010.083 2010.167 2010.250 [17] 2010.333 2010.417 2010.500 2010.583 2010.667 2010.750 2010.833 2010.917 as.yearmon(index(z)) [1] Jan 2009 Feb 2009 Mar 2009 Apr 2009 May 2009 Jun 2009 [7] Jul 2009 Aug 2009 Sep 2009 Oct 2009 Nov 2009 Dec 2009 [13] Jan 2010 Feb 2010 Mar 2010 Apr 2010 May 2010 Jun 2010 [19] Jul 2010 Aug 2010 Sep 2010 Oct 2010 Nov 2010 Dec 2010 head(x,3) x Dec 2008 1 Jan 2009 2 Feb 2009 3 head(xx,3) x Jan 2009 2 Feb 2009 3 Mar 2009 4 head(xxx,3) [,1] Dec 2008 NA Jan 2009 NA Feb 2009 NA On Sun, Apr 18, 2010 at 8:00 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Apr 18, 2010 at 2:51 PM, simeon duckworth simeonduckwo...@gmail.com wrote: Hi Gabor Thats odd. I still get the same problem with the same versions of the software in your mail ... viz as.yearmon converts 2009(1) to Dec-2008 We can`t conclude that its in as.yearmon based on the output shown. What is the output of: index(z) as.yearmon(index(z)) x This is what I get: index(z) [1] 2009.000 2009.083 2009.167 2009.250 2009.333 2009.417 2009.500 2009.583 [9] 2009.667 2009.750 2009.833 2009.917 2010.000 2010.083 2010.167 2010.250 [17] 2010.333 2010.417 2010.500 2010.583 2010.667 2010.750 2010.833 2010.917 as.yearmon(index(z)) [1] Jan 2009 Feb 2009 Mar 2009 Apr 2009 May 2009 Jun 2009 [7] Jul 2009 Aug 2009 Sep 2009 Oct 2009 Nov 2009 Dec 2009 [13] Jan 2010 Feb 2010 Mar 2010 Apr 2010 May 2010 Jun 2010 [19] Jul 2010 Aug 2010 Sep 2010 Oct 2010 Nov 2010 Dec 2010 head(x) x Jan 2009 1 Feb 2009 2 Mar 2009 3 Apr 2009 4 May 2009 5 Jun 2009 6 and although xts is indexed at Jan 2009 in xx, using it to create another xts object with that index reverts to Dec-2008. grateful for any suggestions ## code ## library(xts) z - zooreg(1:24,frequency=12,start=c(2009,1)) x - xts(z,as.yearmon(index(z))) xx - x[-1, ] index(xx) xxx - xts(NA[1:length(xx)],index(xx)) periodicity(x) periodicity(xx) periodicty(xxx)b ## results ### periodicity(x) Monthly periodicity from Dec 2008 to Nov 2010 periodicity(xx) Monthly periodicity from Jan 2009 to Nov 2010 periodicity(xxx) Monthly periodicity from Dec 2008 to Oct 2010 R.version.string [1] R version 2.10.1 (2009-12-14) win.version() [1] Windows XP (build 2600) Service Pack 3 packageDescription(xts)$Version [1] 0.7-0 Sys.time() [1] 2010-04-18 19:37:26 BST On Sun, Apr 18, 2010 at 1:25 PM, simeon duckworth simeonduckwo...@gmail.com wrote: R-listers, I am using xts with a yearmon index, but am getting some inconsistent results with the date index when i drop observations (for example by using na.omit). The issue is illustrated in the example below. If I start with a monthly zooreg series starting in 2009, yearmon converts this to Dec-2008. Not such a worry for my example, but strange. Having converted to xts, i drop the first observation. The index shows jan 2009. But if i create a new variable with this index, it shifts the series back to dec 2008. No doubt i am doing something wrong. very grateful for any tips library(xts) z - zooreg(1:24,frequency=12,start=c(2009,1)) # monthly data starting 2009 x - xts(z,as.yearmon(index(z)))# starts Dec 2008 xx - x[-1, ] # drop first obs (eg through na.omit) index(xx) # starts jan 2009 xxx - xts(NA[1:length(xx)],index(xx))# back to dec 2008 periodicity(x) periodicity(xx) periodicty(xxx) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted
[R] chron, xts and zoo
dear r folks i am a bit puzzled about how to use chron as an index xts and why it differs from zoo. in this example, why can i index zoo but not xts x-1:23 time.of.day - times(paste(x,:0:0,sep=),format=h:m:s) day - dates(4/8/90) period - chron(dates=day,times=time.of.day) xts(1:23,period) zoo(1:23,period) i suspect it might be to do with chron, but i cant see why. it seems to behave normally in the way i am trying to use it. grateful for any help simeon [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plyr and memory allocation issue
Dear R users I am trying to create some new variables for a 4401 x 30 dataframe using ddply and transform. The id variable i am using is a factor with 1330 levles eg bb - function(df) {transform(df, years = study.year - min(study.year) + 1, periods = length(study.year) )} test - ddply(x,.(id),bb) I havent copied the data to avoid clogging the list. The problem is that I get an error cannot allocate vector of size 128.0 Mb. I wouldnt have thought any of these were particularly large files. Is there a limit on how many splits ddply can handle (ie 1330 here)? Or - more likely - am i doing something dumb? grateful for any help best simeon I am using XP with 3G of RAM, R2.9.1 and most recent ggplot2 memory.size() [1] 883.49 memory.limit() [1] 2047 object.size(x) # size of dataframe 1410136 bytes gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 218229 5.9 11384284 304.0 15229393406.7 Vcells 4404372 33.7 77750774 593.2 214556462 1637.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read name multiple excel sheets using RODBC
I'd like to be able to read multiple sheets from an excel workbook and use the sheet name to name the resulting dataframe using RODBC. at the moment i've figured out how to do it the long way (see below) but feel sure that there is a speedier possibly automatic way to do it in R. i've tried to run a loop using sqlTables but it seemed to break the connection. unless i've missed something, i cant see a solution to this on the help list. grateful for any help or pointers simeon # long way library(RODBC) filepath - C:/Data/workbook.xlsx connect - odbcConnectExcel2007(filepath) tbls - sqlTables(connect) sheet1 -sqlFetch(channel=connect,sqtable='sheet1') sheet2 -sqlFetch(channel=connect,sqtable='sheet2') sheet3 -sqlFetch(channel=connect,sqtable='sheet3') .. etc close(connect) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] text matching and substitution
I am trying to simplify a text variable by matching and replacing it with a string in another vector so for example in colours - paste(letters,colours(),stuff,LETTERS) find and replace with (red,blue,green,gray,yellow,other) - irrespective of case its a large dataset, so i'd like to be able to do this as efficiently as possible. thanks for any help [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] text matching and substitution
thanks stephan. i'd been trying to make gsub work, but couldnt make it replace the whole expression. so i'd resorted to trying to loop with grep - but with two problems. firstly, i cant seem to make the loop 'remember' the substitutions it makes (see below). secondly, it feels like this is a really inefficient way of doing something quite simple anyhow. colours - as.character(paste(letters,colours(),stuff,LETTERS)) target - c(red,blue,green,gray) new.colour -colours for (i in length(target)) { x - target[i] new.colour[grep((x),new.colour)] - x return(new.colour) } On Sat, Mar 28, 2009 at 9:45 AM, Stephan Kolassa stephan.kola...@gmx.dewrote: Hi Simeon, ?gsub HTH, Stephan simeon duckworth schrieb: I am trying to simplify a text variable by matching and replacing it with a string in another vector so for example in colours - paste(letters,colours(),stuff,LETTERS) find and replace with (red,blue,green,gray,yellow,other) - irrespective of case its a large dataset, so i'd like to be able to do this as efficiently as possible. thanks for any help [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] text matching and substitution
Jim/Stephan - absolutely perfect. thank you. very grateful for your help. simeon On Sat, Mar 28, 2009 at 5:27 PM, jim holtman jholt...@gmail.com wrote: Does this do what you want: x - c('xxxredxxx', 'blue', 'xx', 'greenbluered') pat - 'red|green|blue' result - sub(paste(^.*?(, pat, ).*, sep=), \\1, x) # check if no match in original string; replace with 'other' match - grep(pat, x) result[-match] - 'other' result [1] red blue other red On Sat, Mar 28, 2009 at 1:08 PM, Stephan Kolassa stephan.kola...@gmx.de wrote: Hi Simeon, I played around a little with Vectorize and mapply, but I couldn't make it work :-( So, my best guess would be a simple loop like this: result - as.character(paste(letters,colours(),stuff,LETTERS)) target - c(red,blue,green,gray) for ( new.color in target ) { result[grep(new.color,result)] - new.color } Best of luck, Stephan simeon duckworth schrieb: stephan sorry for not being clear - but thats exactly what i want. i'd like to replace every complex string that contains red with just red, and then so on with blue, yellow etc my data is of the form x xx xx x red xx xxx xx xx xxx xxx xx blue xx xx xx xx x x xx xx xx xx red red xx xx xx xx xx xx xx xx xx xx xx xx x x x x which i'd like to replace with red blue red other other thanks On Sat, Mar 28, 2009 at 2:38 PM, Stephan Kolassa stephan.kola...@gmx.dewrote: Hi Simeon, I'm slightly unclear on what exactly you are trying to achieve... Are you trying to replace every entry of colours which *contains* red by red, dropping the rest of the entry? And same with blue? A short example before after would be helpful... Best, Stephan simeon duckworth schrieb: thanks stephan. i'd been trying to make gsub work, but couldnt make it replace the whole expression. so i'd resorted to trying to loop with grep - but with two problems. firstly, i cant seem to make the loop 'remember' the substitutions it makes (see below). secondly, it feels like this is a really inefficient way of doing something quite simple anyhow. colours - as.character(paste(letters,colours(),stuff,LETTERS)) target - c(red,blue,green,gray) new.colour -colours for (i in length(target)) { x - target[i] new.colour[grep((x),new.colour)] - x return(new.colour) } On Sat, Mar 28, 2009 at 9:45 AM, Stephan Kolassa stephan.kola...@gmx.de wrote: Hi Simeon, ?gsub HTH, Stephan simeon duckworth schrieb: I am trying to simplify a text variable by matching and replacing it with a string in another vector so for example in colours - paste(letters,colours(),stuff,LETTERS) find and replace with (red,blue,green,gray,yellow,other) - irrespective of case its a large dataset, so i'd like to be able to do this as efficiently as possible. thanks for any help [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] calculating compound growth rates - creating a flexible function
R-listers I am still finding my way with R - and feel that I am making a complete dogs dinner of something that should be pretty simple. What I'd like to do is to create a simple function that i can use to calculate compound growth rates (CAGRs) over a data frame. I'd like the function to be flexible enough to vary the time period and to run over 'panel data'. The issue is that I can get a function to work over one variable, but cant figure out how to generalise it, specifically ... how do i get the original variable to be quoted in the output, not the constructed variable in the function ... what is the most efficient way to loop over variables in the data set to output a labelled dataframe (potentially looping by variable, by time period, or by region/country (more generally ... perhaps with plyr)) # example require(ggplot2) require(zoo) require(xts) data(economics) test-zoo(economics[,-1],economics$date) cagr - function(z,period) { z.sub - last(xts(z),period) g - lm(log(z.sub)~1+I(1:length(z.sub))) cagr - (1+g$coeff[2])^(frequency(z.sub))-1 print(cagr) } cagr(test$pce,5 years) grateful for any help simeon [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Downloading Excel file reading a range
I am trying to figure out a way to download an Excel file and then read a range into R - so that i can have a reasonably automated process. I have been trying to use the RODBC package, but with little success. I suspect that this isnt the right route Here is some code. My aim is to read in the data starting in H69:H283 in sheet 2. v-http://www.statistics.gov.uk/elmr/01_09/downloads/Table1_07.xls; dest-C:/Data/onstest.xls download.file(url=v,destfile=dest,mode=wb) library(RODBC) channel -odbcConnectExcel(dest) qry - paste(SELECT * FROM ',tbls$TABLE_NAME[2],',sep=) onstest - sqlQuery(channel,qry) close(channel) very grateful for any help simeon [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2 ribbon
I would like to be able to shade between two lines using ggplot2 (with faceting too). But, despite reading all the documentation on the website, cant figure out how to do it (either because i am a novice or idiot - or, of course, possibly both) My data looks is readership of paid free newspapers in london by age since 1994. The structure is reading.melt - structure(list(Date = structure(c(9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757, 9100, 11292, 11657, 12022, 12387, 12753, 13118, 13483, 13757), class = Date), Geog = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = London, class = factor), Type = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(Paid, Total ), class = factor), variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L ), .Label = c(Age.15.24, Age.25.34, Age.35.44, Age.45.54, Age.55.64, Age.65.), class = factor), value = c(57.6, 54.7, 44.9, 51.1, 43.5, 44.8, 44, 50, 39.6, 57.6, 54.7, 50.4, 57.3, 55, 57.5, 52.5, 60.9, 59.7, 60.7, 51.9, 52.8, 53.5, 43.5, 40.8, 47.5, 42.7, 34.4, 60.7, 51.9, 57.6, 58.7, 50.2, 51.3, 59, 55.2, 56.5, 65.3, 56.9, 50.5, 54.9, 48.3, 53.3, 43.7, 50.4, 42.2, 65.3, 56.9, 53.2, 58.1, 52.7, 57.6, 52.1, 58.2, 55.4, 69.2, 67.2, 52.6, 61.4, 56.1, 49, 54.8, 51.5, 45.2, 69.2, 67.2, 55.2, 63.6, 57.6, 53.6, 60.5, 57.2, 58.1, 70.7, 64.5, 58.2, 64.7, 57.6, 62.1, 64.3, 61.8, 59.9, 70.7, 64.5, 58.7, 66.3, 58.4, 67.2, 66.9, 63.5, 65.3, 67.5, 67.8, 66.4, 70.2, 60.2, 64, 59.4, 59.7, 57.8, 67.5, 67.8, 66.4, 70.3, 60.3, 64.7, 60, 61.1, 60.3)), .Names = c(Date, Geog, Type, variable, value), row.names = c(NA, -108L), class = data.frame ) I then run ... p-ggplot(reading.melt,aes(x=Date,y=value)) p+geom_path(aes(colour=Type),size=2)+facet_grid(variable~.) but can't figure out (1) How to add a transparent shade between the Paid Total lines. I've tried the ribbon function, but cant seem to get it to shade between the lines (2) Add a left justified title to the chart Any help very grateful received thanks simeon [[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.