Creating a new date.time “interval” column based on start date.time and end date.time












0















I have a data set of start and end times of when a reef is exposed during low tide. I am trying to create a new column called "interval" using the lubridate::interval function. I have about 400 rows of data.



https://github.com/LCRoysterproject/bird/blob/STEVEN-L--DEVELOPMENT/data/birdcamtides.csv



  Site     Start.Date.Time       End.Date.Time


1 LCOR_1 2017-11-08 13:20:00 2017-11-08 15:00:00
2 LCOR_1 2017-11-09 08:40:00 2017-11-09 15:45:00
3 LCOR_1 2017-11-10 09:20:00 2017-11-10 18:30:00
4 LCOR_1 2017-11-11 10:00:00 2017-11-11 18:55:00
5 LCOR_1 2017-11-12 12:05:00 2017-11-12 18:30:00
6 LCOR_1 2017-11-13 13:40:00 2017-11-13 18:55:00
7 LCOR_1 2017-11-14 07:35:00 2017-11-14 09:10:00
8 LCOR_1 2017-11-14 14:45:00 2017-11-14 18:55:00
9 LCOR_1 2017-11-15 07:30:00 2017-11-15 10:30:00
10 LCOR_1 2017-11-15 15:50:00 2017-11-15 18:55:00



library(lubridate)
tides <- read.csv("data/birdcamtides.csv", header = T)

tides$Start.Date.Time <- paste(tides$Date, tides$Start.Low.Tide)
tides$End.Date.Time <- paste(tides$Date, tides$End.Low.Tide)

tides$Start.Date.Time <- mdy_hm(tides$Start.Date.Time, tz = 'EST')
tides$End.Date.Time <- mdy_hm(tides$End.Date.Time, tz = 'EST')

tides$interval <- interval(tides$Start.Low.Tides,
tides$End.Low.Tide)


I keep getting the error
"Error in as.POSIXlt.character(as.character(x), ...) :
character string is not in a standard unambiguous format"



I don't understand how I am getting this error, since all of my dates are in the POSIX.ct format. My question is different because I am trying to write a function or something to create a new column with an interval for each corresponding start and end time.










share|improve this question




















  • 1





    please provide us a reproducible example using dput() otherwise it is difficult to help you

    – Hunaidkhan
    Nov 16 '18 at 4:05
















0















I have a data set of start and end times of when a reef is exposed during low tide. I am trying to create a new column called "interval" using the lubridate::interval function. I have about 400 rows of data.



https://github.com/LCRoysterproject/bird/blob/STEVEN-L--DEVELOPMENT/data/birdcamtides.csv



  Site     Start.Date.Time       End.Date.Time


1 LCOR_1 2017-11-08 13:20:00 2017-11-08 15:00:00
2 LCOR_1 2017-11-09 08:40:00 2017-11-09 15:45:00
3 LCOR_1 2017-11-10 09:20:00 2017-11-10 18:30:00
4 LCOR_1 2017-11-11 10:00:00 2017-11-11 18:55:00
5 LCOR_1 2017-11-12 12:05:00 2017-11-12 18:30:00
6 LCOR_1 2017-11-13 13:40:00 2017-11-13 18:55:00
7 LCOR_1 2017-11-14 07:35:00 2017-11-14 09:10:00
8 LCOR_1 2017-11-14 14:45:00 2017-11-14 18:55:00
9 LCOR_1 2017-11-15 07:30:00 2017-11-15 10:30:00
10 LCOR_1 2017-11-15 15:50:00 2017-11-15 18:55:00



library(lubridate)
tides <- read.csv("data/birdcamtides.csv", header = T)

tides$Start.Date.Time <- paste(tides$Date, tides$Start.Low.Tide)
tides$End.Date.Time <- paste(tides$Date, tides$End.Low.Tide)

tides$Start.Date.Time <- mdy_hm(tides$Start.Date.Time, tz = 'EST')
tides$End.Date.Time <- mdy_hm(tides$End.Date.Time, tz = 'EST')

