Wrong class input when geting the centroid of an hypervolume

Hi! I have been working with creting a hypervolume from a dataset for some time, and after some tweaking and scaling I have been able to create a hypervolume with seemingly no errors or issues. My problem is that when I try to get the centroid from this hypervolume with the get_centroid function, I get this error:

dataCeltisaustralis <- df.clim.occ_wider %>% filter(., species == "Celtis australis") %>%
select(mean_temperature, mean_precipitation, seasonality_temperature, seasonality_precipitation)
scaledCeltisaustralis<- scale(dataCeltisaustralis)
hypervolume(scaledCeltisaustralis)
get_centroid(scaledCeltisaustralis)
Error in get_centroid(scaledCeltisaustralis) : Wrong class input.

The data seems fine and the hypervolume gives me no error back, so I am not sure of what I have done wrong. Any idea on what could be the problem?

R functions very rarely transform their inputs 'in-place' and typically are content to return their transformation to the calling environment. The user has the option to assign such results to a name for further use; you haven't assigned a name to the result of hypervolume(scaledCeltisaustralis)
that would be something like
my_hypvol_from_scaled <- hypervolume(scaledCeltisaustralis)
and then
get_centroid(my_hypvol_from_scaled)

I see. I will try it this way. Thanks a lot.

It did work. By giving the hv a new name the centroid function works with no issue.

hv_scaled_celtisaustralis<- hypervolume(scaledCeltisaustralis)
get_centroid(hv_scaled_celtisaustralis)

get_centroid(hv_scaled_celtisaustralis)
mean_temperature mean_precipitation seasonality_temperature seasonality_precipitation
-0.12817002 0.14713055 0.05883073 0.04829626

Thank you very much for your help.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.