Hocking-Lab / cocanal-turtles

Files related to analysis of turtle data from the Chesapeake and Ohio Canal
0 stars 0 forks source link

Potential Hang Up for Other Species #21

Open nthaydt opened 5 years ago

nthaydt commented 5 years ago

This is where I ran in to some issue running an early version of the SCR model with species other than CPIC... MultiSessionModel_NHedits.R

EM_CPIC <- EDF_CPIC %>%
  group_by(site_num, ind, trap_id_edited, day) %>%
  select(site_num, ind, trap_id_edited, day) %>%
  mutate(count = 1) %>%
  summarise_all(sum) %>%
  #spread(trap_id_edited, count, fill = 0) %>%
  ungroup() %>%
  mutate(id = as.integer(as.factor(ind)))

EM_CPIC$site_trap <- ave(EM_CPIC$trap_id_edited, EM_CPIC$site_num, FUN = function(x) as.numeric(factor(x)))
djhocking commented 4 years ago

I think the code

EDF_PRUB$trap_id_edited <- ifelse(EDF_PRUB$trap_id >= 61, EDF_PRUB$trap_id - 6, EDF_PRUB$trap_id - 0)
EDF_PRUB$site_num <- as.integer(as.factor(EDF_PRUB$site))

summary(EDF_PRUB)

is a place where there will be a problem with species that weren't catch at each site. Don't use as.factor. Manually set the site numbers using the mutate function in dplyr or better yet, make a conversion file. Just a csv with the site names in one column and the corresponding site number in the other column. If there are sites that you will not be using ("H" and "I"?) then don't include those in the first 12 numbers because we will want to loop through site numbers 1-12. This file can then be joined with a left_join() so the site number is added to each row in the original EDF data.

After that is fixed then we can look at what the issue is with the code you initially posted with the issue.

nthaydt commented 4 years ago

I’ve left joined the site number to the original EDF data. I used the site and site_num columns found in the “Max_Traps_Site” csv file. I went ahead and saved the edited version as “MultiSessionModel_NHedits2” so we aren’t editing the current file that “works” with the CPIC model. I can delete it though if you’d rather work off the previous version (I didn’t change too many things yet…). I’ve pushed the edits to GitHub.

On Sep 28, 2019, at 4:49 PM, Daniel J. Hocking notifications@github.com<mailto:notifications@github.com> wrote:

I think the code

EDF_PRUB$trap_id_edited <- ifelse(EDF_PRUB$trap_id >= 61, EDF_PRUB$trap_id - 6, EDF_PRUB$trap_id - 0) EDF_PRUB$site_num <- as.integer(as.factor(EDF_PRUB$site))

summary(EDF_PRUB)

is a place where there will be a problem with species that weren't catch at each site. Don't use as.factor. Manually set the site numbers using the mutate function in dplyr or better yet, make a conversion file. Just a csv with the site names in one column and the corresponding site number in the other column. If there are sites that you will not be using ("H" and "I"?) then don't include those in the first 12 numbers because we will want to loop through site numbers 1-12. This file can then be joined with a left_join() so the site number is added to each row in the original EDF data.

After that is fixed then we can look at what the issue is with the code you initially posted with the issue.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FHocking-Lab%2Fcocanal-turtles%2Fissues%2F21%3Femail_source%3Dnotifications%26email_token%3DAG3PMDCYU6Q2MCCAUSVZV6TQL67NBA5CNFSM4IXGZQ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD73CEKQ%23issuecomment-536224298&data=02%7C01%7Cnthaydt0%40frostburg.edu%7C8318eba98e0f404b0f3a08d744555643%7Cb8f95ed12a184246810403a67478d3a3%7C1%7C0%7C637053005616596503&sdata=v41BAYdVwZq1%2F2aIoexbo9Gm6H3i1btQeAk3gtUP%2BVg%3D&reserved=0, or mute the threadhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAG3PMDCJX7CPQ6NQIG67HSTQL67NBANCNFSM4IXGZQ5Q&data=02%7C01%7Cnthaydt0%40frostburg.edu%7C8318eba98e0f404b0f3a08d744555643%7Cb8f95ed12a184246810403a67478d3a3%7C1%7C0%7C637053005616606500&sdata=%2FfhMVmRHs9HxwI2mqKpqyWksIG2FC%2FO58TZZPq9kXRg%3D&reserved=0.