Some code for R to MLComp conversion.

8 views
Skip to first unread message

Krom17

unread,
Sep 7, 2010, 9:00:52 AM9/7/10
to MLcomp
Here is a simple function in R to convert a dataframe for a copy/paste
in MLcomp.

toMLCOMP <- function (X,Cl,file="") {
for (i in seq_len(nrow(X))) {
x <- X[i,]
ix <- which(! is.na(x))
ixx <- mapply(function(x,y) paste(x,y,sep=":"),ix,x[ix]);
cat(Cl[i]," ",ixx,"\n",file);
}
}

Example :
toMLCOMP(iris[,1:4],iris[,5])

I know it could be improved but i hope you will enjoy it ;)

Christophe.

Reply all
Reply to author
Forward
0 new messages