Displaying 20 results from an estimated 6000 matches similar to: "having trouble extracting week from chron object"
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
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
2006 Jun 23
2
problem with hist() for 'times' objects from 'chron' package
Hello dear useRs and wizaRds,
I encountered the following problem using the hist() method for the
'times' classes
from package 'chron'. You should be able to recreate it using the code:
library(chron)
# pasted from chron help file (?chron)
dts <- dates(c("02/27/92", "02/27/92", "01/14/92", "02/28/92",
"02/01/92"))
class(dts)
2005 Jul 19
2
Problems with date-format (R 2.1.1 + chron)
Hello,
today I've updated on the newest R-Version. But sadly a function I needed
didnt want to work:
The input is e.g.
days(as.Date("21-07-2005","%d-%m-%y"))
the error is: Fehler in Math.Date(dts): floor nicht definiert f??r Date
Objekte
(Error in Math.Date(dts): floor not defined for date objects)
Same for year. Only months gives me the correct output.
In Version
2009 Apr 20
4
automatic exploration of all possible loglinear models?
Is there a way to automate fitting and assessing loglinear models for
several nominal variables . . . something akin to step or drop1 or add1
for linear or logistic regression?
Thanks.
--Chris
--
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY 13790
cryanatbinghamtondotedu
"If you want to build a ship, don't drum
2008 Jun 26
2
stuck on making a line graph across time, with 4 categories
I can't seem to find just what I'm looking for in R help, Everitt and
Hothorn HSAUR, Murrell's book, or the R graphics gallery at
http://addictedtor.free.fr/graphiques/. Probably not looking
efficiently, but anyway,
If my data look like this:
> head(data)
cat startyear studentid
1 other 2001 12
2 UHS 2001 17
3 Lourdes 2001 10
4
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",
2007 Jul 13
3
THANK YOU: Updating R version
Based on the feedback received, I did the following:
a) moved my lib sub-directory from the existing installed R version to
c:\myRLib
b) installed the updated R version
c) created .Renviron file in the home directory (C:\R-2.5.1) with the line
R_LIBS=c:/myRLib
d) used .libPaths() command to confirm that the new R installation was
recognizing the myRLib sub-directory
e) deleted my old R
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
2009 Jun 30
4
conditional coloring of output text in console or in GUI
suppose I have some logical vector
x <- as.logical(c(0,0,0,1,0,0,1,1,0))
x
How would I make the words TRUE appear on the screen in a different
color from the words FALSE?
Thanks.
--Chris
--
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY 13790
cryanatbinghamtondotedu
"If you want to build a ship, don't drum
2012 Apr 18
6
introducing R to high school students
I participate peripherally on a listserve for middle- and high-school
science teachers. Sometimes questions about graphing or data analysis
come up. I never miss an opportunity to advocate for R. However, the
teachers are often skeptical that their students would be able to
issue commands or write a little code; they think it would be too
difficult. Perhaps this stems from the Microsoft- and
2004 Mar 01
6
Find out the day of week for a chron object?
I know that this is correct:
library(chron)
x = dates("01-03-04", format="d-m-y", out.format="day mon year")
print(x)
It gives me the string "01 Mar 2004" which is correct.
I also know that I can say:
print(day.of.week(3,1,2004))
in which case he says 1, for today is monday.
My question is: How do I combine these two!? :-) I have a
2008 Jul 14
2
question about a small "for" loop
R 2.5.1 on WinXP
I'm trying to create new variables in a dataframe called jaw, as powers
of jaw$age up to the sixth power, and name them
jaw$age.(--the digit corresponding to the power--)
Obviously none of these work (silly for me to try, I suppose):
for (i in 2:6) {
jaw$age.'i' <- jaw$age^i
}
for (i in 2:6) {
jaw$age.i <- jaw$age^i
}
for (i in 2:6) {
2011 Mar 22
2
adding vertical segments to an xyplot in lattice
I have a dataframe that looks like this:
> str(chr)
'data.frame': 84 obs. of 7 variables:
$ county: Factor w/ 3 levels "Broome","Nassau",..: 3 3 3 3 3 3 3 3 3 3 ...
$ item : Factor w/ 28 levels "Access to healthy foods",..: 21 19 20
18 16 3 2 6 17 8 ...
$ value : num 8644 15 3.5 3.9 7.7 ...
$ low : num 7897 9 2.5 2.6 7 ...
$ high : num 9390
2010 May 18
2
Function that is giving me a headache- any help appreciated (automatic read )
note: whole function is below- I am sure I am doing something silly.
when I use it like USGS(input="precipitation") it is choking on the
precip.1 <- subset(DF, precipitation!="NA")
b <- ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum)
DF.precip <- precip.1
DF.precip$precipitation <- b$.data
part, but runs fine outside of the function:
days=7
2000 Jul 12
1
plot.times error -- missing or illegal tck parameter (PR#601)
There seems no default setting for tck, causing problems
for plot.times()
> library(chron)
> dts <- dates(c("02/27/92", "02/27/92", "01/14/92",
+ "02/28/92", "02/01/92"))
> y<-chron(dts,out.format=c("dmy","h:m:s"))
> y
[1] 270292 270292 140192 280292 010292
> plot(y,1:5)
Error in axis(n, at =
2008 Mar 11
1
plot.zoo warnings - ignore or look for problem?
I'm getting warnings when I plot a zoo object:
> dts <- chron(rep("2007-09-10", 5), paste("00:0", 0:4, ":00", sep=""),
c("y-m-d", "h:m:s"))
> dat.zoo <- zoo(1:5, dts)
> plot(dat.zoo)
Warning messages:
1: In v[[perm[1]]] : partial match of 'm' to 'month'
2: In v[[perm[2]]] : partial match of 'd'
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
2009 Jan 27
2
using Sweave with a master file that has several iputted .tex files
Suppose I have a Master.Rnw file that looks something like this:
\documentclass[12pt]{mypaper}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{url}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{Sweave}
\pagestyle{fancy}
\lhead{sonographic rectal diameter and ADHD}
\rhead{ }
\usepackage{abbrevs}
%\usepackage{natbib}
%\usepackage{apacite}
2009 Oct 06
1
ggplot2 applying a function based on facet
Look at the bottom of the message for my question
#here is a little function that I wrote
USGS <- function(input="discharge", days=7){
library(chron)
library(gsubfn)
#021973269 is the Waynesboro Gauge on the Savannah River Proper (SRS)
#02102908 is the Flat Creek Gauge (ftbrfcms)
#02133500 is the Drowning Creek (ftbrbmcm)
#02341800 is the Upatoi Creek Near Columbus (ftbn)
#02342500 is