Displaying 20 results from an estimated 3000 matches similar to: "Woring message in as.yearmon()"
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.
2008 Mar 03
1
Formating a zoo dataset .
Suppose I have following dataset :
> head(data1)
Date Return
1 03/31/00 0.14230650
2 04/28/00 -0.03276228
3 05/31/00 -0.06527890
4 06/30/00 -0.04999873
5 07/31/00 -0.01447902
6 08/31/00 0.22265729
Now I convert it to zoo object :
> data11 = zoo(data1[,2], as.Date(data1[,1], format="%m/%d/%y"))
> head(data11)
2000-03-31 2000-04-28 2000-05-31
2013 May 15
1
x and y lengths differ
I have a problem with R. I try to compute the confidence interval for my
df. When I want to create the plot I have this problem: Error in
xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ.
I try this code:
library(dplR)
df.rwi <- detrend(rwl = df, method = "Spline",nyrs=NULL)
write.table(df.rwi,file="rwi.txt",quote=FALSE,row.names=TRUE)
2009 Dec 01
1
Problem in reading data
In my Excel file, I have data in following format :
Feb-07 38.49
Mar-07 39.95
Apr-07 37.47
May-07 35.77
Jun-07 32.96
Jul-07 33.27
I tried to copy this data as a time series using following code :
library(zoo)
dat <- read.zoo(file="clipboard", format="%m-%y")
However getting following error :
Error in read.zoo(file = "clipboard", format = "%m-%y") :
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 for my example, but strange. Having converted to xts, i drop
2010 Mar 09
3
sorting data whilst ignoring NA's
Hello,
I am very new to R and have hit my first main problem that I hope someone
can easily resolve.
I have some data that looks like this (there are 20,000 rows):
> qdata
day month year flow
[1,] 2 10 1945 NA
[2,] 3 10 1945 NA
[3,] 4 10 1945 NA
[4,] 5 10 1945 NA
[5,] 6 10 1945 2.973
[6,] 7 10 1945 NA
2011 Jan 19
1
Using subset to filter data table
I am having difficulty understanding how I would constrain a data set by
filtering out 'records' based on certain criteria.
Using SQL I could query using 'select * from my.data where LithClass in
('sand', 'clay')' or some such.
Using subset, there seem to be ghosts left behind (that is, all of the
LithClass *.Labels* remain after subset)
> dput(tcc)
2010 Mar 18
1
probable timezone confusion with as.yearmon
It looks like a timezone issue, and it's causing confusion to me at least.
My original data:
gmt <-
c("19880101 0000", "19880101 0100", "19880101 0300", "19880101 0400",
"19880101 0500", "19880101 0600")
These were converted to local dates/times with
akst<-strptime(gmt,format="%Y%m%d %H%M")-(3600*9) # because I want
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) -
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]]
2011 Oct 22
3
problem with as.Date
Dear all,
I would like to convert the first column of a dataframe to a date (original
format: year (4 digits) and month (last 2 digits))
>str(dat_FF)
'data.frame': 1022 obs. of 4 variables:
$ date : int 192607 192608 192609 192610 192611 192612 192701 192702
192703 192704 ...
$ Rm.Rf: num 2.69 2.52 0 -3.06 2.42 2.66 0 4.29 0.51 0.57 ...
$ SMB : num -2.49 -1.25 -1.38 -0.2 -0.34
2008 Oct 11
5
Extracting subset of a vector
I have 2 vecros :
x<-c(100,96,88,100,100,96,80,68,92,96,88,92,68,84,84,88,72,88,72,88)
x1 = sample(x, 5, replace=FALSE)
Now i want to get remaining values of vector "x" those are not member of vector "x1". Can anyone please tell me how to do that?
2008 Mar 15
1
Fwd: Re: How to create following chart for visualizing multivariate time series
Thanks David, It is working. Holtman's also gave me a solution but, I wanted to have a color pallet for description of colors, that was not in his solution.
However I need one small modification. If I want to plot only lower diagonal elements of 'dat' then how should I proceed? What I want is, to visualize only lower diagonal elements and having the color pallet on them only. Also
2012 Feb 21
1
Questions on Data reading using zoo package
Hello,
I try to handle the data using read.csv , zoo and aggregate functions.
The data contains NA values. After aggregating monthly data into quarterly
data, all data become NA. Is it because I don't properly aggregate the data
in the presence of NAs? What can I do?
Another problem is that the date in month is presented in Chinese (My OS
is in Chinese.) How can I set the default
2008 Sep 17
5
Loop on vector name
[My previous message rejected, therefore I am sending same one with some modification]
I have 3 vectors with object name : dat1, dat2, dat3
Now I want to create a loop, like :
for (i in 1:3)
{
cat(sd(dati))
}
How I can do this in R?
Regards,
2010 Oct 15
7
Problem with merging two zoo objects
Dear all, I have following 2 zoo objects. However when I try to merge those 2 objects into one, nothing is coming as intended. Please see below the objects as well as the merged object:
> dat11
V2 V3 V4 V5
2010-10-15 13:43:54 73.8 73.8 73.8 73.8
2010-10-15 13:44:15 73.8 73.8 73.8 73.8
2010-10-15 13:45:51 73.8 73.8 73.8 73.8
2010-10-15 13:46:21 73.8 73.8 73.8 73.8
2008 Mar 15
1
How to create following chart for visualizing multivariate time series
Let me take an artifical matrix :
dat = matrix(rnorm(200*200), 200, 200)
My goal is to visualize this matrix according to the procedure, described in previous mails. I took Mendelssohn's advice and got following advice :
?plot.im
Z <- setcov(owin())
plot(Z) .................... etc
However I can not reproduce this example in my problem. How I can change my data
2009 Apr 24
1
function returns R object with name based on input
I wanted to ask how I can make a for loop or a function return an R
object with a unique name based on either some XX of the for loop or
some input for the function.
For example
if I have a function:
fn<-function(data,year){
which does does some stuff
}
How do I return an object from the function called X.year, such that if
I run fn(data,1989), the output is an object called X.1989?
In
2009 Jul 22
6
A question on operation on list
Hi,
I have created a list object like that :
x = vector("list")
for (i in 1:5) x[[i]] = rnorm(2)
x
Now I want to do two things :
1. for each i, I want to do following matrix calculation : t(x[[i]]) %*%
x[[i]] i.e. for each i, I want to get a 2x2 matrix
2. Next I want to get x[[1]] + x[[2]] +....
I did following : res=vector("list"); res = sapply(x, function(i) t(x[[i]])
%*%
2007 Jun 12
3
Panel data
Dear all R users,
I have a small doubt about panel data analysis. My basic understanding on Panel data is a type of data that is collected over time and subjects. Vector Autoregressive Model (VAR) model used on this type of data. Therefore can I say that, one of statistical tools used for analysis of panel data is VAR model? If you clarify my doubt I will be very grateful.
Thanks and regards,