Displaying 5 results from an estimated 5 matches for "firstdat".
Did you mean:
firstday
2001 Feb 13
0
handle date variables
...2. How to convert a string into a date value. For
example, convert 20010122
to 2001 Jan 22, and get its day of the week, i.e.
Monday?
3. How to handle date variables in a loop? How to make
the following codes work? And how users should pass
the date arguments to the function?
fun1 <- function(firstdate, lastdate) {
for ( i in firstdate:lastdate) {
do something....
}
}
fun1(2001/01/22, 2001/01/27)
--- Douglas Bates <bates at stat.wisc.edu> wrote:
> Yu-Ling Wu <yuling5 at yahoo.com> writes:
>
> > I'd like to pass a string to a function as the
&g...
2011 Feb 09
1
Iterate over a list of input files?
...in the directory tested and augment the
data frame I'm building to have more results columns.How can I do
that?
Here's the code:
library(chron) # .Holidays / is.holiday / is.weekend
TStoDate = function (TSDate) {
X = strptime(TSDate + 19e6L, "%Y%m%d")
return(as.Date(X))
}
FirstDate = 1090601
LastDate = 1101101
StartDate = TStoDate(FirstDate)
EndDate = TStoDate(LastDate)
# Create a sequence of days from start to finish
# Then remove weekends and holidays and turn into a data.frame
dd <- seq(StartDate, EndDate, by = "day")
TradingDate <- dd[!is.weekend(dd) &...
2013 Feb 11
2
Inserting rows of interpolated data
Dear help list - I have light data with 5-min time-stamps. I would like to insert four 1-min time-stamps between each row and interpolate the light data on each new row. To do this I have come up with the following code:
lightdata <- read.table("Test_light_data.csv", header = TRUE, sep = ",") # read data file into object "lightdata"
library(chron)
mins <-
2024 Nov 27
4
R Processing dataframe by group - equivalent to SAS by group processing with a first. and retain statments
Check out the dplyr package, specifically the mutate function.
# Create new column based on existing column value
df <- df %>% mutate(FirstDay = if(ID = 2, 5))
df
Repeat as needed to capture all of the day/firstday combinations you want to account for.
Like everything else in R, there are probably at least a dozen other ways to do this, between base R and all of the library packages
2024 Nov 27
7
R Processing dataframe by group - equivalent to SAS by group processing with a first. and retain statments
I am an old, long time SAS programmer. I need to produce R code that processes a dataframe in a manner that is equivalent to that produced by using a by statement in SAS and an if first.day statement and a retain statement:
I want to take data (olddata) that looks like this
ID Day
1 1
1 1
1 2
1 2
1 3
1 3
1 4
1 4
1 5
1 5
2 5
2 5
2 5
2 6
2 6
2 6
3 10
3 10
and make it look like this:
(withing each