tides$interval <- interval(tides$Start.Low.Tides,
tides$End.Low.Tide)


I keep getting the error
"Error in as.POSIXlt.character(as.character(x), ...) :
character string is not in a standard unambiguous format"



I don't understand how I am getting this error, since all of my dates are in the POSIX.ct format. My question is different because I am trying to write a function or something to create a new column with an interval for each corresponding start and end time.










share|improve this question




















  • 1





    please provide us a reproducible example using dput() otherwise it is difficult to help you

    – Hunaidkhan
    Nov 16 '18 at 4:05














0












0








0








I have a data set of start and end times of when a reef is exposed during low tide. I am trying to create a new column called "interval" using the lubridate::interval function. I have about 400 rows of data.



https://github.com/LCRoysterproject/bird/blob/STEVEN-L--DEVELOPMENT/data/birdcamtides.csv



  Site     Start.Date.Time       End.Date.Time


1 LCOR_1 2017-11-08 13:20:00 2017-11-08 15:00:00
2 LCOR_1 2017-11-09 08:40:00 2017-11-09 15:45:00
3 LCOR_1 2017-11-10 09:20:00 2017-11-10 18:30:00
4 LCOR_1 2017-11-11 10:00:00 2017-11-11 18:55:00
5 LCOR_1 2017-11-12 12:05:00 2017-11-12 18:30:00
6 LCOR_1 2017-11-13 13:40:00 2017-11-13 18:55:00
7 LCOR_1 2017-11-14 07:35:00 2017-11-14 09:10:00
8 LCOR_1 2017-11-14 14:45:00 2017-11-14 18:55:00
9 LCOR_1 2017-11-15 07:30:00 2017-11-15 10:30:00
10 LCOR_1 2017-11-15 15:50:00 2017-11-15 18:55:00



library(lubridate)
tides <- read.csv("data/birdcamtides.csv", header = T)

tides$Start.Date.Time <- paste(tides$Date, tides$Start.Low.Tide)
tides$End.Date.Time <- paste(tides$Date, tides$End.Low.Tide)

tides$Start.Date.Time <- mdy_hm(tides$Start.Date.Time, tz = 'EST')
tides$End.Date.Time <- mdy_hm(tides$End.Date.Time, tz = 'EST')

tides$interval <- interval(tides$Start.Low.Tides,
tides$End.Low.Tide)


I keep getting the error
"Error in as.POSIXlt.character(as.character(x), ...) :
character string is not in a standard unambiguous format"



I don't understand how I am getting this error, since all of my dates are in the POSIX.ct format. My question is different because I am trying to write a function or something to create a new column with an interval for each corresponding start and end time.










share|improve this question
















I have a data set of start and end times of when a reef is exposed during low tide. I am trying to create a new column called "interval" using the lubridate::interval function. I have about 400 rows of data.



https://github.com/LCRoysterproject/bird/blob/STEVEN-L--DEVELOPMENT/data/birdcamtides.csv



  Site     Start.Date.Time       End.Date.Time


1 LCOR_1 2017-11-08 13:20:00 2017-11-08 15:00:00
2 LCOR_1 2017-11-09 08:40:00 2017-11-09 15:45:00
3 LCOR_1 2017-11-10 09:20:00 2017-11-10 18:30:00
4 LCOR_1 2017-11-11 10:00:00 2017-11-11 18:55:00
5 LCOR_1 2017-11-12 12:05:00 2017-11-12 18:30:00
6 LCOR_1 2017-11-13 13:40:00 2017-11-13 18:55:00
7 LCOR_1 2017-11-14 07:35:00 2017-11-14 09:10:00
8 LCOR_1 2017-11-14 14:45:00 2017-11-14 18:55:00
9 LCOR_1 2017-11-15 07:30:00 2017-11-15 10:30:00
10 LCOR_1 2017-11-15 15:50:00 2017-11-15 18:55:00



