[R] How to read and write an S4 class

ml-r-help at epigenomics.com ml-r-help at epigenomics.com
Wed Aug 12 10:31:14 CEST 2009


see
?dput
?save


e.g.
setClass("track", representation(x="numeric", y="numeric"))
x <- new("track", x=1:4, y=5:8)

# save as binary
fn <- tempfile()
save(x, ascii=FALSE, file=fn)
rm(x)
load(fn)
x

# save as  ASCII
save(x, ascii=TRUE, file=fn)

# ASCII text representation from which to regenerate the data
dput(x, file=fn)
y <- dget(fn)


R_help Help wrote:
> Hi,
> 
> I have an object in S4 class. Is there anyway that I can write to a
> file and read it back to R? Thank you.
> 
> adschai
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
> 


-- 
Matthias Burger                     Project Manager/ Biostatistician
Epigenomics AG    Kleine Praesidentenstr. 1    10178 Berlin, Germany
phone:+49-30-24345-0                            fax:+49-30-24345-555
http://www.epigenomics.com           matthias.burger at epigenomics.com
--
Epigenomics AG Berlin           Amtsgericht Charlottenburg HRB 75861
Vorstand:                           Geert Nygaard (CEO/Vorsitzender)
                                            Oliver Schacht PhD (CFO)
Aufsichtsrat:   Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender)




More information about the R-help mailing list