> I would like to use compositions package with ggplot/ggtern, other > composition classes of compositional package can be used with ggtern > by converting to data frame but I could do anything with c(ount)comp > class. Ggplot/ggtern can not recognise comp and also can not be converted > > to data frame. Is there any other way to do this?
As Jeff pointed out, the help page says ccomp creates a vector or matrix. But it assigns a class of 'ccomp', and there is no obvious way to coerce this directly to a data.frame for use with ggplot (but I'm not very good with classes so I may be wrong). However, it does appear to be just a matrix(or vector) with a class added (I presume to facilitate the provision of class specific functions), so you can convert it to a matrix (vector) with attr( my_ccomp, 'class' ) <- NULL and go from there. eg library(compositions) data(SimulatedAmounts) my_ccomp <- ccomp(sa.lognormals) print(class(my_ccomp)) attr(my_ccomp,'class')<-NULL print(class(my_ccomp)) my_ccomp_df <- as.data.frame(my_ccomp) # or, as I've just seen in the code of plot.ccomp, # my_ccomp_df <- as.data.frame(unclass(my_ccomp)) Regards, Ron. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.