Displaying 20 results from an estimated 9000 matches similar to: "counting weekday in a month in R"
2011 Aug 30
3
having trouble extracting week from chron object
Running R 2.13.1 on Windows XP.
I would like to get week of the year (1-52) for each date.
library(chron)
dts <- dates(c("02/27/92", "02/27/92", "01/14/92","02/28/92", "02/01/92"))
dts
dts.chron <- as.chron(dts)
dts.chron
class(dts.chron)
# all of these component extractions work:
months(dts.chron)
weekdays(dts.chron)
years(dts.chron)
2001 Jan 11
3
Reformatting dates using chron
Hello All:
I am trying to generate a sequence of dates using library(chron). Using the following code, I got most of what I want,
dts <- seq.dates("01/02/1998", "01/10/2001", by="day")
dts <- dts[!is.weekend(dts)]
a sequence of weekdays only (no weekend dates), with first observation appearing as 01/02/98 and the last 01/10/01. But I would
2011 Jul 22
1
Summing values by weekday and weekend - based on daily dates
Hi, all
Here I created a data frame like
mydates<- seq(as.Date("2010-05-29"), length = 43, by = "day")
myvalues<-runif(43,0,1)
myframe<-data.frame(dates=mydates, day=weekdays(dates), value=myvalues)
dates day value
1 2010-05-29 Saturday 0.14576143
2 2010-05-30 Sunday 0.37669604
3 2010-05-31 Monday 0.74813943
4 2010-06-01 Tuesday
2011 Jul 22
1
Summing daily values by weekday and weekend
(Sorry for reposting. Please delete previous msgs. Thanks!)
Hi, all
Here I created a data frame like
mydates<- seq(as.Date("2010-05-29"), length = 43, by = "day")
myvalues<-runif(43,0,1)
myframe<-data.frame(dates=mydates, day=weekdays(dates), value=myvalues)
dates day value
1 2010-05-29 Saturday 0.14576143
2 2010-05-30 Sunday 0.37669604
2007 Dec 16
2
question about the aggregate function with respect to order of levels of grouping elements
Hi,
I am using aggregate() to add up groups of data according to year and month.
It seems that the function aggregate() automatically sorts the levels of
factors of the grouping elements, even if the order of the levels of factors
is supplied. I am wondering if this is a bug, or if I missed something
important. Below is an example that shows what I mean. Does anyone know if
this is just the way
2008 Sep 11
5
How to obtain a sequence of dates consisting of only weekdays
Dear R-users,
How do I obtain a sequence of dates consisting of only weekdays without the weekends in R?
In S, I can do the following:
timeSeq(from="12/17/2007", to="8/25/2008", by="weekdays")
I tried using looking at timeSequence (fSeries package) and seq.Date (base package) but I do not know if I can specify "weekdays" rather than "day".
2017 Jun 05
2
months not working with local language (weekdays does)
For what it's worth, I tried setting my Region | Formats setting to
Spanish (Peru) in Windows 10 Control Panel, and got Spanish weekday and
month results.
I believe on Windows we use the Microsoft C strftime function to produce
these strings, with the %A (for weekday) or %B (for month) formats. So
this question probably needs to be addressed to Microsoft.
Duncan Murdoch
On 05/06/2017
2010 Jul 15
2
How to plot a histogram of weekday frequencies in a list of dates?
Question from an [R] novice...
Hi,
I have a vector of date/times like the one shown below (a truncated
sample of a much longer list...)
> dates[1:4]
[1] "2006-03-16 08:41:00" "2006-03-16 10:28:00" "2006-03-16 11:03:00"
[4] "2006-03-16 11:04:00"
I would like to generate a weekday histogram showing the frequency of
dates falling on each weekday. I know
2017 Jun 05
0
months not working with local language (weekdays does)
Thank you Duncan and Rui for your time and interest in this issue.
Maybe it is a problem with Windows 7 and Spanish, and not Windows 10.
Let's wait for someone with the same enviroment, before assuming it's a
problem with my PC/configuration.
2017-06-05 14:37 GMT-05:00 Duncan Murdoch <murdoch.duncan at gmail.com>:
> For what it's worth, I tried setting my Region
2006 Jun 23
3
Problems with weekday extraction from zoo objects
Hi Folks!
I'm struggling with dates - but enough about my personal life.....
I have two daily time series files. In one (x) the date format is Y/m/d
and the other (y) is d/m/y. I used read.zoo on both and they read into
R with no problem.
Then I use: weekdays(as.Date(x$DATE)) and get what I expect - all the
days of the week in my data set.
When I use:
2012 May 11
1
summary for weekdays()
Hi all,
probably really simple: I seem to be lacking some understanding for the
character class: I have a bunch of dates in a dataframe and I want to add a
string variable with the weekday for each date. If I use something like
mydata$day <- weekdays (mydata$date), I can create subsets for each weekday
(eg mydata=="Monday"), but summary (mydata$day) doesn't count the instances
for
2017 Jun 05
0
months not working with local language (weekdays does)
Hello,
This doesn't answer the question, but in portuguese it works as expected.
> x <- as.Date("2017-06-05")
> months(x)
[1] "junho"
> weekdays(x)
[1] "segunda-feira"
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
2001 Sep 07
1
chron is.weekend() function
Hello,
I have a dataset which has fields giving both calendar date and weekday. I
know better functions are now available, but I am still using chron because
of the is.holiday() function and a homemade (even Heath Robinson would be
ashamed) is.daylight() function.
As a check for typos in the data input, I checked that the dates matched the
weekdays. I'm getting some confusing results
2017 Jun 05
2
months not working with local language (weekdays does)
Hi,
I want to reporte some strange behaviour with the "months" function, from
base R.
When using "months" to extract months from a date column, I'm getting the
months in english, when I was expecting months in spanish.
When using "weekdays" to extract days of week from a date column, I'm
getting the the days in spanish (as expected).
My understanding is
2010 May 17
6
Change order of columns in table?
I'm an R noob and have a (maybe) stupid question...
I have a table where I have the weekdays and a number for each weekday of
entries:
Thats what the table looks like...
Now I want to have an pie3D plot of this, but obviously the order of the
weekdays are not as one would expect...
Friday Monday Saturday Sunday Thursday Tuesday Wednesday
119 173 80
2010 Mar 12
6
Randomly sampling subsets of dataframe variable
Fellow R users,
I am stumped on what would seem to be something fairly simple.
I have a dataframe that has a variable named 'WEEK' that takes
the numbers 1:26 (26 week time-period) with each number repeated
five times consecutively (once for each weekday, Monday through
Friday). Ex. 111112222233333.....2626262626. I would like to
randomly extract two weekdays per five day week for
2011 Jul 22
0
Summing values by weekday and weekend
Sorry for reposting. The previous message not showing up.
Hi, all
Here I created a data frame like
mydates<- seq(as.Date("2010-05-29"), length = 43, by = "day")
myvalues<-runif(43,0,1)
myframe<-data.frame(dates=mydates, day=weekdays(dates), value=myvalues)
dates day value
1 2010-05-29 Saturday 0.14576143
2 2010-05-30 Sunday 0.37669604
3
2006 Aug 10
2
day, month, year functions
Hi list,
I'm trying to turn a date into something productive. (Not what you may be thinking....)
I want three functions so I could take a "date" object and get the day of week, month, and year from it.
xx <- as.Date("2006-01-05")
month(xx) equal 1
day(xx) equal 5
year(xx) equal 2006
I'm aware of the weekdays() and months() functions in the base package. But
2009 Nov 02
2
how to print the full name of the factors in summary?
Hi,
I am wondering if there is a simple way to fix the problem I am having.
For unknown reason, I could not get the full name of the factors to be
printed in the summary. I have tried to used summary.lm as well but the
problem still persists.
SJ$Weekday <-
2005 Apr 15
2
aggregate slow with variables of type 'dates' - how to solve
Dear all
I use aggregate with variables of type numeric and dates. For type numeric
functions, such as sum() are very fast, but similar simple functions, such
as min() are much slower for the variables of type 'dates'. The difference
gets bigger the larger the 'id' var is - but see this sample code:
dts <- dates(c("02/27/92", "02/27/92",