search for: dtstr

Displaying 7 results from an estimated 7 matches for "dtstr".

Did you mean: distr
2017 Jun 29
0
Different date formats in one column
...y not be able to get them all right unless you know something that limits the range of possible formats. Below is an example of how this can be done. There are many tutorials on the internet that describe regular expressions... they are not unique to R. #----- dta <- read.table( text= "DtStr 020917 2/22/17 May-2-2015 May-12-15 ", header=TRUE, as.is=TRUE ) dta$Dt <- as.Date( NA ) idx <- grepl( "^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-9]+-[0-9]{4}$", dta$DtStr, perl=TRUE, ignore.case = TRUE ) dta$Dt[ idx ] <- as.Date( dta$DtStr[ idx ], format=&qu...
2017 Jun 29
1
Different date formats in one column
...y not be able to get them all right unless you know something that limits the range of possible formats. Below is an example of how this can be done. There are many tutorials on the internet that describe regular expressions... they are not unique to R. #----- dta <- read.table( text= "DtStr 020917 2/22/17 May-2-2015 May-12-15 ", header=TRUE, as.is=TRUE ) dta$Dt <- as.Date( NA ) idx <- grepl( "^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-9]+-[0-9]{4}$", dta$DtStr, perl=TRUE, ignore.case = TRUE ) dta$Dt[ idx ] <- as.Date( dta$DtStr[ idx ], format=&qu...
2017 Jun 28
4
Different date formats in one column
Hi,? I have a data set with various date formats in one column and not sure how to unify it.Here is a few formats: 02091702/22/170221201703/17/160015-08-239/2/1500170806May-2-201522-March-2014 I tried parse_date_time from lubridate library but it failed.Thanks so much.?Best,Farnoosh [[alternative HTML version deleted]]
2017 Jun 30
0
Different date formats in one column
...you know something that limits the range of possible >formats. > >Below is an example of how this can be done. There are many tutorials >on >the internet that describe regular expressions... they are not unique >to >R. > >#----- >dta <- read.table( text= >"DtStr >020917 >2/22/17 >May-2-2015 >May-12-15 >", header=TRUE, as.is=TRUE ) > >dta$Dt <- as.Date( NA ) > >idx <- grepl( >"^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-9]+-[0-9]{4}$", >dta$DtStr, perl=TRUE, ignore.case = TRUE ) >dta$Dt[ i...
2011 Nov 23
1
Density over time intervals
...time(data$online_time[which(data$username==username)], format="%Y-%m-%d %H:%M:%S"); user_off <- strptime(data$offline_time[which(data$username==username)], format="%Y-%m-%d %H:%M:%S"); difftime(user_off, user_on, units="mins"); } min.of.day <- function(dtstr) # minute of day { dt <- strptime(dtstr, format="%Y-%m-%d %H:%M:%S"); h <- as.integer(strftime(dt, "%H")); m <- as.integer(strftime(dt, "%M")); s <- as.integer(strftime(dt, "%OS")); h*60+m } But there I am stuck. I thought of c...
2009 Jan 27
1
Mystery Error in midnightStandard
...#39;t find it in my script. Here is the relevant loop: date1 = timeDate(charvec = Sys.Date(), format = "%Y-%m-%d") date1 dow = 3; for (i in 1:length(V4) ) { x = read.csv(as.character(V4[[i]]), header = FALSE, na.strings=""); y = x[,1]; year = V2[[i]]; week = V3[[i]]; dtstr = sprintf("%i-%i-%i",year,week,dow); date2 = timeDate(dtstr, format = "%Y-%U-%w"); resultsdataframe$dt[[i]] <- difftimeDate(date1,date2,units = "weeks"); fp = fitdistr(y,"exponential"); print(c(V1[[i]],V2[[i]],V3[[i]],fp$estimate,fp$sd)); print(c...
2009 Jan 28
2
t.test in a loop
Hi All, I've been having a little trouble with creating a loop that will run a a series of t.tests for inspection, Below is the code i've tried, and some checks i've looked at. I've used the get(paste()) idea as i was told previously that the use of the eval should try and be avoided. I've run a single syntax to check that my systax is correct and works without any problems