rot.axis | R Documentation |
Returns a dataframe after rotating an X-Y dataset abot an axis(perpendicular to the screen) passing through a point, mentioned in the function argument.
rot.axis(df, pt, deg)
rot.axis(df, deg)
df |
The X-Y dataframe that needs to be rotated. |
pt |
A two element numeric vector which denotes the point around which the dataset needs to be rotated. |
deg |
Angle in degrees denoting the amnount by which the dataset needs to be rotated. |
The returned value is always a 2 column dataframe
Chitran Ghosal
library(StatsChitran)
#build a linear dataset
X <- seq(-1, 1, by = 0.01)
Y <- X
dat <- data.frame(X, Y)
#plot the linear dataset
plot(dat$X, dat$Y, type = 'l')
#rotate the linear dataset
df <- rot.axis(df = dat, pt = c(0.5, 0.5), deg = 30)
#plot the rotated dataset
lines(df$X, df$Y, col = 'red')
#legend
legend("topleft", legend = c("original", "rotated"),col = c("black", "red"), lty = 1, lwd = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.