I am working with water quality data in which I have sampling location, the dates of the samples taken and the result of each sample. Whenever a sample result is greater than 104, it triggers an advisory. The single advisory is counted once but lasts as many days it takes until new sample data reflects a result equal to or lower than 104. The length of the advisory counts starts with the first day the advisory was triggered and counts up to, but does not include, the date the result is equal to or lower than 104. I am looking for a method to count the total number of advisories per location and the average length of an advisory (in days). Thanks!!

Dates in R: Counting Instances and Number of Days
32 Views Asked by Johanna At
1
There are 1 best solutions below
Related Questions in R
- How to make an R Shiny app with big data?
- How do I keep only specific rows based on whether a column has a specific value?
- Likert scale study - ordinal regression model
- Extract a table/matrix from R into Excel with same colors and stle
- How can I solve non-conformable arguments in R netmeta::discomb (Error in B.matrix %*% C.matrix)?
- Can raw means and estimated marginal means be the same ? And when?
- Understanding accumulate function when .dir is set to "backwards"
- Error in if (nrow(peaks) > 0) { : argument is of length zero Calls: CopywriteR ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> Execution ha
- How to increase quality of mathjax output?
- Convert the time intervals to equal hours and fill in the value column
- How to run an R function getpoints() from IPDfromKM package in an R shiny app which in R pops up a plot that utilizes clicks to capture coordinates?
- Replace NA in list of dfs in certain columns and under certain conditions
- R and text on Cyrillic
- The ts() function in R is returning the correct start and frequency but not end value which is 1 and not 179
- TROUBLING with the "DROP_NA" Function
Related Questions in DATE
- Using JQuery Date Slider
- Get Type Error when using .countDocuments with mongoDB
- Gsheet - Automatically send an email using a date & time in a Cell
- Market share growth versus last month, last year
- Convert date string into a number in Python
- Date formatting "yyyy-MM-dd hh:mm:ss +0000" to "dd MMM" in swift
- How does Big Query differentiate between a day and month when we upload any CSV or text file?
- Event_date reference in CTE
- Laravel Nova 4 format date in BelongsTo field
- how to count days elpased between each interval using mySQL?
- MariaDB incorrect dates
- Date issue - how do I parse date in this SQL
- Countdown to varying payday in Javascript
- Can I have a static ISO8601DateFormatter with specific formatOptions in Swift?
- Date Format mdy vs dmy
Related Questions in COUNT
- Pivot table outcomes are not the same and I cannot understand why
- Unable to figure out SQL Query to question
- How to find the consecutive nulls (NaN) in the columns of pandas dataframe?
- Count the number of occurrences of each variant of an enum
- R function to sum/count consecutives values - Rainfall indices
- How to use count for multiple column counts in one run
- VBA how to determine the number of rows in a variable defined by a range stored in an array
- Dates in R: Counting Instances and Number of Days
- Pivot data to Multiple columns in MySQL
- Excel Counting unique values within specific time interval
- Count Distinct Staff Ref Nos of those who have 1 or 2 or 3 records
- Multiple counts in different colums
- Count num of occurences of every 26 characters for every word in numpy
- Using one "class" or one "id" for multiple counters in javascript?
- Word count after executing mysql query
Related Questions in SUM
- Find the sum of the numbers in the sequence
- how to find sum of input value in javascript
- Multiple child processes accessing the same vector
- finding sum of prefilled fields with jquery
- Sum multiple items in 2D array based on condition (javascript)
- How do I take 2 tabs from a google sheet and combine based on the 1st column but also sum the 2nd column in Google Sheets?
- R. Sum over rows
- Dates in R: Counting Instances and Number of Days
- Summing across multiple tables and location of subquery
- How to Sum Values by Column 'Date' After Averaging by Column 'Site'?
- sum in multiple sheets with corresponding values in excel
- Power BI Dax SUM
- Calculating the sum of differences between two columns in Laravel
- Getting the sums for each desired item in a list
- Create a new table with the percentage quantity amount of individual counterparties compared to the total quantity
Related Questions in DAYS
- sqlite add x days to date (x stored in table)
- In Excel, how can I calculate leave days and hours of personnel in the office?
- Plotting temporal data day and hour together
- javascript wrong date / days calculation
- php include file based on day of the week - concise code?
- check consecutive dates matlab
- Find the date/time difference between two dates excluding weekends / off work hours and returns x Days y Hrs zz Mins
- Calculate days between two Dates in Java 8
- Swift - Get last 7 days starting from today in array
- D3 date range by hour; day repeats every 7 days
- What is the best practice to store weekdays in MongoDB?
- HOw to add specific noumber of days to date stored in a variable
- How do I show hours instead of days for an interval in PostgreSQL?
- Calculating first day Date of a week from a given week number
- How to get next day at a certain hour in PHP?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are a few steps you need to make here. Firstly, your dates appear to be stored as a character vector rather than actual date objects, so you need to convert these. Next, you need to ensure that the readings are arranged in order for each site.
You will need to include a column that tells you when the next reading for each site was made. Then, you need to find the consecutive readings at which the values are greater than 104. You can then group these together using
consecutive_ids. Finally, you can filter out the non-advisory readings and summarize the data frame to give only the minimum date and maximum 'next date' of each group of advisory readings. It is trivial to then summarize this into a data frame of counts and mean advisory lengths.Note that the site BRAA01 ends on an advisory if we order the dates properly. We do not know how long this advisory was, so we have only been able to use the first advisory period at that site in the calculation.
Data transcribed from image in question
Anyone that wants to answer this question will have to transcribe your picture into useable text, which is why we ask you not to post images of data, but rather include reproducible data in questions. I have used OCR to transcribe your data on this occasion.