find_previous_measurement_time: Find the previous measurement time for a given measurement...

Description Usage Arguments Value Examples

Description

The long dataset is obtained using gather_(dataset, "time", "number_alive", time_cols). test_id must by a variable identifying in an unique manner the replicate. The dataset must not contain NAs.

Usage

1
find_previous_measurement_time(long_dataset, test_id_, time)

Arguments

long_dataset

A dataset in the long format, with one line for each measurement in time.

test_id_

A unique identifier for each replicate.

time

The time for which we want to compute the preceding time.

Value

The previous time found in the dataset.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
dataset = read_csv('data/RTT_dataV2_ImidaclopridCorrected.csv') %>%
 mutate(test_id = seq(nrow(.)))
concentration_col = "Concentration"
species_col = "Identifier"
time_cols = c("0h", "24h", "48", "72", "R96h")
time_stamps = c(0,24,48,72,96)
ordered_time_cols = time_cols[order(time_stamps)]
make_time_col_name_time_stamp_converter = function(time_col_names, time_stamps){
  cv = c(time_col_names, time_stamps) %>% setNames(c(time_stamps, time_col_names) %>% as.character())
  cv_fun = function(ids){
    sapply(ids, function(x) cv[x])
  }
  return(cv_fun)
}
time_col_name_time_stamp_converter = make_time_col_name_time_stamp_converter(time_col_names = time_cols, time_stamps = time_stamps)

long_dataset = gather_(dataset, "time", "number_alive", time_cols) %>%
mutate(time = time_col_name_time_stamp_converter(time) %>% as.numeric()) %>%
  subset(!is.na(number_alive))

  find_previous_measurement_time(long_dataset = long_dataset, test_id = 5, time = 96)

konkam/RTTanalyse documentation built on May 20, 2019, 12:55 p.m.