I am trying to make a heatmap of a sites vs. species abundances matrix. With thanks to Maurits Evers for some of this code, I am still not able to run it without the error message:
Setting row names on a tibble is deprecated.Error in
row.names<-.data.frame
(*tmp*
, value = list(Site = c("AwarukuLower", : invalid 'row.names' length
It was suggested tidyverse & tibbles may be the issue. I uninstalled packages tibble & tidyverse and installed the devtools readr package instead. I am still getting the same error message and can't figure out how to fix this. Data attached.
library(readr)
devtools::install_github("tidyverse/readr") #to install readr without tidyverse
bank_mean_wide_sp <- read.csv("/Users/Chloe/Desktop/Environmental Data Analysis/EDA.working.directory/bank_mean_wide.csv")
log_mean_wide_sp <- read_csv("/Users/Chloe/Desktop/Environmental Data Analysis/EDA.working.directory/log_mean_wide.csv")
as.matrix(bank_mean_wide_sp)
as.matrix(log_mean_wide_sp)
Store Site information as rownames
logdf <- log_mean_wide_sp;
base::row.names(logdf) <- log_mean_wide_sp[, 1];
Remove non-numeric column
logdf <- logdf[, -1];
Use as.matrix
to convert data.frame to matrix
logmap <- heatmap(
as.matrix(logdf),
col = cm.colors(256),
scale = "column",
margins = c(5, 10),
xlab = "species", ylab = "Site",
main = "heatmap(<Auckland Council MCI data 1999, habitat:bank>, ..., scale = \"column\")")
Returns the error message as mentioned above:
Setting row names on a tibble is deprecated.Error in
row.names<-.data.frame
(*tmp*
, value = list(Site = c("AwarukuLower", : invalid 'row.names' length
Alternatively, I tried to run the code without first 3 lines, and used as.numeric and as.matrix to convert data.frame to numeric matrix. This also did not work.
as.matrix(logdf)
logmap <- heatmap(as.numeric(logdf),
col = cm.colors(256),
scale = "column",
margins = c(5, 10),
xlab = "species", ylab = "Site",
main = "heatmap(<Auckland Council MCI data 1999, habitat:bank>, ..., scale = \"column\")")
Returns this second error:
Error in heatmap(as.numeric(logdf), col = cm.colors(256), scale = "column", : (list) object cannot be coerced to type 'double'
as.matrix
step at the beginning, before you take one column as the row names. Please clarify what your code is (in order), and what you are asking about. – Melissa Key