r/Rlanguage • u/satvrtle • 2d ago
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 216000, 129600, 14400
Hi!
I'm working on a project for uni, and I just got this error message that i cannot figure out how to solve. Here is my code, and the problem occurs in the last line. I understand that the problem is with the data frame, but how can i solve it? Knowing that I will then use all_tab in an ACP
predictors <- geodata::worldclim_country(country = c('FRA',"ESP","AND"), var='bio', mask=TRUE, res= 2.5, path="")
presvals <- terra::extract(predictors, pres)
presvals_tab <- as.data.frame(presvals)
zone <- terra::ext(0, 5, 42, 45)
all <- terra::extract(predictors, zone)
summary(all)
all_tab <- as.data.frame(all)1
u/Adventurous_Push_615 2d ago
On the extract function can you try raw = FALSE so it returns a data frame initially?
1
u/satvrtle 2d ago
it does not work, returns the error message : Error in .local(x, y, ...) : unused argument (row = FALSE)
1
1
u/Adventurous_Push_615 2d ago
Ah also, it's perhaps that
worldclim_countryis returning a list, data for each country and they have different numbers of rows - examine what it returns1
u/satvrtle 2d ago
yeah it's telling me that it's the class is a SpatRasterCollection. And yeah the nrows (and ncol) are all different indeed
1
u/Confident_Bee8187 2d ago
Please post this on r/rstats. Details: https://www.reddit.com/r/Rlanguage/s/HSnPPqdhu5
2
u/SprinklesFresh5693 2d ago
In which of those 5 objects are you getting the error