Hi,
I'm trying to make a function which does a lot of computational work and
visualization work.
This won't be a problem, but as things can get a lot of computational time,
I would like to print what is going on, but also instructions about what the
user should do.
A small example:
fctn <- function(data.df){
cat("Calculating linear regression \n")
data.lm <- lm(y~x,data.df)
cat("Calculating ANOVA \n")
data.aov<- aov(data.lm)
cat("Plotting graphs \n")
plot(y~x, data.df)
cat("Click on the graph to set X and Y limits \n")}
lim <- locator(n=2)
plot(y~x,data.df,ylim=sort(lim$y),xlim=sort(lim$x))
...............
}
But unfortunately R will do first the calculations and then afterwards return
the strings.
Is there a way around?
Thanks
Bart
[[alternative HTML version deleted]]
rolf at math.unb.ca
2007-Feb-18 21:04 UTC
[R] printing intermediate lines while in a function
You're using Windoze, aren't you? You didn't say.
See the Windoze-specific FAQ, 7.1.
cheers,
Rolf Turner
rolf at math.unb.ca
===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+==Original
message:
> <snip>
>
> But unfortunately R will do first the calculations and then
> afterwards return the strings.
>
> Is there a way around?
Thanks for al the tips, it was the readline() function who did the trick for me, so thanks for all of your input Kind Regards Bart Original message:> >> <snip> >> >> But unfortunately R will do first the calculations and then >> afterwards return the strings. >> >> Is there a way around? >