[R] Drawing Trig Function

Ko-Kang Wang Ko-Kang at xtra.co.nz
Tue May 30 22:40:00 CEST 2000


Hi there,

Two simple questions:

1) How do I comment out several lines in R?  Do I need to type # in the
beginning of each line?
2) I have got a few lines of codes that draws sin, cos and tan
(supposedly) below.  My codes can draw sin() and cos() perfectly fine,
but when it comes to tan(), the last part which I have commentted out, I
have problem.  It does not draw what it's supposed to do.

Thanks...

Ko-Kang

layout.my <- function (m, n) {
    par(mfrow = c(m, n))
}

x <- 0:12566 / 1000   # Range from 0 to 4*pi

layout.my( 1, 2 )
plot( sin(x), type = "l",
      xaxs = "i", yaxs = "i", axes = F,
      xlab = "x", ylab = "sin(x)",
      main = "Y = sin(x), x = [ 0, 720 ]"
    )
axis( 2, at = seq( -1, 1, by=1 ),las = 2 )
box(lty="dotted")
abline( h = 0, lwd = 1 )

plot( cos(x), type = "l",
      xaxs = "i", yaxs = "i", axes = F,
      xlab = "x", ylab = "cos(x)",
      main = "Y = cos(x), x = [ 0, 720 ]"
    )
axis( 2, at = seq( -1, 1, by=1 ),las = 2 )
box(lty="dotted")
abline( h = 0, lwd = 1 )

#plot( tan(x), type = "l",
#      xaxs = "i", yaxs = "i", axes = F,
#      xlab = "x", ylab = "tan(x)",
#      main = "Y = sin(x), x = [ 0, 360 ]"
#    )
#axis( 2, at = seq( -1, 1, by=1 ),las = 2 )
#box(lty="dotted")
#abline( h = 0, lwd = 1 )

--
-----------------------------------------------------------------------------------

 Ko-Kang Wang
 Undergraduate Student
 Computer Science/Statistics Double Major
 University of Auckland
 Auckland 1005
 New Zealand
-----------------------------------------------------------------------------------



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