[R] Behavior different inside function?

Stuart Luppescu s-luppescu at uchicago.edu
Mon Mar 27 22:56:23 CEST 2000


I'm stumped with this. When I execute the lines in the function singly, they
run fine, but when I run the function, I get this error on the read.table()
line:
Error in count.fields(file, sep, quote, skip) : 
        can't open file fspci1.dat

Can anyone tell my why this should be so? Here is the program:

library(rpart)

wait <- function(str="Press a key when ready...")
 readline(str)

doit <- function (fn=" ", sesnum, tit=" ", fm=" ") {
  dsn <- paste(fn, sesnum, ".dat", sep="", collapse=NULL)
  psn <- paste(fn, sesnum, ".ps", sep="", collapse=NULL)
  fm1 <- as.formula(fm)
  ds <- read.table(file=dsn, header=T)
  rownames(ds) <- ds$unit
  nmavgres <- ds$mavgres * 1000
  nravgres <- ds$ravgres * 1000
  ds.mrpt <- rpart(formula=fm1, data=ds, control=rpart.control(minbucket=20))
  plot(prune(ds.mrpt, cp=0.018))
  text(prune(ds.mrpt, cp=0.018), digits=2)
  wait()
  plotcp(ds.mrpt)
  wait()
  post.rpart(prune(ds.mrpt, cp=0.018),
             title=c(tit, paste("SES Quartile", sesnum, sep=" ",
collapse=NULL)), pretty=0,
             filename=psn, horizontal=F, height=9, digits=3, pointsize=10)
}

doit("fspci", 1, "Parent Involvement (S)", "nmavgres ~ sbpisc97 + sbpsup97 +
sbigcl97 + sbpars97")
           
I'm running R 1.0.0 on Linux (intel). Thanks.
______________________________________________________________________
Stuart Luppescu         -=-=-  University of Chicago
$(B:MJ8$HCRF`H~$NIc(B        -=-=-  s-luppescu at uchicago.edu
http://www.consortium-chicago.org/people/sl/sl.html
ICQ #21172047  AIM: psycho7070
"The chain which can be yanked is not the eternal chain."
-- G. Fitch
>> Sent on 27-Mar-00 at 14:46:49 with xfmail
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list