Problem to export simper data in csv

Hi Studio community,
I have a little problem with my data set create in Studio environment.
I juste need after Simper analysis (with vegan) to keep data in csv or txt document. Unfortunately, I have an error message
"Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
cannot coerce class ""simper"" to a data.frame" and my simper data are not exploitable for graphical representations after (like marplot, with ggplot2). "

Please find my script here :

library("vegan")
data(dune.env)
data(dune)
(sim=with(dune.env, simper(dune, Management)))
summary(sim)
write.csv(sim, "data.csv")
sim

Thank you for your help

Well, the sim object is of class simper and it does not make much sense to write it as CSV rectangular data.

If you are using RStudio, then in the Environment pane you will see that the 'Value' column is 'List of 6' and you should be able to view the object as a list.

If you just want a text representation of your object which you can retrieve later, you can dput and dget. See code below.

library("vegan")
data(dune.env)
data(dune)
(sim=with(dune.env, simper(dune, Management)))
summary(sim)
class(sim)
dput(sim, file = "sim.txt")
sim2 <- dget("sim.txt")
summary(sim2)

Dear Radmuzom,
It's work thank you for the help :slight_smile:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.