[R] how to save results???

Ronaldo Reis Jr. crysopa at terra.com.br
Sat Jan 20 17:32:26 CET 2001


Em Quarta 17 Janeiro 2001 19:45, Ronaldo Reis Jr. escreveu:
> Hi,
> I'm a new R's user. I am using "faq" and "An Introdution to R" to learn.
> My main problem for start the learning is: how to save my result in a
> output file?
> I has used the sink CMD or $ R > [output file], but the commands go to file
> and can't to be read in Linux Terminal. The workspace saved at the end of
> section save only commands and dont save results.
> Anybody can help-me??
> Thank you
> Inte mais
> Ronaldo

For save all commands and results in a terminal (LINUX).

script
Script started on Sat Jan 20 14:27:21 2001
[ronaldo at localhost Rwork]$ R

R : Copyright 2000, The R Development Core Team
Version 1.1.1  (August 15, 2000)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type	"?license" or "?licence" for distribution details.

R is a collaborative project with many contributors.
Type	"?contributors" for a list.

Type	"demo()" for some demos, "help()" for on-line help, or
    	"help.start()" for a HTML browser interface to help.
Type	"q()" to quit R.

[Previously saved workspace restored]

> demo() m nlm)


	demo(nlm)
	---- ~~~

Type  <Return>	 to start :

> theta <- function(x1, x2) {
    if (x1 > 0)
        return((0.5/pi) * atan(x2/x1))
    else return((0.5/pi) * atan(x2/x1) + 0.5)
}

> f <- function(x) {
    f1 <- 10 * (x[3] - 10 * theta(x[1], x[2]))
    f2 <- 10 * (sqrt(x[1]^2 + x[2]^2) - 1)
    f3 <- x[3]
    return(f1^2 + f2^2 + f3^2)
}

> x <- seq(-1, 2, len = 50)

> y <- seq(-1, 1, len = 50)

> z <- apply(as.matrix(expand.grid(x, y)), 1, function(x) f(c(x, 
    0)))


> contour(x, y, matrix(log10(z), 50, 50))

> nlm(f, c(-1, 0, 0), hessian = TRUE, print = 0)
$minimum
[1] 1.238337e-14

$estimate
[1]  1.000000e-00  3.071555e-09 -6.063119e-09

$gradient
[1] -3.756314e-07  3.486019e-06 -2.202456e-06

$hessian
              [,1]          [,2]          [,3]
[1,]  2.000000e+02   -0.04065842  9.776087e-07
[2,] -4.065842e-02  506.60589960 -3.183099e+02
[3,]  9.776087e-07 -318.30988572  2.020000e+02

$code
[1] 2

$iterations
[1] 27
..
..
..
> q()
Save workspace image? [y/n/c]: n
[ronaldo at localhost Rwork]$ exit
exit

Script concluído em Sat Jan 20 14:28:13 2001

All terminal's command will be save in a file named typescript

by
Inte mais

Ronaldo 
-- 
   //|\\   #*******************************************
  ( õ õ )  #Ronaldo Reis Júnior
     V     #ESALQ/USP - Entomologia, Caixa Postal - 09
   / l \   #13418-900 Piracicaba - SP
  /(lin)\  #Fone: 19-429-4199 r.229
 /(linux)\ #crysopa at insecta.ufv.br
/ (linux) \#crysopa at terra.com.br | ICQ#: 5692561
   ( x )   #*******************************************
   _/ \_ Powered by Conectiva Linux 6.0 D+:)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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