library(lubridate)
tides <- read.csv("data/birdcamtides.csv", header = T)

tides$Start.Date.Time <- paste(tides$Date, tides$Start.Low.Tide)
tides$End.Date.Time <- paste(tides$Date, tides$End.Low.Tide)

tides$Start.Date.Time <- mdy_hm(tides$Start.Date.Time, tz = 'EST')
tides$End.Date.Time <- mdy_hm(tides$End.Date.Time, tz = 'EST')

tides$interval <- interval(tides$Start.Low.Tides,
tides$End.Low.Tide)


I keep getting the error
"Error in as.POSIXlt.character(as.character(x), ...) :
character string is not in a standard unambiguous format"



I don't understand how I am getting this error, since all of my dates are in the POSIX.ct format. My question is different because I am trying to write a function or something to create a new column with an interval for each corresponding start and end time.







r datetime intervals lubridate






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 5:14







Steven

















asked Nov 16 '18 at 3:45









StevenSteven

12




12








  • 1





    please provide us a reproducible example using dput() otherwise it is difficult to help you

    – Hunaidkhan
    Nov 16 '18 at 4:05














  • 1





    please provide us a reproducible example using dput() otherwise it is difficult to help you

    – Hunaidkhan
    Nov 16 '18 at 4:05








1




1





please provide us a reproducible example using dput() otherwise it is difficult to help you

– Hunaidkhan
Nov 16 '18 at 4:05





please provide us a reproducible example using dput() otherwise it is difficult to help you

– Hunaidkhan
Nov 16 '18 at 4:05












1 Answer
1






active

oldest

votes


















0














dput:



tides <- structure(list(Date = structure(c(15L, 16L, 1L, 2L, 3L, 4L, 5L, 
5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 10L, 11L, 12L, 13L, 14L), .Label = c("11/10/2017",
"11/11/2017", "11/12/2017", "11/13/2017", "11/14/2017", "11/15/2017",
"11/16/2017", "11/17/2017", "11/18/2017", "11/19/2017", "11/20/2017",
"11/21/2017", "11/22/2017", "11/23/2017", "11/8/2017", "11/9/2017"
), class = "factor"), Site = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "LCOR_1", class = "factor"),
Camera = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "HC500", class = "factor"),
Start.Low.Tide = structure(c(3L, 13L, 14L, 1L, 2L, 4L, 10L,
5L, 9L, 6L, 9L, 7L, 9L, 8L, 9L, 10L, 9L, 11L, 11L, 12L), .Label = c("10:00",
"12:05", "13:20", "13:40", "14:45", "15:50", "16:40", "17:55",
"7:30", "7:35", "7:40", "8:00", "8:40", "9:20"), class = "factor"),
End.Low.Tide = structure(c(10L, 11L, 12L, 14L, 12L, 14L,
15L, 14L, 2L, 13L, 1L, 13L, 4L, 13L, 3L, 5L, 8L, 6L, 7L,
9L), .Label = c("10:25", "10:30:00", "10:45", "10:55", "12:20",
"12:50", "13:25", "13:40", "14:35", "15:00:00", "15:45:00",
"18:30:00", "18:55", "18:55:00", "9:10:00"), class = "factor"),
Notes = structure(c(1L, 1L, 1L, 3L, 1L, 3L, 2L, 3L, 2L, 3L,
2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("", "reef showing on the first frame of the day",
"reef showing on the last frame of the day"), class = "factor"),
Start.Date.Time = structure(c(1510165200, 1510234800, 1510323600,
1510412400, 1510506300, 1510598400, 1510662900, 1510688700,
1510749000, 1510779000, 1510835400, 1510868400, 1510921800,
1510959300, 1511008200, 1511094900, 1511181000, 1511268000,
1511354400, 1511442000), class = c("POSIXct", "POSIXt"), tzone = "EST"),
End.Date.Time = structure(c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, 1510790100, 1510845900, 1510876500, 1510934100, 1510962900,
1511019900, 1511112000, 1511203200, 1511286600, 1511375100,
1511465700), class = c("POSIXct", "POSIXt"), tzone = "EST")), .Names = c("Date",
"Site", "Camera", "Start.Low.Tide", "End.Low.Tide", "Notes",
"Start.Date.Time", "End.Date.Time"), row.names = c(NA, 20L), class = "data.frame")


