[R-sig-Geo] Compare.cv write to csv

Paul Hiemstra paul.hiemstra at knmi.nl
Mon Oct 24 11:53:54 CEST 2011


On 10/23/2011 09:52 PM, Sandeep Patil wrote:
> Hello
>
> I have used compare.cv from Automap to generate a comparison
>
> of different interpolation methods in R.
>
> The output says that compare.cv object is a data.frame
>
> but when i try to write it to a csv file it gives me an error saying that
>
> object is "of list type"
>
> Error in write.table(x, file, nrow(x), p, rnames, sep, eol, na, dec,
> as.integer(quote),  :
>   unimplemented type 'list' in 'EncodeElement'
Hi Sandeep,

This works:

library(automap)
library(plyr)

loadMeuse()

kr.cv = autoKrige.cv(log(zinc)~1, meuse, model = c("Exp"), nfold = 10)
kr_dist.cv = autoKrige.cv(log(zinc)~sqrt(dist), meuse,
       model = c("Exp"), nfold = 10)
kr_dist_ffreq.cv = autoKrige.cv(log(zinc)~sqrt(dist)+ffreq,
       meuse, model = c("Exp"), nfold = 10)

obj = compare.cv(kr.cv, kr_dist.cv, kr_dist_ffreq.cv)
# Convert to a 'good' data.frame
obj4writecsv = ldply(obj, as.data.frame)

write.csv(obj4writecsv, file = "/tmp/bla")

This fixes your problem right now, but I agree that this behavior should
change. Writing the result of compare.cv to a tex file should be much
easier. I created a bugreport on my bitbucket account for automap.

regards,
Paul



>
> when i use class(compare.cv) it gives output as dataframe.
>
>
> I think it is a dataframe of lists or something like that.
>
>
> Please advice
>
>
> I want the datframe in a csv file where i can edit this
>
>
> ,also i have to batch process this so cant do many changes
>
>
> manually.
>
>
> Thanks in advance
>
>
> Sandeep
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770



More information about the R-sig-Geo mailing list