)
I want to apply dismo::maxent to a list of multiple datasets with lapply. But I get the error message that the arguments have a different number of rows, which is very strange because I created one dataset from the other one and they should have the same number of rows (which is proven via nrow()).
The fuction has the following structure:
maxent(x=dataFrame of environmental conditions at species locations (or background samples)
p=vector of 0 or 1 for species absence(0) or presence(1))
I tried:
me_lapply <- lapply(X=split_data_env_df, FUN=maxent, dummy_presence_list)
Where dummy_presence_list was generated by
dummy_presence_list <- list(rep(1, nrow(split_data_env_df[[1]])), rep(1, nrow(split_data_env_df[[2]])))
To summarize: I'm having two lists:
split_data_env_df
which contains 2 data frames, (one with 3 rows, the second has 2 rows, each representing environmental variables at species locations) and 2 columns for each df (temperature and precipitation)
t_mean | precip | t_mean2 | precip2 | |
---|---|---|---|---|
value1 | value2 | value7 | value8 | |
value3 | value4 | value9 | value10 | |
value5 | value6 |
dummy_presence_list
which contains 2 vectors: c(1,1,1) and c(1,1) telling the maxent formula that environmental parameters from split_data mean that the species is present at those locations
And I want to use lapply to run maxent(x, p) on the first elements of each list split_data_env_df
& dummy_presence_list
and on the second elements of said lists
maxent function via lapply returns that the arguments don't have an equal number of rows: 3, 2
I think it has something to do with the way how the functions treat the data and not with the data itself since the number of rows is in fact the same. Note that this is only a reduced dataset for testing purposes. My actual dataset is much larger so it would be nice to get lapply working. Thank you :-)