Displaying 20 results from an estimated 40000 matches similar to: "Generating weekdays only"
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".
2002 Feb 22
1
Weekdays
Hello,
I'm trying to write a function that returns the number of weekdays between a
vector of start dates and a vector of end dates.
Subtracting the 2 times the number of whole weeks is the easy part and works
if the number of days is a multiple of 7.
However, the number of weekend days in the tail is a little harder.  It
depends on both the start date of the tail and the number of days in
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
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
2009 Jan 25
1
Delete Dates from a vector.
I need to create a vector of dates, weekdays only for a function I am
working on. Thanks to the chron library, I have managed to accomplish
this, but is there is a better / easier way. This is what I have thus
far.
        range.dates <- seq.dates('02/02/2009', '03/13/2009', by =
        'days')
        range.days <- weekdays(range.dates)
        weekends <-
2011 Jul 01
1
beginner question - effective way to chart sleep habits
Hi - beginning R user question here - each day, over the course of several
months, I've tracked the time I go to bed, the time I wake up, and my hours
spent sleeping.  What would be a good way to display this information?  I
think it would be ideal to show something resembling a bar and whisker graph
for each day that would show the interval of hours spent asleep (or perhaps
just a bar
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
2007 Apr 18
5
Problem with ?curve
Dear all R gurus,
 
I have following syntax:
 
y = c(1:10)
chippy <- function(x) 
        {
         y[5] = x
         sin(cos(t(y)%*%y)*exp(-t(y)%*%y/2))
        }
curve(chippy, 1, 20, n=200)
 
But I am getting error while executing :
 
Error in xy.coords(x, y, xlabel, ylabel, log) : 
        'x' and 'y' lengths differ
In addition: Warning message:
number of items to
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
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
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
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
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
2012 Feb 14
1
Creating categories from a date-time object
Hello R-List,
I have a question about recoding from a date time object.  I have tried using as.POSIXct objects and Chron Objects, but I can get the what I want.
I need to create a new variable from a date-time object, adding "Office Time" for those events that happens between 08:00:00 to 18:00:00 and "Out of Office" all the others, but not including weekends. I have created a
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
2007 Dec 13
1
counting weekday in a month in R
Hi,
I am trying to count weekday of the month using R. For example, 1/4/2001
is the 4th weekday of Jan, and 1/5/2001 is the 5th weekday of the month, and
1/8/2001 is the 6th weekday of the month, etc. I get as far as extracting
the weekdays from a sequence of dates (see below). But I have not yet
figured out a fast way of counting without using a For Loop. Does anyone
know how to do such counting
2007 Jun 14
1
ARIMA with more than one seasonality period
Dear R community,
I have a project with electricity load forecasting, and I got hourly
data for system load.  If you haven't worked with electricity before,
seasonality comes in many flavors: a daily pattern, with a peak at
around 7pm; a weekly pattern, in which we use more electricity on
weekdays in comparison to weekends; a winter-summer pattern, with air
conditioning and heaters playing an
2008 Jun 29
3
Interactive plot
Hi all,
I have created following codes :
mat = cbind(c(0.000059710430,0.000023057380), c(0.000023057380, 0.00005971089))
set.seed = 1000
vary = runif(dim(mat)[1], 2000, 3000)
calc = function(mat, vary)
    {
     result = vector(length = (length(vary)+1))
     result[1] = sqrt(t(vary) %*% vary)
     for (i in 1 : length(vary))
        {
         result[(i+1)] = sum(vary)*sum(vary*mat[,i])
     
2005 Dec 16
10
Associative arrays
I just started playing with rails this week and am working on porting our
existing website to rails
in our navigation we have a list that has the days of the week that link to
the articles for those days.
this seems to be working when I had it in the template it would give me the
array I was looking for so I decided to move it to the helper so that I
could use it on all my templates.
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