-1

I am given the polar coordinates (r, 2sin(2t)) over [1, 10]. I need to plot this in R (the graph should look like a four leafed clover). So far, I have tried:

>t<-seq(1, 10, len=100)
>y<-2*sin(2*t)
>plot(t, y, type="n", xlab="x", ylab="y", main="Polar Graph")
>lines(t, y)

This code returns a graph of 2sin(2t), which just looks like a regular sin graph and is not what I am looking for. I am really not sure how to continue, as the only graphing experience I have with R is simple plots like the one above.

Any help would be greatly appreciated. Thanks!

  • Really? I searched this question and did not see a duplicate. Could you include the link, please? – user10136147 Jul 25 '18 at 23:44
  • The link is at the top of the post. The key is to either convert from polar to cartesian coordinates, or use `gglot` with `coord_polar` as demonstrated in the answer below. – Maurits Evers Jul 25 '18 at 23:46
  • I think the problem that I am having is that I can't seem to figure out what the x coordinate needs to be in order to correctly plot the equation. – user10136147 Jul 26 '18 at 00:03

1 Answers1

0

Perhaps you can use ggplot

library(ggplot2)
ggplot(data.frame(t, y), aes(t, y)) + geom_line() + coord_polar()

enter image description here

FKneip
  • 368
  • 3
  • 12