search for: yearqtr

Displaying 20 results from an estimated 54 matches for "yearqtr".

2012 Apr 18
2
quarter end dates between two date strings
Hello, I have two date strings, say "1972-06-30" and "2012-01-31", and I'd like to get every quarter period end date between those dates? Does anyone know how to do this? Speed is important... Here is a small sample: Two dates: "2007-01-31" "2012-01-31" And I'd like to get this: [1] "2007-03-31" "2007-06-30"
2009 Sep 13
3
How to get last day of a month?
Is there any R function to calculate automatically the last day of a particular month? For example "sep2009" should be converted to last day of September of 2009? Thanks -- View this message in context: http://www.nabble.com/How-to-get-last-day-of-a-month--tp25425645p25425645.html Sent from the R help mailing list archive at Nabble.com.
2018 Jan 28
1
Plotting quarterly time series
Using Achim's d this also works to generate z where FUN is a function used to transform the index column and format is also passed to FUN. z <- read.zoo(d, index = "time", FUN = as.yearqtr, format = "Q%q %Y") On Sun, Jan 28, 2018 at 4:53 PM, Achim Zeileis <Achim.Zeileis at uibk.ac.at> wrote: > On Sun, 28 Jan 2018, phil at philipsmith.ca wrote: > >> I have a data set with quarterly time series for several variables. The >> time index is recorded in c...
2018 Jan 28
0
Plotting quarterly time series
...uot;, "Q2 1961","Q3 1961", "Q4 1961", "Q1 1962", etc. I want > to produce line plots with ggplot2, but it seems I need to convert the > time index from character to date class. Is that right? If so, how do I > make the conversion? You can use the yearqtr class in the zoo package, converting with as.yearqtr(..., format = "Q%q %Y"). zoo also provides an autoplot() method for ggplot2-based time series visualizations. See ?autoplot.zoo for various examples. ## example data similar to your description d <- data.frame(sin = sin(1:8), cos...
2018 Jan 28
2
Plotting quarterly time series
I have a data set with quarterly time series for several variables. The time index is recorded in column 1 of the dataframe as a character vector "Q1 1961", "Q2 1961","Q3 1961", "Q4 1961", "Q1 1962", etc. I want to produce line plots with ggplot2, but it seems I need to convert the time index from character to date class. Is that right? If so, how
2010 Jun 08
2
Extract/format/show for S4 objects
...S4 tutorials that I've found have been too high-level, and I can't find any examples of implementing extract. In S3, I can use [.Date as my example, but I can't find the equivalent for S4. Second, is this misguided? Now for the details. Given this start: library(zoo) # borrowing yearqtr for output. setClass("iqtr", contains="integer") ## Create an iqtr object from a numeric date (e.g. 2000.5). iqtr <- function (x) { iq <- as.integer(floor((as.numeric(x) - 2000) * 4 + 0.0001)) new("iqtr", iq) } setMethod("show", "...
2008 May 31
1
Representing 'Date' as 'Year - Quarter'
...0 years, and four quarters per year. The present file (.csv) reads the Date columns as "200706" for the second quarter of 2007; "199809" for the third quarter of 1997. Is there a way I can convert it to something like "2007 Q2", "1998 Q3"? I am aware of the yearqtr feature of the zoo package and ts also has some facility to represent frequency. However, the problem is that, my data isn't exactly a time series right now. In each quarterly file, the date column has the same value f.e 200706, however each row contains fundamental data of a different firm....
2012 May 04
1
zoo package; a question on as.yearmon and as.yearqtr
Hello, In zoo package, if I would like the time frame to be 1981M01 to 1982M12, then I code time_0<-as.yearmon("1981-01")+(0:23)/12 However, if the time frame of interest becomes 1981M01 to 2011M12, it is relatively hard to calculate the number of months. Is there any faster way to do it? Thanks, miao [[alternative HTML version deleted]]
2010 Oct 25
3
finding the year of a date
I know that I can use as.yearmon in the package "zoo" to find the year and the month of a date. I can use as. yearqtr to find the year and the quarter. But how can one find just the year of a date? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com
2008 Jun 29
1
Calculating quarterly statistics for time series object
I have time series observation on daily frequencies : library(zoo) SD=1 date1 = seq(as.Date("01/01/01", format = "%m/%d/%y"), as.Date("12/31/02", format = "%m/%d/%y"), by = 1) len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=SD*0.5), nrow = len1),  date1) plot(data1) Now I want to calculate 1. Quarterly statistics like mean, variance etc
2017 Oct 06
2
Time series: xts/zoo object at annual (yearly) frequency
...)) : order.by requires an appropriate time-based object > a<-xts(x=c(2,4,5), order.by=1991:1993) Error in xts(x = c(2, 4, 5), order.by = 1991:1993) : order.by requires an appropriate time-based object How should I do it? I know that to do for quarterly or monthly time series, we use as.yearqtr or as.yearmon. What about annual? Thanks, John [[alternative HTML version deleted]]
2017 Sep 11
0
Case statement in sqldf
...' and '2018-03-31' then '2017_18' else null end as FY from cr where ReportDate >= '2012-04-01' ") giving: > cr2 ReportDate FY 1 2017-09-11 2017_18 Note that using as.yearqtr from zoo this alternative could be used: library(zoo) cr <- data.frame(ReportDate = as.Date("2017-09-11")) # input fy <- as.integer(as.yearqtr(cr$ReportDate) + 3/4) transform(cr, FY = paste0(fy-1, "_", fy %% 100)) giving: ReportDate FY 1 2017-09-11 2017_18 On...
2011 Jun 07
2
Setting up a State Space Model in dlm
...ng to glance at the code. Thanks. Michael library(quantmod) library(dlm) ## Get and organize the data getSymbols("UNRATE",src="FRED") ## Unemployment rate getSymbols("GDPDEF",src="FRED") ## Quarterly GDP Implicit Price Deflator u <- aggregate(UNRATE,as.yearqtr,mean) gdpdef <- aggregate(GDPDEF,as.yearqtr,mean) pi <- diff(log(gdpdef))*400 pilag <- lag(pi,-1) tvnairu <- cbind(pi,pilag,u) tvnairu.df <- subset(data.frame(tvnairu), !is.na(pi) & !is.na(u) & !is.na(pilag)) ## First attempt buildNAIRU <- function(x) { modNAIRU <-...
2006 Oct 08
2
Select range of dates
Hello, This is likely fairly silly question, and I apologize to whomever takes the time to respond. I am a relatively new user of R, on Windows XP, version 2.3.1. Say I have a data table that looks like the following: x Date Location Amount Blue Green 1 01/01/2001 Central 1817 TRUE FALSE 2 01/02/2001 Central 20358 FALSE TRUE 3 05/08/2001 Central 16245 FALSE TRUE 4
2009 Sep 17
3
Help with date specification
Hi everyone,I have a data daily data (x) for 10 years starting from 04-01-1995 to 03-31-2005. I was able to get the yearly sum for the ten years using aggregate(x, years, sum). But this gave me the yearly sum for 1995 (Apr- Dec); 1996 (Jan-Dec) ---------2005 (Jan-Mar). But I want to get the aggregates for Apr-1995 to Mar 1996, Apr 1996- mar 1997 and so on. your help will be higly appreciated.
2007 Jul 25
3
aggregate.ts
Consider the following scrap of code: > x<- ts(1:50,start=c(1,11),freq=12) > y <- aggregate(x,nfreq=4) > c(y) [1] 6 15 24 33 42 51 60 69 78 87 96 105 114 123 132 141 > y Error in rep.int("", start.pad) : invalid number of copies in rep.int() > tsp(y) [1] 1.833333 5.583333 4.000000 So we can aggregate into quarters, but we cannot print it using
2007 Jul 25
3
aggregate.ts
Consider the following scrap of code: > x<- ts(1:50,start=c(1,11),freq=12) > y <- aggregate(x,nfreq=4) > c(y) [1] 6 15 24 33 42 51 60 69 78 87 96 105 114 123 132 141 > y Error in rep.int("", start.pad) : invalid number of copies in rep.int() > tsp(y) [1] 1.833333 5.583333 4.000000 So we can aggregate into quarters, but we cannot print it using
2010 May 12
2
How to extract sum of particular months in a monthly data series
...or a number of stations and i wish to extract sesonal time-series for the months of March-May and October-November for very station. I have read this data with read.table in R with stations as columns and time (months) as rows. My attempt to aggregate with the zoo package using the function as.yearqtr failed since this sums evey three months of the year from January. Is there away it can be coersed to aggregate particular months as in my case? Thanks ---------------------------- ZABLONE OWITI GRADUATE STUDENT College of Atmospheric Science Nanjing University of Information, Science and Te...
2006 Feb 17
3
(Newbie) Functions on vectors
Folks, I want to make the following function more efficient, by vectorizing it: getCriterionDecisionDate <- function (quarter , year) { if (length(quarter) != length(year)) stop ("Quarter and year vectors of unequal length!"); ret <- character(0); for (i in 1:length(quarter)) { currQuarter <- quarter[i]; currYear <- year[i]; if ((currQuarter < 1) |
2005 May 10
1
Aggregate lag
hello, Does anybody know how to aggregate a lag series ? when I try to use aggregate I get the following message > try<-ts(1:100,start=c(1985,1),freq=12) > aggregate(try,4,mean,na.rm=T) Qtr1 Qtr2 Qtr3 Qtr4 1985 2 5 8 11 1986 14 17 20 23 1987 26 29 32 35 1988 38 41 44 47 1989 50 53 56 59 1990 62 65 68 71 1991 74 77 80 83 1992