OstfriesenBI / PredmiRNA

A set of scripts and tools to train a classifier for pre-miRNA Recognition
1 stars 0 forks source link

R Script: Convert csv file to arff file #4

Closed Finesim97 closed 5 years ago

Finesim97 commented 5 years ago

We need an R function which reads a csv file and converts it to an arff file. The R foreign library has an usable write.arff: https://stat.ethz.ch/R-manual/R-devel/library/foreign/html/write.arff.html When reading a csv file, String arguments will be read as factors (with all values as allowed levels), to prevent this, use the stringsAsFactors = F option of read.csv.

csvToArff <- function(in_path, out_path) {
    # code here

}

Input

"comment","sequence","realmiRNA"
"A1","ZZZZZ",0
"B2","XXXX",1

Output

@relation Example
@attribute comment string
@attribute sequence string
@attribute realmiRNA numeric
@data
'A1','ZZZZZ',0
'B2','XXXX',1