kaitlyngaynor / gorongosa-mesocarnivores

2 stars 0 forks source link

error in loading detection histories #56

Closed klg-2016 closed 4 years ago

klg-2016 commented 4 years ago

https://github.com/kaitlyngaynor/gorongosa-mesocarnivores/blob/e75f436b190ee23c46044308470ccbfac2bd106b/scripts/GNP-models.Rmd#L18

This is a super basic question that I'm very confused why it's not working--this line of code is returning the following error: Error: 'gorongosa-mesocarnivores/data/gorongosa-cameras/genet.csv' does not exist in current working directory ('C:/Users/kathr/OneDrive - Nexus365/BCM/Dissertation/Mesocarnivores/Modeling/gorongosa-mesocarnivores/scripts').

I thought the working directory was automatically set as 'gorongosa-mesocarnivores'? I tried to manually set the working directory to that, and it still gave an error.

kaitlyngaynor commented 4 years ago

Do you have the R Project open as a project?

kaitlyngaynor commented 4 years ago

This is a silly error ;) You shouldn't have the "gorongosa-mesocarnivores" in that file path

change to: genet_dh <-read_csv("data/gorongosa-cameras/genet.csv")

klg-2016 commented 4 years ago

Sorry I forgot I'd added the "gorongosa-mesocarnivores" in an attempt to get it to read--even without that there it gives the error. let me check to see if it's open as a project. Also, the y argument for the R function takes a list of matrices, so I'll have to convert these csvs to matrices when I get them in, right?

klg-2016 commented 4 years ago

I also just reopened the project to ensure it was open and it's still giving the error. I'm going to try closing R completely and reopening

kaitlyngaynor commented 4 years ago

Weird. It's working for me.

kaitlyngaynor commented 4 years ago

You are also sure that the genet.csv is in that folder, right?

I AM getting other issues because it thinks that there are column names, and there aren't.

And yes, you can easily do that with the as.matrix() function. You can even pipe it into a matrix.

See here for all issues addressed: genet_dh <-read_csv("data/gorongosa-cameras/genet.csv", col_names = FALSE) %>% as.matrix()

kaitlyngaynor commented 4 years ago

Also, you don't need to create a separate object called y... you could just do this in the function

unmarkedFrameOccuMulti(y = list(genet_dh, civet_dh, mongoose_dh), siteCovs = ... etc

klg-2016 commented 4 years ago

I just double checked and "genet.csv" is indeed a file in the "gorongosa-cameras" folder of "data". I don't understand why my R is convinced I'm in the "scripts" folder as my working directory. I closed all my open scripts and RStudio and reopened and it's still cranky.

Also, you don't need to create a separate object called y... you could just do this in the function Got it, will do!

kaitlyngaynor commented 4 years ago

And the project is definitely open?

kaitlyngaynor commented 4 years ago

You see the little R studio badge and it says "gorongosa-mesocarnivores" in the top right?

klg-2016 commented 4 years ago

image this is my screen right now

klg-2016 commented 4 years ago

I feel like I've spent the last few days trying to understand much higher level stuff and getting stumped by importing data feels rough haha

klg-2016 commented 4 years ago

When I "go to working directory" it takes me to the project directory

kaitlyngaynor commented 4 years ago

Oh my gosh it's a dumb thing, I think it's because you are running the script within the Rmd file (you have "Chunk Output Inline" selected, I assume) rather than in your R environment. Click on the gear icon (to the right of the "Knit" button, left of the "Insert" button) and change to "Chunk Output in Console"

kaitlyngaynor commented 4 years ago

I always do this by default because I find it kind of annoying to have the output clogging up the Rmd script

klg-2016 commented 4 years ago

YES that worked! I also was finding the ouput in the Rmd script annoying but I didn't even think to try to change it. Thank you!