The variable for the interval is wrong. It should be: tides$interval <- interval(tides$Start.Date.Time, tides$End.Date.Time) as this is the lubridate version that you have calculated.






share|improve this answer


























  • I found this after I deleted the file. But this is a good way of shortening the dput() stackoverflow.com/questions/19767253/…

    – wl1234
    Nov 16 '18 at 5:18











  • added dput now.

    – wl1234
    Nov 16 '18 at 5:25











  • I am still getting the error for some reason.

    – Steven
    Nov 16 '18 at 5:50











  • Edits made to answer. This should work. The first few rows are NA.

    – wl1234
    Nov 16 '18 at 6:57











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331123%2fcreating-a-new-date-time-interval-column-based-on-start-date-time-and-end-date%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














dput:



tides <- structure(list(Date = structure(c(15L, 16L, 1L, 2L, 3L, 4L, 5L, 
5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 10L, 11L, 12L, 13L, 14L), .Label = c("11/10/2017",
"11/11/2017", "11/12/2017", "11/13/2017", "11/14/2017", "11/15/2017",
"11/16/2017", "11/17/2017", "11/18/2017", "11/19/2017", "11/20/2017",
"11/21/2017", "11/22/2017", "11/23/2017", "11/8/2017", "11/9/2017"
), class = "factor"), Site = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "LCOR_1", class = "factor"),
Camera = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "HC500", class = "factor"),
Start.Low.Tide = structure(c(3L, 13L, 14L, 1L, 2L, 4L, 10L,
5L, 9L, 6L, 9L, 7L, 9L, 8L, 9L, 10L, 9L, 11L, 11L, 12L), .Label = c("10:00",
"12:05", "13:20", "13:40", "14:45", "15:50", "16:40", "17:55",
"7:30", "7:35", "7:40", "8:00", "8:40", "9:20"), class = "factor"),
End.Low.Tide = structure(c(10L, 11L, 12L, 14L, 12L, 14L,
15L, 14L, 2L, 13L, 1L, 13L, 4L, 13L, 3L, 5L, 8L, 6L, 7L,
9L), .Label = c("10:25", "10:30:00", "10:45", "10:55", "12:20",
"12:50", "13:25", "13:40", "14:35", "15:00:00", "15:45:00",
"18:30:00", "18:55", "18:55:00", "9:10:00"), class = "factor"),
Notes = structure(c(1L, 1L, 1L, 3L, 1L, 3L, 2L, 3L, 2L, 3L,
2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("", "reef showing on the first frame of the day",
"reef showing on the last frame of the day"), class = "factor"),
Start.Date.Time = structure(c(1510165200, 1510234800, 1510323600,
1510412400, 1510506300, 1510598400, 1510662900, 1510688700,
1510749000, 1510779000, 1510835400, 1510868400, 1510921800,
1510959300, 1511008200, 1511094900, 1511181000, 1511268000,
1511354400, 1511442000), class = c("POSIXct", "POSIXt"), tzone = "EST"),
End.Date.Time = structure(c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, 1510790100, 1510845900, 1510876500, 1510934100, 1510962900,
1511019900, 1511112000, 1511203200, 1511286600, 1511375100,
1511465700), class = c("POSIXct", "POSIXt"), tzone = "EST")), .Names = c("Date",
"Site", "Camera", "Start.Low.Tide", "End.Low.Tide", "Notes",
"Start.Date.Time", "End.Date.Time"), row.names = c(NA, 20L), class = "data.frame")


