comparison extract_ipm_date_interval.R @ 5:87482a201699 draft

Uploaded
author greg
date Wed, 01 Aug 2018 08:25:22 -0400
parents 3741790740f3
children 869e7d06bdf3
comparison
equal deleted inserted replaced
4:3741790740f3 5:87482a201699
26 26
27 # FIXME: currently custom date fields are free text, but 27 # FIXME: currently custom date fields are free text, but
28 # Galaxy should soon include support for a date selector 28 # Galaxy should soon include support for a date selector
29 # at which point this tool should be enhanced to use it. 29 # at which point this tool should be enhanced to use it.
30 # Validate start_date. 30 # Validate start_date.
31 start_date = format(opt$start_date);
32 end_date = format(opt$end_date);
31 33
32 # Calaculate the number of days in the date interval. 34 # Calaculate the number of days in the date interval.
33 start_date = validate_date(format(opt$start_date)); 35 start_date = validate_date(start_date);
34 # Validate end_date. 36 # Validate end_date.
35 end_date = validate_date(format(opt$end_date)); 37 end_date = validate_date(end_date);
36 if (start_date >= end_date) { 38 if (start_date >= end_date) {
37 stop_err("The start date must be between 1 and 50 days before the end date when setting date intervals for plots."); 39 stop_err("The start date must be between 1 and 50 days before the end date when setting date intervals for plots.");
38 } 40 }
39 # Calculate the number of days in the date interval. 41 # Calculate the number of days in the date interval.
40 num_days = difftime(end_date, start_date, units=c("days")); 42 num_days = difftime(end_date, start_date, units=c("days"));
72 temperature_data_frame = temperature_data_frame[start_date_row:end_date_row,]; 74 temperature_data_frame = temperature_data_frame[start_date_row:end_date_row,];
73 # Save the date interval data into an output file 75 # Save the date interval data into an output file
74 # named the same as the input. 76 # named the same as the input.
75 file_path = paste("output_data_dir", input_file, sep="/"); 77 file_path = paste("output_data_dir", input_file, sep="/");
76 write.csv(temperature_data_frame, file=file_path, row.names=F); 78 write.csv(temperature_data_frame, file=file_path, row.names=F);
77 # TODO: Save the dat interval plots... 79 # TODO: Save the datE interval plots...
78 } 80 }