[R] Missing values in argument of .Fortran.

From: Rolf Turner <rolf_at_math.unb.ca>
Date: Mon 06 Jun 2005 - 23:52:18 EST


I wish to pass a vector ``y'', some of whose entries are NAs to a fortran subroutine which I am dynamically loading and calling by means of .Fortran(). The subroutine runs through the vector entry by entry; obviously I want to have it do one thing if y[i] is present and a different thing if it is missing.

The way I am thinking of proceeding is along the xlines of:

	ymiss <- is.na(y)
	rslt <- .Fortran(
		"foo",
		NAOK=TRUE,
		as.double(y),
		as.logical(ymiss),
		etc,
		etc
	)

and inside ``foo'' have a logical branch based on the value of xmiss(i).

Questions:

(1) Is there a sexier way to proceed? E.g. is it possible

	within (g77) fortran to detect the fact that y(i) is/was an
	NA (or not) and make the nature of y(i) the basis of an
	if-statement?


(2) Are there any lurking pitfalls in the use of the NAOK=TRUE
argument?
(3) Is there an entirely different and better way to proceed?

TIA.                         cheers,

				Rolf Turner
				rolf@math.unb.ca

P. S. I'm running R 2.0.1 under (Red Hat) Linux. (Sigh. Yes I must get around to upgrading real soon now.)

                                R. T.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 07 00:42:13 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:23 EST