- Launch R and open a new script by selecting File and then New script.
- In the R Editor window, enter the following code and make sure to replace all of the file paths with the paths leading to the appropriate locations on your device. After pasting the paths, make sure to replace the backslashes with double backslashes, as seen in the following code:
pt <-read.table ("C:\\Users\\Slaven\\Desktop\\personality_ traits.csv", header=T, sep=",")pt.pc <- prcomp(pt, scale = TRUE)X1 <- pt.pc$x [, 1]X2 <- pt.pc$x [, 2]X3 <- pt.pc$x [, 3]X4 <- pt.pc$x [, 4]X5 <- pt.pc$x [, 5]scores <- cbind(pt, X1, X2, X3, X4, X5) colnames(scores) <- "X1"colnames(scores) <- "X2"colnames(scores) <- "X3"colnames(scores) <- "X4"colnames(scores) ...
Get Tableau 2019.x Cookbook now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.