The variable for the interval is wrong. It should be: tides$interval <- interval(tides$Start.Date.Time, tides$End.Date.Time) as this is the lubridate version that you have calculated.






share|improve this answer


























  • I found this after I deleted the file. But this is a good way of shortening the dput() stackoverflow.com/questions/19767253/…

    – wl1234
    Nov 16 '18 at 5:18











  • added dput now.

    – wl1234
    Nov 16 '18 at 5:25











  • I am still getting the error for some reason.

    – Steven
    Nov 16 '18 at 5:50











  • Edits made to answer. This should work. The first few rows are NA.

    – wl1234
    Nov 16 '18 at 6:57
















0














dput:



tides <- structure(list(Date = structure(c(15L, 16L, 1L, 2L, 3L, 4L, 5L, 
5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 10L, 11L, 12L, 13L, 14L), .Label = c("11/10/2017",
"11/11/2017", "11/12/2017", "11/13/2017", "11/14/2017", "11/15/2017",
"11/16/2017", "11/17/2017", "11/18/2017", "11/19/2017", "11/20/2017",
"11/21/2017", "11/22/2017", "11/23/2017", "11/8/2017", "11/9/2017"
), class = "factor"), Site = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "LCOR_1", class = "factor"),
Camera = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "HC500", class = "factor"),
Start.Low.Tide = structure(c(3L, 13L, 14L, 1L, 2L, 4L, 10L,
5L, 9L, 6L, 9L, 7L, 9L, 8L, 9L, 10L, 9L, 11L, 11L, 12L), .Label = c("10:00",
"12:05", "13:20", "13:40", "14:45", "15:50", "16:40", "17:55",
"7:30", "7:35", "7:40", "8:00", "8:40", "9:20"), class = "factor"),
End.Low.Tide = structure(c(10L, 11L, 12L, 14L, 12L, 14L,
15L, 14L, 2L, 13L, 1L, 13L, 4L, 13L, 3L, 5L, 8L, 6L, 7L,
9L), .Label = c("10:25", "10:30:00", "10:45", "10:55", "12:20",
"12:50", "13:25", "13:40", "14:35", "15:00:00", "15:45:00",
"18:30:00", "18:55", "18:55:00", "9:10:00"), class = "factor"),
Notes = structure(c(1L, 1L, 1L, 3L, 1L, 3L, 2L, 3L, 2L, 3L,
2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("", "reef showing on the first frame of the day",
"reef showing on the last frame of the day"), class = "factor"),
Start.Date.Time = structure(c(1510165200, 1510234800, 1510323600,
1510412400, 1510506300, 1510598400, 1510662900, 1510688700,
1510749000, 1510779000, 1510835400, 1510868400, 1510921800,
1510959300, 1511008200, 1511094900, 1511181000, 1511268000,
1511354400, 1511442000), class = c("POSIXct", "POSIXt"), tzone = "EST"),
End.Date.Time = structure(c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, 1510790100, 1510845900, 1510876500, 1510934100, 1510962900,
1511019900, 1511112000, 1511203200, 1511286600, 1511375100,
1511465700), class = c("POSIXct", "POSIXt"), tzone = "EST")), .Names = c("Date",
"Site", "Camera", "Start.Low.Tide", "End.Low.Tide", "Notes",
"Start.Date.Time", "End.Date.Time"), row.names = c(NA, 20L), class = "data.frame")


The variable for the interval is wrong. It should be: tides$interval <- interval(tides$Start.Date.Time, tides$End.Date.Time) as this is the lubridate version that you have calculated.






share|improve this answer


























  • I found this after I deleted the file. But this is a good way of shortening the dput() stackoverflow.com/questions/19767253/…

    – wl1234
    Nov 16 '18 at 5:18











  • added dput now.

    – wl1234
    Nov 16 '18 at 5:25











  • I am still getting the error for some reason.

    – Steven
    Nov 16 '18 at 5:50











  • Edits made to answer. This should work. The first few rows are NA.

    – wl1234
    Nov 16 '18 at 6:57














