HELP needed: arguments imply differing number of rows

Hi I get this error when I run this line:
new.sdm.dat = data.frame(new.occ, ph, aws, depth, org, c.cov, elev, asp, dup)
Error in data.frame(new.occ, ph, aws, depth, org, c.cov, elev, asp, dup) :
arguments imply differing number of rows: 3168, 5000, 1281
How do I fix it?

Lines of code running up to it:
new.sp <- SpatialPoints(new.occ[1:2])
crs(new.sp) <- CRS('+proj=longlat +datum=WGS84')

new.sp <- spTransform(new.sp, newcrs)
new.sp.cc <-spTransform(new.sp, tempcrs)
new.sp.topo <-spTransform(new.sp, topocrs)

ph <- over(new.sp, soilph)$pHwater
aws <- over(new.sp, soilh20)$AWS025
depth <- over(new.sp, soildep)$Dep2ResLyr
org <- over(new.sp, soilorg)$OrgMatter

c.cov <- raster::extract(canopy, new.sp.cc)
elev <- raster::extract(elev.dat, bg.sp.topo)
asp <- raster::extract(aspect.dat, bg.sp.topo)

sapply(list(new.occ, ph, aws, depth, org, c.cov, elev, asp), length)

new.sdm.dat = data.frame(new.occ, ph, aws, depth, org, c.cov, elev, asp, dup)

This error message means you're trying to do an operation that requires a vector of the same length, or two tables that require the same number of rows, and these are not being provided to a function that requires it.

Given the code provided it's hard to tell at which point this error occurred. Ideally, you'd pose this question with a reprex and example-dummy data (FAQ: What's a reproducible example (reprex) and how do I do one? ).

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.