I intend to see data points distribution (each reows) within labeled groups (different batchs such as 1,2,3, and so on) in 3D scatter plot, because I want to see the distribution of the data points and want to see how similar each group of data points in 3D space. To do so, I used scatterplot3d
package from CRAN to get 3D scatter plot, didn't get correct plot for my data.
reproducible data:
Here is the reproducible data that simulated from the original dataset.
persons_df <- data.frame(ID= LETTERS[1:20], ages=sample(1:50,20, replace = FALSE),
batch=c(rep(1,5), rep(2,6),rep(3,4),rep(4,5)),
platform=c(rep("CATH",12), rep("ANN",8)))
basically, I want to render 3D plot for the data points that belongs to the same batch with the same color (1 is red, 2 is blue, 3 is green, 4 is yellow).
this was my attempt to render PCA plot
require(scatterplot3d)
par(mar=c(4,4,4,4), cex=1.0, cex.main=0.8, cex.axis=0.8)
scatterplot3d(persons_df$batch)
but above code doesn't work because first I should group data points that belongs to different batches then render them in 3D space. This is not very intuitive to me how to do it in R? Any idea to render possible 3D scatter plot for my data? any thought?
desired 3D plot:
I want 3D plot something like this:
how can I make this happen? any idea to get this done?
prcomp(iris[, -5])
is performing PCA on sepal length, sepal width, petal length, and petal width. So we have 4 dimensions here. In your reproducible example, you only have two dimensions to look at, Age and Batch. Number of dimensions aside, I think you are missing the useful data on which it would be useful to apply PCA. This is just metadata. $\endgroup$