hmsc-r / HMSC

GNU General Public License v3.0
103 stars 37 forks source link

Error matching species and trait names #90

Open cour10eygrace opened 3 years ago

cour10eygrace commented 3 years ago

Error in Hmsc(Y = ymat, XData = X, studyDesign = Pi, ranLevels = list(plot = rL), : rownames of Tr must match species names in Y

I receive the following error message when entering data into the Hmsc command. My species names match in the Y matrix and trait matrix. A dplyr filter of colnames(Y) %in% rownames(Tr) confirms they all match. Do they need to be in the same order?

ovaskain commented 3 years ago

Hi Courtney,

Yes, they should be in the same order.

Otso

From: Courtney Collins @.> Sent: torstai 15. huhtikuuta 2021 1:42 To: hmsc-r/HMSC @.> Cc: Subscribed @.***> Subject: [hmsc-r/HMSC] Error matching species and trait names (#90)

Error in Hmsc(Y = ymat, XData = X, studyDesign = Pi, ranLevels = list(plot = rL), : rownames of Tr must match species names in Y

I receive the following error message when entering data into the Hmsc command. My species names match in the Y matrix and trait matrix. A dplyr filter of colnames(Y) %in% rownames(Tr) confirms they all match. Do they need to be in the same order?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/hmsc-r/HMSC/issues/90, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEIYMZQSHNUETGC32S5XNE3TIYK2DANCNFSM426I4W4Q.

GolaDataExplorer commented 3 years ago

Hi Otso,

I've recently been provided with a copy of your book 'JSDM with applications in R' with the view to learn the modelling method to apply it to real-world biodiversity data in tropical forests - a very exciting prospect with real-world implications to land management. I'm new to this method so please be forgiving if I'm overlooking some blatantly obvious solution here.

Regarding the above issue mentioned by Courtney, I'm coming across the same problem of species names in traitis dataset not matching the community dataset - "rownames of TrData must match species names in Y" - however I'm using your example script (S1_fit_models_11_1) and example datasets for Section 11.1 for Finnish birds downloaded from the website: https://www2.helsinki.fi/en/researchgroups/statistical-ecology/hmsc.

I've error checked the trait and Y datasets for inconsistent spelling and order using a 'match' function in Excel, and also using the (very helpful) error-checking R script 'R scripts S1 and S2 (case specific, these examples are for the bird case study)' also from the same weblink. I would like to move past this issue - can you tell me why I'm encountering this issue in the example and how to overcome it so that I may actually look at the model output? I cannot see any steps in the book which discuss modifying the datasets.

TQ Penny

ovaskain commented 3 years ago

I think this relates to the changes in the base-line of R after we published the scripts. Maybe add StringsAsFactors=TRUE when reading in the file? Jari is probably best to tell what caused this issue.

Best,

Otso

From: PGardner @.> Sent: tiistai 18. toukokuuta 2021 13:51 To: hmsc-r/HMSC @.> Cc: Ovaskainen, Otso T @.>; Comment @.> Subject: Re: [hmsc-r/HMSC] Error matching species and trait names (#90)

Hi Otso,

I've recently been provided with a copy of your book 'JSDM with applications in R' with the view to learn the modelling method to apply it to real-world biodiversity data in tropical forests - a very exciting prospect with real-world implications to land management. I'm new to this method so please be forgiving if I'm overlooking some blatantly obvious solution here.

Regarding the above issue mentioned by Courtney, I'm coming across the same problem of species names in traitis dataset not matching the community dataset - "rownames of TrData must match species names in Y" - however I'm using your example script (S1_fit_models_11_1) and example datasets for Section 11.1 for Finnish birds downloaded from the website: https://www2.helsinki.fi/en/researchgroups/statistical-ecology/hmsc.

I've error checked the trait and Y datasets for inconsistent spelling and order using a 'match' function in Excel, and also using the (very helpful) error-checking R script 'R scripts S1 and S2 (case specific, these examples are for the bird case study)' also from the same weblink. I would like to move past this issue - can you tell me why I'm encountering this issue in the example and how to overcome it so that I may actually look at the model output? I cannot see any steps in the book which discuss modifying the datasets.

TQ Penny

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/hmsc-r/HMSC/issues/90#issuecomment-843067211, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEIYMZWZ3R2BQGVEBMUGOMLTOJBB7ANCNFSM426I4W4Q.

GolaDataExplorer commented 3 years ago

Hi Otso,

Thanks for your prompt reply - as per your suggestion, this line (StringsAsFactors=TRUE) is already included in the code when reading in the trait file and community file.

TQ Penny

jarioksa commented 3 years ago

I'll have a look at this. There is no reproducible example, but I'll try to skim through possible problems in code. Not yet today (UTC+3), but perhaps tomorrow.

akrowe20 commented 3 years ago

Hello Everyone, Has this issue been resolved? I am working through the book examples and am getting the same error message. I have tried the StringsAsFactors command and I am still receiving the message. Do I need to have a different version of R? Thanks, Amanda

ovaskain commented 3 years ago

One repeating issue that pops up because of a version difference at the time the book was published is that now rownames of traits must be the same as colnames of the species matrix. Check if the species names are as rownames in traits (rather than a data column).

Otso

From: akrowe20 @.> Sent: torstai 2. syyskuuta 2021 0:54 To: hmsc-r/HMSC @.> Cc: Ovaskainen, Otso T @.>; Comment @.> Subject: Re: [hmsc-r/HMSC] Error matching species and trait names (#90)

Hello Everyone, Has this issue been resolved? I am working through the book examples and am getting the same error message. I have tried the StringsAsFactors command and I am still receiving the message. Do I need to have a different version of R? Thanks, Amanda

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/hmsc-r/HMSC/issues/90#issuecomment-910806656, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEIYMZS2ZIPGEKMVZEKGKR3T72OFZANCNFSM426I4W4Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

cour10eygrace commented 3 years ago

It resolved for me by setting the species names in the same order in the Y and Tr matrices, I would have closed the issue, but it seems others are having similar issues