Sorry about that. Still new to this... The code below should be
reproducible. All R2 should just be 1, and I should write 1 to
R2outputKKNN.txt 10 times....nothing is happening. Appreciate the efforts
to help!
for (i in 1:10)
{
adata = 1:5
bdata = 6:10
lm <- lm(adata~bdata)
slm <- summary(lm)
str(slm)
if (i == 1) {
previousR2 <-slm$r.squared
sink(file="R2outputKKNN.txt", append=TRUE)
previousR2
sink() } else if(i!=1)
{
currentR2 <- slm$r.squared
if (previousR2 > currentR2)
{
currentR2 <- previousR2
}
if (previousR2 < currentR2) {
sink(file="R2outputKKNN.txt", append=TRUE)
currentR2
sink()
}
}
}
--
View this message in context:
http://r.789695.n4.nabble.com/Help-with-Sink-Function-tp2291705p2291717.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
[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.