Dear R forum,

The example below is just an indicative one and I have constructed it. My real 
life data and conditions are different.

I have a data.frame as given below

mydat = data.frame(A = c(19, 20, 19, 19, 19, 18, 16, 18, 19, 20), B = c(19, 20, 
20, 19, 20, 18, 19, 18, 17, 16))

if (length(mydat$A) > 10)

{
stop("A has length more than 10")
}else

if (max(mydat$B) > 18)
{
stop("max B exceeds limit")
}else

{result = mydat$A + mydat$B

    if (length(result) > 0)

{
         write.csv(data.frame(result = result), 'result.csv', row.names = FALSE)
         }
}

# -----------------------------------------------------------------

When i execute above code, I get message

Error: max B exceeds limit

If all conditions are met, obviously I am getting an output as result.csv

If result.csv is generated, I am able to capture and show the output in front 
end. However, if the process couldn't be run owing to the violation of 
conditions, the error is produced. How do I capture this error (and express it 
as csv file) so that I can show it as a comment in front end. 

Kindly guide.


Katherine
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to