similar to: Representing 'Date' as 'Year - Quarter'

Displaying 20 results from an estimated 4000 matches similar to: "Representing 'Date' as 'Year - Quarter'"

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"
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
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
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
2008 Jan 10
5
diff in a dataframe
I have a dataframe say: date price_g price_s 0.34 0.56 0.36 0.76 . . . . . . and so on. say, 1000 rows. Is it possible to add two columns to this dataframe, by computing say diff(log(price_g) and diff(log(price_s)) ? The elements in the first row of these columns cannot be computed, but
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
2018 Jan 28
0
Plotting quarterly time series
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 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
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
2007 Oct 15
3
for loop if else conditional
date <- as.POSIXlt(Sys.time()) #present date for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01")) if (date$wday != 0 & date$wday != 6) {print(date);assign("date", (date-86400))} else (assign("date", (date-86400))) I am trying to print dates from present day to a day in the past, but omitting weekends. I am not doing something right, but can't
2017 Oct 06
2
Time series: xts/zoo object at annual (yearly) frequency
Hi, I'd like to make a time series at an annual frequency. > a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993")) Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) : 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 =
2007 Oct 16
1
try / tryCatch for download.file( ) within a for loop when URL does not exist
I am trying to download a bunch of files from a server, for which I am using download.file( ) within a for loop. The script is working fine except until download.file hits a URL which has no file, at which point it exits. I want to change this behavior to simple log the failure and maintain state within the for loop and iterate to next. I read about try / tryCatch but am having trouble
2012 Apr 11
2
What is a better way to deal with lag/difference and loops in time series using R?
Hello, I am writing codes for time series computation but encountering some problems Given the quarterly data from 1983Q1 to 1984Q2 PI1<-ts(c(2.747365190,2.791594762, -0.009953715, -0.015059485, -1.190061246, -0.553031799, 0.686874720, 0.953911035), start=c(1983,1), frequency=4) > PI1 Qtr1 Qtr2 Qtr3 Qtr4 1983 2.747365190 2.791594762
2008 Apr 04
1
RODBC / odbcConnectExcel Issue
Can someone throw light on the following problem I am having with RODBC? There's an Excel file I am trying to read from, it has one sheet named 'nameclass'. Thanks in anticipation. Vishal Belsare > library(RODBC) > con = odbcConnectExcel(file.choose()) > tbls <- sqlTables(con) > tbls TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS 1
2009 Mar 26
1
ApEn (Approximate Entropy), Total Corr, Information Interaction
Is there any existing implementation in R/S of : 1] Pincus & Kalman's approximate entropy (ApEn) measure 2] Total Correlation / Multiinformation 3] Information Interaction A search doesn't quite reveal anything, but I'd be keen to not reinvent in case someone has worked on it. Many thanks in anticipation. Best, Vishal Belsare
2007 Oct 15
1
String concatenation, File Path Handling to pass to download.file( ) [backslash in DOS paths]
Gabor, Thanks much. Your solution is elegant. My overall scheme is to take present date, and check whether it is a weekend, if not, then create a string based on the date, to concatenate into a url link for download.file( ). The files I need to download have a part which is in the format: mmddyy. I am working to make myself a system to connect to exchanges, and download end of day files from
2008 Jan 14
1
zoo object
I have an ordered series of 3 month t-bill rates (annual). I transform this to a daily series, however, the observations are constructed only from the dates on which the t-bills were issued, which is every week. So now I have ordered observations of the daily 'risk-free rate' for one day every week. I want to expand this zoo object to give a value for every day, and to do so, copy the
2010 Jan 20
1
Line Plot with Dates on X-axis
I am trying to generate a line graph with quarterly time buckets (with nice labels) on the x-axis. The first block of code below will generate the graph with nicely formatted x-axis labels, but the "type=" and "col=" options are not recognized when factors are used for the x-axis. The second block, where the quarter values are mapped into dates, will plot the line nicely but
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) |
2008 May 25
1
n Realizations of a Stochastic Process assigned to dynamically generated variable names?
I am interested in creating multiple (say 1000) time series, from a given stochastic process, of length 250. I want to refer to each realization with its own variable name, of the format say, tsn, where n is the n'th simulation. i.e. ts1, ts2, ts3, ts4, .... , ts1000 The way I am thinking of doing this is placing the following code within another loop, and the 'tsn' assignment should