Displaying 20 results from an estimated 7000 matches similar to: "Combining month and year into a single variable"
2007 May 10
3
Getting the last day of the month.
Hi,
Given a date, how do I get the last date of that month? I have
data in the form YYYYMM, that I've read as a date using
> x$Date <-
as.Date(ISOdate(substr(x$YearEnd,1,4),substr(x$YearEnd,5,6),1))
But this gives the first day of the month. To get the last day of the
month, I tried
> as.Date(as.yearmon(x$Date,frac=0))
But I don't get the last day of the month here. (Tried
2012 Jun 11
2
Define a variable on a non-standard year interval (Water Years)
Hello,
I am trying to define a different interval for a "year". In hydrology,
a "water year" is defined as the period between October 1st and
September 30 of the following year. I was wondering how I might do
this in R. Say I have a data.frame like the following and I want to
extract a variable with the water year specs as defined above:
2013 Mar 05
1
ggplot2: two time series with different dates in a single plot
Hi
Using the ggplot2 package, I would like to obtain a plot that contains two
time series that have data points on different dates.
For instance, one data frame looks like:
date1, value1
2010-01-05, 2921.74
2010-01-08, 2703.89
2010-01-14, 3594.21
2010-01-20, 3659.22
The other data frame looks like
date2, value2
2010-01-01, 285.85
2010-01-02, 229.20
2010-01-05, 333.91
2010-01-06, 338.27
2012 May 12
1
Query regarding date as argument in functions - and about sqldf
Hi,
I have a query about sqldf, and dates in general. I couldnt find much on
the net or on the forums, hence I am here. Here is the issue:
I want to write a function that accepts 3 arguments: date1, date2 and a
dataframe, say 'df'. Within the function, I want to populate a temp
dataframe which essentially contains the output of the query "select * from
df where DATE between date1
2015 Nov 06
4
Puzzled by eval
I am currently puzzled by a seach path behavior. I have a library of a dozen routines
getlabs(), getssn(), getecg(), ... that interface to local repositories and pull back
patient information. All have a the first 6 arguments in common, and immediately call a
second routine to do initial processing of these 6. The functions "joe" and "fred" below
capture the relevant
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
2009 Sep 22
3
how to convert character string with only month and year into date
Dear R helpers.
I am new to plotting time data using R.
wonder how to convert character time info into date in R.
I searched over the web but did not find answer.
the input character string is something like 03_1993 or 03-1993, so the
precision is at month level. I tried the following but failed.
#R code below.
strptime(c("03_1993"),"%m_%Y")
2009 Jul 11
2
Date conversions
Hi all,
I'm having a little bit of trouble with some date conversions and
am hoping someone can help me out. Thanks in advance.
OK, I have two sources of data that provide date info in a csv file
differently. I've attached a small zipped file with two text files
that illustrate both. (Is it ok to send attachments to this list? Not
sure. It's very small.) I need to be able to
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]]
2010 Nov 08
2
finding the last day of the month
Dear R Help,
I am trying to get fields showing the last day of each month for a monthly
closing project. In order to find the last day of the previous month, I
subtract the number of days from the current month. For all months my code
works; however, for October, my code doesn't work...it returns
2010-09-*29* instead
of 2010-09-*30*.
format(strptime("2010-10-31",
2012 Nov 10
4
help on date dataset
Hi everybody,
I am beginer in R and I need your precious help.
I want to create a small function in R as in sas to retrieve date.
I have a file with data that import in R.
DATE PAYS nb_pays.ILI.
1 24/04/2009 usa 0
2 24/04/2009 usa 0
3 24/04/2009 Mexique 0
4 24/04/2009
2013 Feb 14
3
Problems plotting and regression w.r.t. date data type on x axis
Hello,
probably a newbie question, but i didnt find any information on
plotting/regressing w.r.t. a date data type. My trials were unfruitful. Can
anyone help ? Thanks in advance!
Here is my interaction with R:
> tabelle
date number date2
1 2009-01-1 1673 2009-01-01
2 2009-12-1 2111 2009-12-01
3 2010-7-1 2487 2010-07-01
4 2013-2-1 4301 2013-02-01
> regression.punkte<-lm(tabelle$number
2005 Feb 24
2
Row median of Date class variables in a data frame
I am trying to calculate the median of each row of a
data frame where the data frame consist of
columns of class Date.
Below are my test data and best attempt at using apply.
I didn't see a solution via Google or the Baron search
site.
I'd be grateful for any suggestions or solutions.
I'm using R 2.0.0 on Mac OS X.
Thank you,
Stephen Weigand
### Test data
date1 <- c(1000,
2010 Dec 01
1
Changing the day of the month in a date
Hello, I want to change the day of the month in a date object. What I am
doing at the moment is:
x=as.POSIXlt(x)
x$mday=13
x=as.Date(x)
Does anybody know if there is a more "natural" (eficient) way to do this
Thank you
Felipe Parra
[[alternative HTML version deleted]]
2011 Dec 07
2
plotting and coloring longitudinal data with three time points (ggplot2)
Dear list,
I have been struggling with this for some time now, and for the last hour I have been struggling to make a working example for the list. I hope someone out there have some experience with plotting longitudinal data that they will share.
My data is some patient data with three different time stamps. First the patients are identified at different times (first time stamp). Second, they
2009 Dec 09
1
reshape() makes R run out of memory (PR#14121)
Full_Name: Alexander L. Belikoff
Version: 2.8.1
OS: Ubuntu 9.04 (x86_64)
Submission from: (NULL) (67.244.71.200)
I'm trying to reshape the following data frame:
ID DATE1 DATE2 VALUE_TYPE VALUE
'abcd1233' 2009-11-12 2009-12-23 'TYPE1' 123.45
...
VALUE_TYPE is a string and is a factor with only 2 values
2011 May 06
1
Extracting months and years from Dates while keeping order
Hello!
I'd like to take Dates and extract from them months and years - but so
that it sorts correctly. For example:
x1<-seq(as.Date("2009-01-01"), length = 14, by = "month")
(x1)
order(x1) # produces correct order based on full dates
# Of course, I could do "format" - but this way I am losing the "Date"
quality of the data:
2009 Dec 07
2
Filtering a zoo object based on index of another object
Hello everybody,
I have two datasets, observed and predicted.
Since my observed dataset is not in regular intervals, I need to filter my
predicted dataset based on the measurement date of my observed data.
Here, is an example similar to what I have
library(chron);library(zoo)
DATE<- seq(as.Date("2009-01-01"), as.Date("2009-05-01"), by = 1)
mydat<- rnorm(length(DATE),
2012 Jan 27
3
Subsetting for the ten highest values by group in a dataframe
Hello,
I am looking for a way to subset a data frame by choosing the top ten
maximum values from that dataframe. As well this occurs within some
factor levels.
## I've used plyr here but I'm not married to this approach
require(plyr)
## I've created a data.frame with two groups and then a id variable (y)
df <- data.frame(x=rnorm(400, mean=20), y=1:400,
2012 Mar 27
1
Convert day of year back into a date format.
Hello,
I am having trouble figuring out how to convert a Day of Year integer
back into a Date format. For example I have the following:
date <- c('2008-01-01','2008-01-02','2008-01-03','2008-01-04','2008-01-05','2008-01-06','2008-01-07',