0












0








0







dput:



tides <- structure(list(Date = structure(c(15L, 16L, 1L, 2L, 3L, 4L, 5L, 
5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 10L, 11L, 12L, 13L, 14L), .Label = c("11/10/2017",
"11/11/2017", "11/12/2017", "11/13/2017", "11/14/2017", "11/15/2017",
"11/16/2017", "11/17/2017", "11/18/2017", "11/19/2017", "11/20/2017",
"11/21/2017", "11/22/2017", "11/23/2017", "11/8/2017", "11/9/2017"
), class = "factor"), Site = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "LCOR_1", class = "factor"),
Camera = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "HC500", class = "factor"),
Start.Low.Tide = structure(c(3L, 13L, 14L, 1L, 2L, 4L, 10L,
5L, 9L, 6L, 9L, 7L, 9L, 8L, 9L, 10L, 9L, 11L, 11L, 12L), .Label = c("10:00",
"12:05", "13:20", "13:40", "14:45", "15:50", "16:40", "17:55",
"7:30", "7:35", "7:40", "8:00", "8:40", "9:20"), class = "factor"),
End.Low.Tide = structure(c(10L, 11L, 12L, 14L, 12L, 14L,
15L, 14L, 2L, 13L, 1L, 13L, 4L, 13L, 3L, 5L, 8L, 6L, 7L,
9L), .Label = c("10:25", "10:30:00", "10:45", "10:55", "12:20",
"12:50", "13:25", "13:40", "14:35", "15:00:00", "15:45:00",
"18:30:00", "18:55", "18:55:00", "9:10:00"), class = "factor"),
Notes = structure(c(1L, 1L, 1L, 3L, 1L, 3L, 2L, 3L, 2L, 3L,
2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("", "reef showing on the first frame of the day",
"reef showing on the last frame of the day"), class = "factor"),
Start.Date.Time = structure(c(1510165200, 1510234800, 1510323600,
1510412400, 1510506300, 1510598400, 1510662900, 1510688700,
1510749000, 1510779000, 1510835400, 1510868400, 1510921800,
1510959300, 1511008200, 1511094900, 1511181000, 1511268000,
1511354400, 1511442000), class = c("POSIXct", "POSIXt"), tzone = "EST"),
End.Date.Time = structure(c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, 1510790100, 1510845900, 1510876500, 1510934100, 1510962900,
1511019900, 1511112000, 1511203200, 1511286600, 1511375100,
1511465700), class = c("POSIXct", "POSIXt"), tzone = "EST")), .Names = c("Date",
"Site", "Camera", "Start.Low.Tide", "End.Low.Tide", "Notes",
"Start.Date.Time", "End.Date.Time"), row.names = c(NA, 20L), class = "data.frame")


The variable for the interval is wrong. It should be: tides$interval <- interval(tides$Start.Date.Time, tides$End.Date.Time) as this is the lubridate version that you have calculated.






share|improve this answer















dput:



