[R] reading lisp file in R
Martin Møller Skarbiniks Pedersen
traxplayer at gmail.com
Fri Jan 19 02:38:42 CET 2018
Here are the beginning of a R program.
I hope it can help you writing the rest of the program.
Regards
Martin M. S. Pedersen
----
filename <- "university.data"
lines <- readLines(filename)
first <- T
for (ALine in lines) {
ALine <- sub("^ +","",ALine)
ALine <- sub(")","",ALine, fixed = T)
if (length(grep("def-instance", ALine))) {
if (first) {
first = F
}
else {
cat(paste(instance,state,control,no_of_students_thous,"\n", sep = ","))
}
instance <- sub("(def-instance ","",ALine, fixed = T)
next
}
if (length(grep("state ", ALine))) {
state <- sub("(state ","",ALine, fixed = T)
next
}
if (length(grep("control ", ALine))) {
control <- sub("(control ","", ALine, fixed = T)
next
}
if (length(grep("no-of-students thous:", ALine))) {
no_of_students_thous <- ALine
no_of_students_thous <- sub("(no-of-students thous:","", ALine, fixed = T)
next
}
}
[[alternative HTML version deleted]]
More information about the R-help
mailing list