Hi everybody,
I'm trying to create a script that picks a txt file with 2 columns of 
coordinates (depth and variable1) and automatically tries to fit several 
polynomial with the function nls().
After  that, it creates a list of observed, predict, residuals and other, and 
then it calculates AIC, RMSD, MAD and R^2.
At the end of the script I create a series of vectors with MAD for all 
polynomials, RMSD for all polynomial and so on, and from a matrix a .csv file.
This script is completely automatic, but there is a problem if one or more 
models don't fit, because if one or more data is missing I cannot create the 
vectors and the matrix, as well.

So, my question is: is it possible to create a vector with a missing object, 
substituting that object with NA in the vector?

For example:
I want to create this vector
Vec1<-c(MAD1,MAD2,MAD3,MAD4)
but MAD4 is missing and as a consequence R return an error like this:
"object 'MAD4' not found"

Is it possible to say to R that if it does not find an object it must 
substitute that object with NA in the vector?

Many Thanks, Fabio


Mr. Fabio Veronesi
Ph.D. student

Cranfield University, Bld.37
School of Applied Sciences
MK43 0AL
Cranfield, Bedfordshire

Tel. +44 (0)7984049316
e-mail: f.veron...@cranfield.ac.uk

        [[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