Re: [R] confused with yearmon, xts and maybe zoo

2010-04-18 Thread simeon duckworth
... 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 wrote: > Hi ga

Re: [R] confused with yearmon, xts and maybe zoo

2010-04-18 Thread simeon duckworth
indows 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 wrote: > R-listers, > > I am using xts with a yearmon index, but

[R] confused with yearmon, xts and maybe zoo

2010-04-18 Thread simeon duckworth
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

[R] chron, xts and zoo

2010-01-14 Thread simeon duckworth
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,per

[R] Plyr and memory allocation issue

2009-08-18 Thread simeon duckworth
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)

[R] Read & name multiple excel sheets using RODBC

2009-05-28 Thread simeon duckworth
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

Re: [R] text matching and substitution

2009-03-28 Thread simeon duckworth
d 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&quo

Re: [R] text matching and substitution

2009-03-28 Thread simeon duckworth
get)) { x <- target[i] new.colour[grep((x),new.colour)] <- x return(new.colour) } On Sat, Mar 28, 2009 at 9:45 AM, Stephan Kolassa wrote: > Hi Simeon, > > ?gsub > > HTH, > Stephan > > simeon duckworth schrieb: > >> I am trying to simplify a text v

[R] text matching and substitution

2009-03-28 Thread simeon duckworth
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

[R] calculating compound growth rates - creating a flexible function

2009-02-22 Thread simeon duckworth
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 fle

[R] Downloading Excel file & reading a range

2009-01-17 Thread simeon duckworth
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

[R] ggplot & annotating charts

2008-11-04 Thread simeon duckworth
Dear "R-listers" I've been trying to figure out how to annotate charts in ggplot (ie add text to line charts, highlighted boxes etc). By and large, I can get close to what i want with base graphics, but would ideally like to use ggplot whenever possible (additionally, i would like to add text lab

[R] ggplot2 & ribbon

2008-02-16 Thread simeon duckworth
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 newspape