Thank you for your example. I have successfully modified it with regard to most fields. However, I think that am not going to be putting this out for my students. The class I am currently teaching is in multivariate statistics (both methods and applications, with R used for computing) and I use the opportunity to provide students with experience in handling different kinds of files. From what I can tell, this file is being read in using string operations and that is not peculiar to lisp code.
Best wishes, Ranjan On Fri, 19 Jan 2018 02:38:42 +0100 Martin Møller Skarbiniks Pedersen <traxpla...@gmail.com> wrote: > 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]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > -- Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.