search for: yearmon

Displaying 20 results from an estimated 183 matches for "yearmon".

2008 Nov 04
2
ggplot & annotating charts
...ask/MktData/datahouse/vixcurrent.csv", header=T,sep=",", na.strings="") names(vix) <- tolower(names(vix)) vix$dates <- chron(as.character(vix$date),out.format="d-mon-y") vix.z <- zoo(vix[,-1],vix$dates) vix.close1<-aggregate(vix.z[,4],as.yearmon,max) # 1990 - 2003 vix.ar1 <- read.csv("C:/Data/MindShare/Recession/vixarchive.csv", header=T,sep=",", quote="",na.strings="n/a") names(vix.ar1) <- tolower(names(vix.ar1)) vix.ar1$dates <- chron(as.character(vix.ar1$date),out.format=&quot...
2010 Jul 12
3
How to create sequence in month
Hi all, can anyone please guide me how to create a sequence of months? Here I have tried following however couldn't get success > library(zoo) > seq(as.yearmon("2010-01-01"), as.yearmon("2010-03-01"), by="1 month") Error in del/by : non-numeric argument to binary operator What is the correct way to do that? Thanks for your time. [[alternative HTML version deleted]]
2010 Apr 18
4
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 fo...
2010 Apr 08
2
xts off by one confusion or error
...ting information. Here's a small subset to show the problem: A small set of data: > vv x 2010-02-01 6.1 2010-02-02 6.1 2010-02-03 6.0 2010-02-04 6.0 2010-02-05 6.0 2010-02-06 6.1 2010-02-07 6.1 2010-02-08 6.1 2010-02-09 6.1 2010-02-10 6.2 Aggregate: > aggregate (vv, as.yearmon (index (vv)), mean) Feb 2010 6.08 That's fine. But if I explicitly convert to xts (which the answer ought to be, so this should be a noop), the values shift back by one month: > xts (aggregate (vv, as.yearmon (index (vv)), mean)) x Jan 2010 6.08 Just to confirm the class...
2010 Mar 28
0
Preserving both yearmon and numeric data in an xls object
...n a list. This is necessary because the strings in each cell do not translate into a regular matrix with equal-length columns. Once I fix the entries, I'm ready to convert them into an xts object. The first two columns of the original table contain dates, and I want them to be of type "yearmon" in the xts object. The other four columns have numeric data. Here's my problem. If I convert the list into a data frame on the way to making it an xlt, the first two columns correctly keep the data as the yearmon class, but the remaining columns are converted to character class. Alte...
2011 May 19
1
Creating a "shifted" month (one that starts not on the first of each month but on another date)
...ple data: mydf<-data.frame(mydate=seq(as.Date("2011-01-01"), length = 92, by = "day")) (mydf) ### Creating a new variable that has one value before ### the 20th of each month and next value after it mydf$daynum<-as.numeric(format(mydate,"%d")) library(zoo) mydf$yearmon<-as.yearmon(mydf$mydate) (mydf); str(mydf) mydf$newfactor<-NA for(i in unique(mydf$yearmon)){ # looping through "yearmon" (important because true data has many years of data) tempdf<-mydf[mydf$yearmon == i,] which.month<-which(unique(mydf$yearmon)==i) tempdf$newfactor[temp...
2009 Jan 23
1
extract certain months toyears (zoo)
...aggr. and extract the summer data ######################################################### library(zoo) a.z<- read.zoo("glacierdischarge.txt", header=TRUE, sep=",", dec = ".", na.string="NA", format = "%d.%m.%Y") a.z.mean <- aggregate(a.z, as.yearmon, mean) a.z.median <- aggregate(a.z, as.yearmon, median) a.z.sd <- aggregate(a.z, as.yearmon, sd) a.z.min <- aggregate(a.z, as.yearmon, min) a.z.max <- aggregate(a.z, as.yearmon, max) a.z.sum <- aggregate(a.z, as yearmon, sum) a.zoo<-cbind(mean = a.z.mean, median= a.z.median, sd =...
2011 Aug 24
1
setMethods/setGeneric problem when R CMD CHECK'ing a package
R-helpers: I'm trying to build a package, but I'm a bit new to the whole S3/S4 methods concept. I'm trying to add a new definition of the zoo function "as.yearmon", but I'm getting the following error when it gets to this point during a package install: *** R CMD INSTALL STARStools * installing to library ?/Library/Frameworks/R.framework/Versions/2.13/Resources/library? WARNING: omitting pointless dependence on 'R' without a version requir...
2009 Nov 09
1
zoo: bug with unique for yearmon
I'm using R 2.10.0, with zoo 1.5-8. The release notes for zoo 1.5-8 claim a bug with unique for yearmon objects has been fixed, but I'm still having problems. Browse[1]> tmp2 [1] "Dec 1996" "Dec 1996" Browse[1]> unique(tmp2) [1] "Dec 1996" "Dec 1996" Browse[1]> unique(unique(tmp2)) [1] "Dec 1996" Browse[1]> as.numeric(tmp2) - (1996 +...
2010 Mar 18
1
probable timezone confusion with as.yearmon
...like this on my system: > akst [1] "1987-12-31 15:00:00 AKST" "1987-12-31 16:00:00 AKST" "1987-12-31 18:00:00 AKST" [4] "1987-12-31 19:00:00 AKST" "1987-12-31 20:00:00 AKST" "1987-12-31 21:00:00 AKST" but why does this happen? z<-as.yearmon(akst); z [1] "Jan 1988" "Jan 1988" "Jan 1988" "Jan 1988" "Jan 1988" "Jan 1988" I would expect this: [1] "Dec 1987" "Dec 1987" "Dec 1987" "Dec 1987" "Dec 1987" "Dec 1987" which I...
2008 Sep 10
2
Woring message in as.yearmon()
...6 1.27 [4,] 1946 7 1.27 [5,] 1946 8 1.52 [6,] 1946 9 1.52 [7,] 1946 10 1.52 [8,] 1946 11 1.52 [9,] 1946 12 1.62 [10,] 1947 1 1.62 [11,] 1947 2 1.62 [12,] 1947 3 1.62 [13,] 1947 4 1.87 [14,] 1947 5 1.87 [15,] 1947 6 1.87 Now I write following code : > as.yearmon(paste(res[,1], res[,2], sep="-")) [1] "Apr 1946" "May 1946" "Jun 1946" "Jul 1946" "Aug 1946" "Sep 1946" "Oct 1946" "Nov 1946" "Dec 1946" [10] "Jan 1947" "Feb 1947" "Mar 1947...
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]]
2012 Nov 17
3
Reshaping a dataframe
Seems like this should be easy but I'm struggling a bit. How do I rearrange a data frame to go from the first one to the second shown below ? State Date lbs TX 200701 400 TX 200702 650 TX 200703 950 TX 200704 1000 FL 200701 200 FL 200702 300 FL 200703 500 FL 200704 333 NJ 200701 409 NJ 200702 308 NJ 200703 300 NJ 200704 800 Date TX FL NJ 200701 400 200 409 200702 650
2010 Aug 13
3
transforming dates into years
Hello! If I have in my data frame MyFrame a variable saved as a Date and want to translate it into years, I currently do it like this using "zoo": library(zoo) as.year <- function(x) as.numeric(floor(as.yearmon(x))) myFrame$year<-as.year(myFrame$date) Is there a function that would do it directly - like "as.yearmon" - but for years? Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com
2009 Sep 25
0
differing behaviour between xts (0.6-7) and zoo (1.5-8)
Folks, I have some weekly dataseries that I convert to monthly xts (with yearmon indices), and obtain the two following extracts: > str(sig) An 'xts' object from Apr 1998 to Sep 1998 containing: Data: num [1:6, 1] 0.0083 0.2799 -0.2524 -0.0119 0.18 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr "e1" Indexed by objects of class...
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
2017 Sep 20
1
Convert data into zoo object using Performance analytics package
Dear Sir, Thanks for your mail and help. I got this error while trying to run your code. sbux1.z <- read.csv.zoo(u, FUN = as.yearmon, format = fmt) Error in read.table(file = file, header = header, sep = sep, quote = quote, : 'file' must be a character string or connection Thanks and Regards, Upananda Pani On Tue, Sep 19, 2017 at 4:31 PM, Upananda Pani <upananda.pani at gmail.com> wrote: > Dear Sir, > &...
2005 Dec 19
3
given a mid-month date, get the month-end date
I have a vector of dates. I wish to find the month end date for each. Any suggestions? e.g. For 12/15/05, I want 12/31/05, For 10/15/1995, I want 10/31/1995, etc __________________________________________________ [[alternative HTML version deleted]]
2017 Sep 18
3
Convert data into zoo object using Performance analytics package
...nvert data frame object to zoo object I am getting numeric(0) error in performance analytics package. The source code i am using from this website to learn r in finance: https://faculty.washington.edu/ezivot/econ424/returnCalculations.r # create zoo objects from data.frame objects dates.sbux = as.yearmon(sbux.df$Date, format="%m/%d/%Y") dates.msft = as.yearmon(msft.df$Date, format="%m/%d/%Y") sbux.z = zoo(x=sbux.df$Adj.Close, order.by=dates.sbux) msft.z = zoo(x=msft.df$Adj.Close, order.by=dates.msft) class(sbux.z) head(sbux.z) > head(sbux.z) Data: numeric(0) I will be gratef...
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code: > library(zoo) > a <- as.yearmon("March-2010", "%B-%Y") > b <- as.yearmon("May-2010", "%B-%Y") > > nn <- (b-a)*12 # number of months in between them > nn [1] 2 > as.integer(nn) [1] 1 What is the correct way to find the number of months between "a"...