Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on PCA axis label when built using autoplot function #175

Open
xuahe opened this issue Sep 1, 2017 · 3 comments
Open

Error on PCA axis label when built using autoplot function #175

xuahe opened this issue Sep 1, 2017 · 3 comments

Comments

@xuahe
Copy link

xuahe commented Sep 1, 2017

Hi ggfortify developer,

I noticed that there're two "almost-identical" documentations on for plotting PCA.
One is here (from cran.r-project.org), one is from here(from rpubs.com).

However, the axis for PC1 and PC2 are different (for example, if you look at first plot from the documentations linked above), output from:

library(ggfortify)
df <- iris[c(1, 2, 3, 4)]
autoplot(prcomp(df))

In fact, the PC1 from prcomp(df) should be in a range between -3.2 and 3.7, so, is this a bug in the recent release (v0.4.1)?

Thank you for your time!

@terrytangyuan
Copy link
Collaborator

@lselzer Could you take a look when you get a chance to see if this is related to your changes? Thanks!

@lselzer
Copy link
Contributor

lselzer commented Feb 12, 2018

It looks like the scaling parameter is different in the two. In the Rpubs docs scaling is 0 (disabled) while in the package docs is the 1, the default. And I look at my commits and I haven't chaged the scale factor.

@terrytangyuan
Copy link
Collaborator

terrytangyuan commented Feb 12, 2018

Thanks @lselzer for the confirmation!

@nancyxuanhe I am not sure about the RPubs one. But the vignette on CRAN is always up-to-date. Could you show me what how you produced result ranging from -3.2 and 3.7? Here's my result of prcomp and the plot looks matching the one hosted on CRAN.

> prcomp(iris[c(1, 2, 3, 4)])
Standard deviations (1, .., p=4):
[1] 2.0562689 0.4926162 0.2796596 0.1543862

Rotation (n x k) = (4 x 4):
                     PC1         PC2         PC3        PC4
Sepal.Length  0.36138659 -0.65658877  0.58202985  0.3154872
Sepal.Width  -0.08452251 -0.73016143 -0.59791083 -0.3197231
Petal.Length  0.85667061  0.17337266 -0.07623608 -0.4798390
Petal.Width   0.35828920  0.07548102 -0.54583143  0.7536574

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants