Hi! I have been working with a set of data that I wanted to calculate a Hypervolume from. After succesfully doing so, scaled it and calculated its centroid. Now I am trying to do the reverse of scaling on the centroid result so I can compare it to another one, but I do not know how to proceed. I have tried using the apply function but I am quite unfamiliar with it, so I am not doing it right. Here is my relevant code:
dataCeltisaustralis <- df.clim.occ_wider %>% filter(., species == "Celtis australis") %>% select(mean_temperature, mean_precipitation, seasonality_temperature, seasonality_precipitation)
scaledCeltisaustralis<- scale(dataCeltisaustralis)
hv_scaled_celtisaustralis<- hypervolume(scaledCeltisaustralis)
centroid_Celtisaustralis <- get_centroid(hv_scaled_celtisaustralis)
unscaledCentroid_Celtisaustralis <- apply(centroid_Celtisaustralis, 1:4, function(x) x*sd, x+mean)
Should I use a different function than "apply" here? Or is it just my application of it that is wrong? Thanks a lot.