tides <- structure(list(Date = structure(c(15L, 16L, 1L, 2L, 3L, 4L, 5L, 
5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 10L, 11L, 12L, 13L, 14L), .Label = c("11/10/2017",
"11/11/2017", "11/12/2017", "11/13/2017", "11/14/2017", "11/15/2017",
"11/16/2017", "11/17/2017", "11/18/2017", "11/19/2017", "11/20/2017",
"11/21/2017", "11/22/2017", "11/23/2017", "11/8/2017", "11/9/2017"
), class = "factor"), Site = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "LCOR_1", class = "factor"),
Camera = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "HC500", class = "factor"),
Start.Low.Tide = structure(c(3L, 13L, 14L, 1L, 2L, 4L, 10L,
5L, 9L, 6L, 9L, 7L, 9L, 8L, 9L, 10L, 9L, 11L, 11L, 12L), .Label = c("10:00",
"12:05", "13:20", "13:40", "14:45", "15:50", "16:40", "17:55",
"7:30", "7:35", "7:40", "8:00", "8:40", "9:20"), class = "factor"),
End.Low.Tide = structure(c(10L, 11L, 12L, 14L, 12L, 14L,
15L, 14L, 2L, 13L, 1L, 13L, 4L, 13L, 3L, 5L, 8L, 6L, 7L,
9L), .Label = c("10:25", "10:30:00", "10:45", "10:55", "12:20",
"12:50", "13:25", "13:40", "14:35", "15:00:00", "15:45:00",
"18:30:00", "18:55", "18:55:00", "9:10:00"), class = "factor"),
Notes = structure(c(1L, 1L, 1L, 3L, 1L, 3L, 2L, 3L, 2L, 3L,
2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("", "reef showing on the first frame of the day",
"reef showing on the last frame of the day"), class = "factor"),
Start.Date.Time = structure(c(1510165200, 1510234800, 1510323600,
1510412400, 1510506300, 1510598400, 1510662900, 1510688700,
1510749000, 1510779000, 1510835400, 1510868400, 1510921800,
1510959300, 1511008200, 1511094900, 1511181000, 1511268000,
1511354400, 1511442000), class = c("POSIXct", "POSIXt"), tzone = "EST"),
End.Date.Time = structure(c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, 1510790100, 1510845900, 1510876500, 1510934100, 1510962900,
1511019900, 1511112000, 1511203200, 1511286600, 1511375100,
1511465700), class = c("POSIXct", "POSIXt"), tzone = "EST")), .Names = c("Date",
"Site", "Camera", "Start.Low.Tide", "End.Low.Tide", "Notes",
"Start.Date.Time", "End.Date.Time"), row.names = c(NA, 20L), class = "data.frame")


The variable for the interval is wrong. It should be: tides$interval <- interval(tides$Start.Date.Time, tides$End.Date.Time) as this is the lubridate version that you have calculated.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 16 '18 at 6:56

























answered Nov 16 '18 at 5:15









wl1234wl1234

424315




424315













  • I found this after I deleted the file. But this is a good way of shortening the dput() stackoverflow.com/questions/19767253/…

    – wl1234
    Nov 16 '18 at 5:18











  • added dput now.

    – wl1234
    Nov 16 '18 at 5:25











  • I am still getting the error for some reason.

    – Steven
    Nov 16 '18 at 5:50











  • Edits made to answer. This should work. The first few rows are NA.

    – wl1234
    Nov 16 '18 at 6:57



















  • I found this after I deleted the file. But this is a good way of shortening the dput() stackoverflow.com/questions/19767253/…

    – wl1234
    Nov 16 '18 at 5:18











  • added dput now.

    – wl1234
    Nov 16 '18 at 5:25











  • I am still getting the error for some reason.

    – Steven
    Nov 16 '18 at 5:50











  • Edits made to answer. This should work. The first few rows are NA.

    – wl1234
    Nov 16 '18 at 6:57

















I found this after I deleted the file. But this is a good way of shortening the dput() stackoverflow.com/questions/19767253/…

– wl1234
Nov 16 '18 at 5:18





I found this after I deleted the file. But this is a good way of shortening the dput() stackoverflow.com/questions/19767253/…

– wl1234
Nov 16 '18 at 5:18













added dput now.

– wl1234
Nov 16 '18 at 5:25





added dput now.

– wl1234
Nov 16 '18 at 5:25













I am still getting the error for some reason.

– Steven
Nov 16 '18 at 5:50





I am still getting the error for some reason.

– Steven
Nov 16 '18 at 5:50













Edits made to answer. This should work. The first few rows are NA.

– wl1234
Nov 16 '18 at 6:57





Edits made to answer. This should work. The first few rows are NA.

– wl1234
Nov 16 '18 at 6:57




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331123%2fcreating-a-new-date-time-interval-column-based-on-start-date-time-and-end-date%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine