0

I am trying to solve some mystery puzzle to identify some thief using some df as is shown below. I have been able to narrow the search down using some set criteria except the last one

library(tidyr)
df1<- tidyr::separate(suspect_times, Time.Spotted, c("date", "time"), sep = " ")

Name Occupation date time Mary Martin actress 2018-01-29 12:41:00
Woody Allen director 2018-07-23 04:42:30
Lou Rawls singer 2018-02-01 10:18:10
Lee Trevino PGA golfer 2018-12-20 03:46:00
Richard Pryor actor 2018-03-21 18:21:20
Bette Midler actress 2018-07-13 23:15:10
Treat Williams actor 2018-12-23 05:53:10
Georges Seurat painter 2018-07-15 10:27:00
Charles Ringling formed Ringling Bros circus 2018-03-24 11:07:40
Julie Harris actress 2018-11-14 19:09:10

subsetting the time from midday to midnight to exclude any hour in the AM segment

library(lubridate)
df1[df1$time >= "12-00-00" & df1$time <= "23-59-59", ]

## Subsetting the date to fall within some defined date as shown
df1[df1$date >= "2018-10-18" & df1$date <= "2018-11-22", ]

## converting the dates in weekdays

df2 <- df1 ##replicating df1
df2$date <- strftime(df2$date, "%A") ##converting dates to weekdays
df2  ##Print converted data

Name Occupation date time Mary Martin actress Monday 12:41:00
Woody Allen director Monday 04:42:30
Lou Rawls singer Thursday 10:18:10
Lee Trevino PGA golfer Thursday 03:46:00
Richard Pryor actor Wednesday 18:21:20
Bette Midler actress Friday 23:15:10
Treat Williams actor Sunday 05:53:10
Georges Seurat painter Sunday 10:27:00
Charles Ringling formed Ringling Bros circus Saturday 11:07:40
Julie Harris actress Wednesday 19:09:10

##deleting the rows containing Tuesdays and Thursdays to narrow the search with the exclusion of these days

df3<-df2[!(df2$date=="Tuesday" | df2$date=="Thursday"),]
df3

Name Occupation date time 88 Mary Todd Lincoln First Lady of the United States Wednesday 20:39:30 89 Archie Moore champion boxer Friday 00:24:10 90 Dick Van Dyke actor Friday 09:15:20 91 Christopher Plummer actor Monday 13:23:50 92 John Davidson actor Sunday 18:52:20 93 Ted Nugent singer Sunday 03:54:10 94 Nostradamus astrologer Saturday 15:29:50 95 James Doolittle World War II aviator Wednesday 11:40:30 96 Morey Amsterdam actor Wednesday 05:27:10 97 Don Hewitt TV producer Monday 11:11:20

I am now stuck here: getting an end date given that the start data is 1970 midnight and the time difference in minutes is divisible by 10- such that I can single out a particular person

Peace Wang
  • 2,399
  • 1
  • 8
  • 15
  • Please share data in reproducible format. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Peace Wang May 04 '21 at 08:26
  • @PeaceWang here is a subset of my dataframe structure(list(Name = c("Mary Martin", "Woody Allen"), Occupation = c("actress", "director"), date = c("Monday", "Monday"), time = c("12:41:00", "04:42:30")), row.names = 1:2, class = c("tbl_df", "tbl", "data.frame" )) – Data_Analytics 49 May 04 '21 at 11:03

0 Answers0