[R] Re: Writting R Function
Göran Broström
gb at stat.umu.se
Mon Apr 15 13:35:58 CEST 2002
On Mon, 15 Apr 2002, Ko-Kang Kevin Wang wrote:
> Hi,
>
> I think I found the problem. It lies in my Fortran program. Is there a
> way, after a DO loop, to make sure it does NOT return anything?
A DO loop in FORTRAN does not "return" anyting. I guess you have to be
more specific in formulating your question. From below I guess that you
have a WRITE (or the equivalent under R) statement in your Fortran
subroutine, which gives you the
output you want to avoid. How about removing that statement and return the
values as a vector instead?
Göran
>
> Cheers,
>
> Kevin
>
> On Mon, 15 Apr 2002, Ko-Kang Kevin Wang wrote:
>
> > Date: Mon, 15 Apr 2002 17:27:20 +1200 (NZST)
> > From: Ko-Kang Kevin Wang <kwan022 at stat1.stat.auckland.ac.nz>
> > To: R Help <r-help at stat.math.ethz.ch>
> > Subject: Writting R Function
> >
> > Hi,
> >
> > Suppose I have a function as below:
> > Fibonacci <- function(n, all = T) {
> > .Fortran("fibonacci",
> > ans = as.double(n),
> > as.character(all))$ans
> > }
> > which produces:
> > Fibonacci(10)
> > 1
> > 1
> > 2
> > 3
> > 5
> > 8
> > 13
> > 21
> > 34
> > 55
> > [1] 10
> > this is fine but I'd like to a) display in a vector format, i.e.:
> > [1] 1 1 2 3 5
> > [6] 8 13 21 34 55
> > and b) do not display the last line in the above output ([1] 55).
> >
> > Is there anyway to achieve this?
> >
> > Cheers,
> >
> > Kevin
> >
> > ------------------------------------------------------------------------------
> > Ko-Kang Kevin Wang
> > Postgraduate PGDipSci Student
> > Department of Statistics
> > University of Auckland
> > New Zealand
> >
> > Homepage: http://www.stat.auckland.ac.nz/~kwan022
> >
> > E-mail: kwan022 at stat.auckland.ac.nz
> >
> >
>
> Cheers,
>
> Kevin
>
> ------------------------------------------------------------------------------
> Ko-Kang Kevin Wang
> Postgraduate PGDipSci Student
> Department of Statistics
> University of Auckland
> New Zealand
>
> Homepage: http://www.stat.auckland.ac.nz/~kwan022
>
> E-mail: kwan022 at stat.auckland.ac.nz
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
Göran Broström tel: +46 90 786 5223
professor fax: +46 90 786 6614
Department of Statistics http://www.stat.umu.se/egna/gb/
Umeå University
SE-90187 Umeå, Sweden e-mail: gb at stat.umu.se
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list