hi ,I am writing a soft package based on R.
But when I try to read a configure file showed as below.
How can I read the parameter in this text file.
How can I read the parameter into each variable in this file ?
configinfo<-scan(file(configfile),ok=TRUE,n=-1)
scan seems need every line have same column ?
configinfo <- readLines(configfile,ok=TRUE,n=-1)
methodnum <- unlist(strsplit(configinfo[2],":"))[2]
methodname <- unlist(strsplit(configinfo[3],":"))
time <- strtrim((unlist(strsplit(configinfo[4],":"))[2]),3)
and
time is a string "3 "
and
strtoi(time) failed and is "[1] NA"
when
time <- strtoi(strtrim((unlist(strsplit(configinfo[4],":"))[2]),1))
time is a integer "6"
actually this parameter could be a 1 to 4 digital number from 1 to 9999
How could I can read this kind of variables into my config R file?
thank you
################################################
##########config file ###########################
method=1; # amount of methods
method1;method2;method3; #name of the method
time=6 #time intv
byear=1990 #strar year
eyear=2010 #end year
title = "pictitle" #title
xlab = "xlabinfo" #xlab
xxlimmin = 0 #x
xxlimmax = 100 #x
ylab = "ylabinfo" #
yylimmin = 0 #
yylimmax = 100 #
graph = "phase;discrete;oscillo" #
################################################
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.