[R] glmmTMB
Hi List, I'm having some trouble finding documentation for the package glmmTMB. I would like to fit a zero-truncated poisson, what do I need to specify in "family = " for this distribution? Thanks! Alice [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding a date column with dplyr
Thanks so much, that worked! - Original Message - From: "Don MacQueen" To: "Alice Domalik" <9a...@queensu.ca>, r-help@r-project.org Sent: Friday, August 5, 2016 2:18:16 PM Subject: Re: [R] adding a date column with dplyr What's wrong with this? df$Night <- as.POSIXct( paste(format(df$Date,'%Y-%m-%d'),'21:30')) or df$Night <- trunc(df$Date,'day') + 21*60*60 + 30*60 I believe both of those satisfy "the day of tracking for each animal, but with the time of 21:30". But perhaps you meant the day that tracking started, when tracking lasted more than one day... And then just add 24 hours ("one day later") to that one special case df$Night[df$ID=='M16c'] <- df$Night[df$ID=='M16c'] + 24*60*60 -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/5/16, 9:51 AM, "R-help on behalf of Alice Domalik" wrote: >Hi all, > > >I'm having some difficulties adding a conditional element to my code. > >I have a time series data set that contains GPS tracking coordinates for >a population of animals. > > >ID Date Latitude > Longitude >15K12 2014-05-22 04:33:00 50.67675 -129.6553 > >15K12 2014-05-22 04:35:00 50.45613 -129.4566 >15K19 2014-05-24 06:44:00 50.34611 -129.5678 (and >so on) > >I added a new column to this dataset, called "Night", which is the day of >tracking for each animal, but with the time of 21:30. > > >ID Date Latitude > Longitude Night >15K12 2014-05-22 04:33:00 50.67675 -129.6553 >2014-05-22 21:30:00 > >15K12 2014-05-22 04:35:00 50.45613 -129.4566 >2014-05-22 21:30:00 >15K19 2014-05-24 06:44:00 50.34611 -129.5678 >2015-05-24 21:30:00 > >I used the following code to do this: >library(dplyr) >library(lubridate) >Sys.setenv(TZ="Canada/Pacific") >df<-df%>% > group_by(ID) %>% > mutate(Night=as.POSIXct(date(min(Date)) + days(0) + hours(21) + >minutes(30), tz="Canada/Pacific")) > >However, I need to add a conditional element, because for one animal, >"Night" needs to be 1 day later. I tried this code... > >df<-df%>% > group_by(ID) %>% > mutate(Night=ifelse(test=(id=='M16c'),yes=as.POSIXct(date(min(Date)) + >days(1) + hours(21) + minutes(30), tz="Canada/Pacific"), >no=as.POSIXct(date(min(Date)) + days(0) + hours(21) + minutes(30), >tz="Canada/Pacific"))) > >The code runs, but instead of having a date, I get a string of numbers >like "1403497200" in the column "Night". >Any ideas what the problem could be? > >Thanks, Alice > > > > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] adding a date column with dplyr
Hi all, I'm having some difficulties adding a conditional element to my code. I have a time series data set that contains GPS tracking coordinates for a population of animals. IDDate Latitude Longitude 15K12 2014-05-22 04:33:00 50.67675-129.6553 15K12 2014-05-22 04:35:00 50.45613-129.4566 15K19 2014-05-24 06:44:00 50.34611-129.5678(and so on) I added a new column to this dataset, called "Night", which is the day of tracking for each animal, but with the time of 21:30. IDDate Latitude Longitude Night 15K12 2014-05-22 04:33:00 50.67675-129.6553 2014-05-22 21:30:00 15K12 2014-05-22 04:35:00 50.45613-129.4566 2014-05-22 21:30:00 15K19 2014-05-24 06:44:00 50.34611-129.5678 2015-05-24 21:30:00 I used the following code to do this: library(dplyr) library(lubridate) Sys.setenv(TZ="Canada/Pacific") df<-df%>% group_by(ID) %>% mutate(Night=as.POSIXct(date(min(Date)) + days(0) + hours(21) + minutes(30), tz="Canada/Pacific")) However, I need to add a conditional element, because for one animal, "Night" needs to be 1 day later. I tried this code... df<-df%>% group_by(ID) %>% mutate(Night=ifelse(test=(id=='M16c'),yes=as.POSIXct(date(min(Date)) + days(1) + hours(21) + minutes(30), tz="Canada/Pacific"), no=as.POSIXct(date(min(Date)) + days(0) + hours(21) + minutes(30), tz="Canada/Pacific"))) The code runs, but instead of having a date, I get a string of numbers like "1403497200" in the column "Night". Any ideas what the problem could be? Thanks, Alice [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] filtering data by the time stamp
Hi List, I'm working with some bird GPS tracking data, and I would like to exclude points based on the time stamp. Some background information- the GPS loggers track each bird for just over 24 hours, starting in the evening, and continuing through the night and the following day. What I would like to do is exclude points taken after 21:30 on the day AFTER deployment (but retain points between 21:30 and 23:59 on the day of deployment). My data is set up like this: birdID x y datetime 15K11 492719.95634805 2015-06-23 18:25:00 I've tried running the code posted below. The idea is to use the function "mutate" to create a new variable called newdate that takes the earliest observation for each bird and sets the date for cutoff as the next day at 21:30:00. library(dplyr); library(lubridate) df %>% group_by(birdID) %>% mutate(newdate=as.POSIXct(date(min(datetime)) + days(1) + hours(21) + minutes(30))) %>% filter(datetimehttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Excluding coordinates that fall within a circle
Hi List, I'm working with some bird tracking data, and to filter the data set, I need to exclude points taken at the colony. I would like to exclude coordinates from within a 500 meter radius of a point centered on the colony. However, as an R novice, I'm not sure how to accomplish this. My df looks like this: AnimalID Latitude Longitude Datetime Any suggestions would be greatly appreciated. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with r package "trip"
Hi List, I'm relatively new to R, so apologies if my question is rather elementary. I'm working with some bird tracking data and I would like to calculate the maximum distance traveled from the colony. For the maximum distance traveled, I was going to use the function homedist(). However, when I try to use this function I get the following error: Error: could not find function "homedist" Anyone know why I would get this error? I have been using other functions in "trip" without an issue. Is there an alternative way I can calculate this? Thanks in advance for any help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.