I am trying to convert a column to row names for each list of an object using sapply
.
tibble::column_to_rownames()
is not an option because it "always returns a data frame".
For a single variable (class sf
, data.frame
), using the base
function:
rownames(polygon_nyc_listings[[1]]) <- polygon_nyc_listings[[1]]$zipcode
It works perfectly without changing the class: sf
, data.frame
.
So I am trying to repeat for each list the function above without success:
test <- sapply(polygon_nyc_listings,
function(x){rownames(x) <- x$zipcode},
simplify = FALSE, USE.NAMES = TRUE)
I instead get an object with zipcode lists class character
.
Does someone know how to proceed?