I want to write a single df with the freq of 150 raster objects (partly answered in: <a href="https://stackoverflow.com/questions/52365579/count-freq-of-multiple-raster-objects-in-r" rel="nofollow">Count freq of multiple raster objects in R</a>)
I have created a list of all the raster files with
and then called
Now I have a list containing 150 entries that contain a freq matrix for every raster file.
I am only interested in
For a single entry of the list I can create a df for counts with
My question is:
How can I write
$Band.1[,"count"] for all of the 150 in the list into a single df in one go???
I see you're new here. Others will have an easier time answering your question if you can make your question reproducible -- check out this post on <a href="https://stackoverflow.com/q/5963269/2572423" rel="nofollow">how to make a great reproducible example</a>. That being said, using your other question, this should likely get you what you need:
library(tidyverse) list_of_results <- lapply(ls$raster,freq) df_of_results <- list_of_results %>% map_df(~ data.frame(.)) df_of_results$count
purrr::map functions aren't your thing, you could also do something like:
results <- unlist(lapply(list_of_results, function(x) x[, c("count")]))