Font Family Not Found in Windows Font Database

Prinicpal Component Analysis

I am setting upwardly a notebook for how to run principal component analyses. PCA techniques are very useful for data exploration when the dataset is 'wide', there are a lot of columns for the amount of rows of datapoints. A PCA looks for correlations amid the columns by searching for vectors (eigenvectors) that correlate stongly with the data in the columns (high eigenvalues). By searchinig for this eigenvectors with high eigenvalues we tin hopefully reduce the dimensionality of the dataset.

  • Information Sources:

    • Datacamp.com Intro to PCA
    • Stanford Multivariate analysis in R
    • Footling book of R Using R for Multivariate Assay
    • Richard Lent Tutorial on Multivariate Analysis
    • Principal Component Methods in R: Applied Guide
      • using the factoextra package
      • see Shiny awarding Factoshiny

PCA is a type of linear transformation on a given data set that has values for a sure number of variables (coordinates) for a sure amount of spaces. This linear transformation fits this dataset to a new coordinate system in such a way that the most significant variance is found on the first coordinate, and each subsequent coordinate is orthogonal to the final and has a lesser variance. In this style, you transform a gear up of x correlated variables over y samples to a prepare of p uncorrelated principal components over the same samples.

Where many variables correlate with one another, they will all contribute strongly to the same primary component. Each principal component sums upwardly a certain percentage of the total variation in the dataset. Where your initial variables are strongly correlated with one another, you will be able to gauge most of the complexity in your dataset with just a few principal components. As you lot add more than master components, you summarize more and more than of the original dataset. Adding boosted components makes your estimate of the total dataset more than accurate, but also more unwieldy.

Simply put, an eigenvector is a direction, such as "vertical" or "45 degrees", while an eigenvalue is a number telling you how much variance there is in the data in that direction. The eigenvector with the highest eigenvalue is, therefore, the kickoff principal component.

Standardising Variables

If y'all want to compare unlike variables that have different units, are very different variances, it is a good idea to showtime standardise the variables.

Yet, whether you want to standardise or not depends on the question you are asking, run across this stack exchange discussion

If variables are not standardised the get-go primary component will exist dominated by variables which prove the largest variance.

  • Why is the default to rescale the data?

You tend to utilize the covariance matrix when the variable scales are similar and the correlation matrix when variables are on different scales.

Using the correlation matrix is equivalent to standardizing each of the variables (to mean 0 and standard difference 1)

Call back the difference between correlation and covariance. In correlation you rescale past dividing by the norm of each dimension. This is more than in line with what nosotros're interested in. If one of our variable is measured in inches so nosotros decide to change that measurement to feet, the variance decreases by a cistron of \(12^{-2}\). We don't desire the result of our PCA to alter based on the units a dimension is measured in. To avoid problems similar this, we rescale our data and so that each dimension has variance 1.

Thus, it would be a improve thought to first standardise the variables so that they all have variance one and hateful 0, and to and so carry out the main component analysis on the standardised data. This would allow us to find the principal components that provide the best low-dimensional representation of the variation in the original data, without being overly biased by those variables that show the virtually variance in the original data.

You can standardise variables in R using the scale() function.

For example, to standardise the values of the 18 soil variables at each site, we type: standardisedvalues <- as.information.frame(scale(T.18[1:eighteen]))

Annotation that we utilise the as.information.frame() function to catechumen the output of scale() into a data frame, which is the same type of R variable that the T.eighteen variable.

Nosotros can check that each of the standardised variables stored in standardisedvalues has a mean of 0 and a standard difference of ane by typing:

            #sapply(standardisedvalues,hateful) #       V2            V3            V4            V5            V6            V7 #  -eight.591766e-16 -6.776446e-17  8.045176e-sixteen -vii.720494e-17 -iv.073935e-17 -1.395560e-17 #       V8            V9           V10           V11           V12           V13 #  half dozen.958263e-17 -1.042186e-16 -one.221369e-16  three.649376e-17  2.093741e-16  iii.003459e-16 #      V14 #  -1.034429e-xvi #sapply(standardisedvalues,sd) #  V2  V3  V4  V5  V6  V7  V8  V9 V10 V11 V12 V13 V14 #  ane   1   i   1   i   1   1   1   ane   1   1   1   1          

We encounter that the means of the standardised variables are all very tiny numbers so are essentially equal to 0, and the standard deviations of the standardised variables are all equal to one.

  • Why is the default to center?

Suppose that we did non center. We can relate PCA to directions with highest covariance. When we calculate sample covariance, we subtract the mean from each observation. If nosotros skip this stride (not centering), so the starting time centrality of the PCA would ever exist pointing towards the center of mass.

Some functions in R that calculate the PCA do not eye past default. In that location might be a good reason to not center (e.g., you lot centered a large dataset already and you are only looking at a subsample), but in general, you lot should always heart your data when doing a PCA.

Constructing a PCA

The prcomp package contains an arguement scale which scales the variables used in a PCA, so it is not necessary to manually scale as above.

Loading information, selecting columns to include in PCA and running a scaled and centred PCA.

            Env_18 <- read.csv("C:/Users/Cian/Documents/PhD/Data/Meggis Information/Env_18.csv")  colnames(Env_18)[1] <- "Param"  for(i in 1:18){ rownames(Env_18)[i] <- every bit.character(droplevels(Env_18$Param[i])) }  Env_18 <- Env_18[,-1]   #str(Env_18)   Env.18.pca <- prcomp(Env_18, eye = Truthful, scale. = TRUE)  #summary(Env.xviii.pca)  #str(Env.18.pca)  #Transposing the data and then we are looking at correlation between the soil characteristics themselves and not correleations among the sites. T.xviii <- as.data.frame(t(Env_18)) T.18.pca <- prcomp(T.18, center = Truthful, calibration. = Truthful) #summary(T.18.pca)          
  • the heart, scaling, standard deviation of each principal component.
            $centre, $scale, $sdev          
  • The relationship (correlation or anticorrelation, etc) betwixt the initial variables and the principal components
            $rotation          
  • The values of each sample in terms of the main components
            $x          

Theory Behind PCA Results

This code will calculate the PCA results for variables (i.east. columns): coordinates, cos2, and contributions

  • var.coord = loadings * the component standard deviations
  • var.cos2 = var.coord^ii
  • var.contrib. The contribution of a variable to a given principal component is (in pct) : (var.cos2 * 100) / (total cos2 of the component)
            #helper function  var_coord_func <- function(loadings, comp.sdev){   loadings*comp.sdev }  # Compute Coordinates  loadings <- T.eighteen.pca$rotation sdev <- T.xviii.pca$sdev var.coord <- t(apply(loadings, MARGIN = 1, var_coord_func, sdev))  head(var.coord[, ane:4])          
            ##                 PC1        PC2         PC3         PC4 ## m_gv      0.1112659 -0.8397329 -0.27438780 -0.02808150 ## m_pH_H2O -0.3770343  0.3365268 -0.78532581 -0.02319610 ## m_pH_Ca  -0.3978461  0.1885975 -0.73551774 -0.08737664 ## m_CN      0.1787622 -0.6555604  0.60132147  0.15584940 ## m_Cl     -0.4319542 -0.3695436 -0.07478097  0.57131811 ## m_NO3     0.2612686 -0.5962655 -0.49718902 -0.44795962          
            #compute Cos2 (the variable components squared), or quality of representation on given dimension var.cos2 <- var.coord^2 head(var.cos2[, 1:4])          
            ##                 PC1        PC2         PC3          PC4 ## m_gv     0.01238009 0.70515135 0.075288662 0.0007885708 ## m_pH_H2O 0.14215486 0.11325025 0.616736633 0.0005380592 ## m_pH_Ca  0.15828153 0.03556902 0.540986346 0.0076346773 ## m_CN     0.03195592 0.42975950 0.361587515 0.0242890340 ## m_Cl     0.18658447 0.13656246 0.005592193 0.3264043823 ## m_NO3    0.06826130 0.35553253 0.247196926 0.2006678208          
            #Compute contributions comp.cos2 <- apply(var.cos2, MARGIN = 2, FUN = sum) contrib <- function(var.cos2, comp.cos2){var.cos2*100/comp.cos2} var.contrib <- t(employ(var.cos2, MARGIN = 1, contrib, comp.cos2)) head(var.contrib[, 1:4])          
            ##                PC1        PC2        PC3         PC4 ## m_gv     0.2028662 17.8681349  2.2542900  0.06399317 ## m_pH_H2O 2.3294185  ii.8696972 18.4663026  0.04366394 ## m_pH_Ca  2.5936781  0.9012987 16.1981906  0.61956032 ## m_CN     0.5236453 10.8898617 10.8266383  1.97107503 ## m_Cl     3.0574637  iii.4604153  0.1674412 26.48798338 ## m_NO3    1.1185629  9.0089924  7.4015601 xvi.28435827          

This code will calculate PCA results for individuals (i.east. rows)

  • ind.coord = res.pca$ten
  • Cos2 of individuals. Two steps:
    • Calculate the square altitude between each individual and the PCA center of gravity: d2 = [(var1_ind_i - mean_var1)/sd_var1]^2 + …+ [(var10_ind_i - mean_var10)/sd_var10]^two + …+..
    • Summate the cos2 every bit ind.coord^2/d2
  • Contributions of individuals to the primary components: 100 * (1 / number_of_individuals)*(ind.coord^ii / comp_sdev^2). Note that the sum of all the contributions per cavalcade is 100
            # Coordinates of individuals #:::::::::::::::::::::::::::::::::: ind.coord <- T.18.pca$x head(ind.coord[, 1:4])          
            ##          PC1        PC2         PC3        PC4 ## aa  ane.843619  0.6984034  1.39085931  0.8521719 ## ab  1.499047  3.3314063 -0.13836903 -0.4757199 ## ac  2.438382  ii.3485011 -0.11155408 -ane.0069934 ## ba -4.068176  0.4089068  0.67238375 -1.3135724 ## bb -4.251161  0.8734186  0.05115095 -0.9593515 ## bc -4.245708 -0.4283674  0.01116178 -0.5839797          
            # Cos2 of individuals #::::::::::::::::::::::::::::::::: # 1. square of the distance between an private and the # PCA center of gravity center <- T.xviii.pca$eye scale<- T.18.pca$calibration getdistance <- function(ind_row, centre, scale){   return(sum(((ind_row-center)/scale)^ii))   } d2 <- apply(T.18,1,getdistance, center, scale) # 2. Compute the cos2. The sum of each row is ane cos2 <- function(ind.coord, d2){render(ind.coord^ii/d2)} ind.cos2 <- apply(ind.coord, 2, cos2, d2) caput(ind.cos2[, ane:4])          
            ##          PC1         PC2          PC3        PC4 ## aa 0.3221090 0.046224592 1.833272e-01 0.06882002 ## ab 0.1444967 0.713645955 one.231134e-03 0.01455225 ## air-conditioning 0.3631827 0.336901791 7.601385e-04 0.06194055 ## ba 0.8227422 0.008312142 two.247494e-02 0.08577727 ## bb 0.8706902 0.036753047 1.260538e-04 0.04434085 ## bc 0.9101629 0.009265135 vi.290511e-06 0.01721926          
            # Contributions of individuals #::::::::::::::::::::::::::::::: contrib <- function(ind.coord, comp.sdev, northward.ind){   100*(one/n.ind)*ind.coord^2/comp.sdev^two } ind.contrib <- t(utilise(ind.coord, i, contrib,                         T.18.pca$sdev, nrow(ind.coord))) caput(ind.contrib[, 1:4])          
            ##          PC1        PC2          PC3      PC4 ## aa  3.094253  0.6866526 3.2179115510 iii.273971 ## ab  two.045708 15.6235453 0.0318482443 1.020288 ## air conditioning  five.412734  7.7643643 0.0207003940 iv.571658 ## ba fifteen.066517  0.2353819 0.7520420308 seven.779083 ## bb 16.452371  ane.0739134 0.0043522633 4.149311 ## bc 16.410186  0.2583195 0.0002072405 1.537503          

PCA Visualisation

At present it's fourth dimension to plot the PCA.

we will start look at a parcel ggbiplot.

Y'all will make a biplot, which includes both the position of each sample in terms of PC1 and PC2 and also will show you how the initial variables map onto this. You will use the ggbiplot package, which offers a user-friendly and pretty function to plot biplots. A biplot is a blazon of plot that will let you to visualize how the samples chronicle to one another in our PCA (which samples are similar and which are different) and will simultaneously reveal how each variable contributes to each principal component.

            library(devtools)          
            ## Loading required package: usethis          
            #install_github("vqv/ggbiplot")  library(ggbiplot)          
            ## Loading required package: ggplot2          
            ## Loading required package: plyr          
            ## Loading required parcel: scales          
            ## Loading required parcel: filigree          
            library(ggalt)          
            ## Warning: packet 'ggalt' was built nether R version three.6.iii          
            ## Registered S3 methods overwritten by 'ggalt': ##   method                  from    ##   grid.draw.absoluteGrob  ggplot2 ##   grobHeight.absoluteGrob ggplot2 ##   grobWidth.absoluteGrob  ggplot2 ##   grobX.absoluteGrob      ggplot2 ##   grobY.absoluteGrob      ggplot2          
            library(ggforce)          
            ## Warning: package 'ggforce' was built nether R version three.6.3          
            ggbiplot(Env.18.pca)          

            ggbiplot(T.18.pca)          

            #lets add in rownames then that we tin run across the identity of the points plotted. ggbiplot(Env.18.pca, labels=rownames(Env_18))          

            ggbiplot(T.xviii.pca, labels=rownames(T.xviii))          

Many other packages be for plotting PCAs. Another suite of packages are the facto package family, which again works off the ggplot functionality

            library(factoextra)          
            ## Alert: package 'factoextra' was built under R version 3.6.3          
            ## Welcome! Desire to learn more? See two factoextra-related books at https://goo.gl/ve3WBa          
            #scree plot fviz_eig(T.18.pca)          

            #individuals (rows) fviz_pca_ind(T.18.pca,              col.ind = "cos2", # Color by the quality of representation              gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),              repel = True     # Avoid text overlapping              )          

            #variables (columns) fviz_pca_var(T.eighteen.pca,              col.var = "contrib", # Color by contributions to the PC              gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),              repel = Truthful     # Avoid text overlapping              )          

            #biplot fviz_pca_biplot(T.18.pca, repel = TRUE,                 col.var = "#2E9FDF", # Variables color                 col.ind = "#696969"  # Individuals color                 )          

            library(Factoshiny)          
            ## Warning: bundle 'Factoshiny' was built under R version 3.6.iii          
            ## Loading required package: FactoMineR          
            ## Warning: package 'FactoMineR' was built under R version iii.6.3          
            ## Loading required parcel: shiny          
            ## Loading required package: FactoInvestigate          
            ## Warning: parcel 'FactoInvestigate' was built under R version 3.vi.3          
            #result <- Factoshiny(T.xviii)          

Supplementary Variables

Qualitative / categorical variables

Qualitative / chiselled variables tin be used to color individuals (rows) by groups. The grouping variable should exist of same length every bit the number of agile individuals

Code for extracting data from Factoextra parcel on PCA results

            library(factoextra) # Eigenvalues eig.val <- get_eigenvalue(T.18.pca) eig.val          
            # Results for Variables (i.eastward. columns) res.var <- get_pca_var(T.18.pca) #res.var$coord          # Coordinates #res.var$contrib        # Contributions to the PCs #res.var$cos2           # Quality of representation  # Results for individuals (i.e rows) res.ind <- get_pca_ind(T.18.pca) #res.ind$coord          # Coordinates #res.ind$contrib        # Contributions to the PCs #res.ind$cos2           # Quality of representation                      

Deciding how many principal components to retain

In guild to make up one's mind how many principal components should be retained, it is mutual to summarise the results of a chief components analysis by making a scree plot, which we can do in R using the screeplot() function:

            T.18.pca <- prcomp(T.18, center = Truthful, scale. = Truthful) screeplot(T.18.pca, type="lines")          

The most obvious change in slope in the scree plot occurs at component iv, which is the "elbow" of the scree plot. Therefore, it cound exist argued based on the basis of the scree plot that the first iii components should be retained.

Another fashion of deciding how many components to retain is to employ Kaiser's criterion: that we should only retain main components for which the variance is higher up i (when principal component assay was practical to standardised information). We can check this past finding the variance of each of the main components:

            (T.xviii.pca$sdev)^two          
            ##  [1] 6.102590e+00 3.946418e+00 3.339795e+00 1.232273e+00 9.323371e-01 ##  [6] 7.314076e-01 6.372587e-01 3.753322e-01 3.178664e-01 1.847776e-01 ## [11] 7.417828e-02 6.980869e-02 3.720730e-02 i.241689e-02 3.706036e-03 ## [16] 2.339936e-03 ii.868659e-04 1.028193e-32          

We come across that the variance is above 1 for chief components 1, 2, 3 and 4 (which have variances 6.ten, iii.95, iii.34, and 1.23 respectively). Therefore, using Kaiser's criterion, we would retain the offset four principal components.

A third style to decide how many principal components to retain is to decide to continue the number of components required to explain at least some minimum corporeality of the total variance. For example, if information technology is important to explain at least 80% of the variance, nosotros would retain the showtime four principal components, equally we can see from the output of summary(T.18.pca) that the first four principal components explain 81.ii% of the variance (while the first three components explain just 74.4%, then are non sufficient).

            summary(T.eighteen.pca)          
            ## Importance of components: ##                          PC1    PC2    PC3     PC4    PC5     PC6    PC7 ## Standard difference     two.470 one.9866 1.8275 1.11008 0.9656 0.85522 0.7983 ## Proportion of Variance 0.339 0.2192 0.1855 0.06846 0.0518 0.04063 0.0354 ## Cumulative Proportion  0.339 0.5583 0.7438 0.81228 0.8641 0.90471 0.9401 ##                            PC8     PC9    PC10    PC11    PC12    PC13    PC14 ## Standard departure     0.61264 0.56380 0.42986 0.27236 0.26421 0.19289 0.11143 ## Proportion of Variance 0.02085 0.01766 0.01027 0.00412 0.00388 0.00207 0.00069 ## Cumulative Proportion  0.96097 0.97863 0.98889 0.99301 0.99689 0.99896 0.99965 ##                           PC15    PC16    PC17      PC18 ## Standard deviation     0.06088 0.04837 0.01694 1.014e-sixteen ## Proportion of Variance 0.00021 0.00013 0.00002 0.000e+00 ## Cumulative Proportion  0.99985 0.99998 i.00000 1.000e+00          

Interpreting the Results

At present, we tin can group our variables and see whether groups occupy a similar infinite in PCA space, indicating that they are correlated with each other. We do this using the groups statement in ggbiplot

            #creating groups, turning ellipses on T.eighteen.pca <- prcomp(T.xviii, center = TRUE, scale. = True) site.groups <- c(rep("a", 3), rep("b", 3),rep("c", 3),rep("d", 3),rep("e", 3),rep("f", 3)) ggbiplot(T.18.pca, labels=rownames(T.18), groups = site.groups, ellipse = Truthful)          

            #looking at the other PCA axes ggbiplot(T.18.pca, labels=rownames(T.18), groups = site.groups, ellipse = True, choices = c(three,4))          

illustrates that axis three is useful for pulling out groups, such as f, and so should include the start three axes every bit they contain alot of variation.

Graphical parameters with ggbiplot

Are as well othe variables that can be used to alter the biplots. * Tin add together a circle to the eye of the dataset * Can scale the sampples (obs.scale) and the variables (var.scale) * Can remove the arrows altogether using var.axes

            T.18.pca <- prcomp(T.18, center = TRUE, scale. = TRUE) ggbiplot(T.18.pca, labels=rownames(T.18), groups = site.groups, ellipse = Truthful, circle = TRUE)          

            ggbiplot(T.18.pca, labels=rownames(T.eighteen), groups = site.groups, ellipse = True, obs.scale = 1, var.calibration = 1)          

            ggbiplot(T.18.pca, labels=rownames(T.18), groups = site.groups, obs.scale = 1, var.scale = 1, var.axes=False ) +   theme_bw() +   geom_mark_hull(concavity = 5, expand = 0, radius = 0, aes(fill=site.groups))          

Every bit ggbiplot is based on the ggplot office, y'all can use the aforementioned set of graphical parameters to change the biplots equally y'all would for any ggplot.

  • Specify colours to use for the groups with scale_colour_manual()
  • Add a championship with ggtitle()
  • Specify the minimal() theme, or other themes
  • Movement the legend with theme()

Multivariate Packages

So far I been using the base stats package for conducting PCA. But there are other packagaes out there that are design to facilitate a suite of multivariate analysis. ade4 is such a package.

Using the bundle ade4 for multivariate assay rather than base stats package. Combining with scree plots and comparing the ade4 plotting functions to customised plotting using ggplot universe of packages

            library(ade4) # multivariate assay          
            ##  ## Attaching package: 'ade4'          
            ## The post-obit object is masked from 'package:FactoMineR': ##  ##     reconst          
            T.eighteen.pca <- dudi.pca(T.eighteen, scannf = F, nf = 8)  #The $co is the coordinates of variables in PCA infinite. Equivalent to loadings*sdev as calculated in theory section above for prcomp. #The $li represent to the individual, or row, cooridinates  scatter(T.18.pca)          

Setting up libraries, and basic plot themes

            library(grid) # has the viewport function, needed for insetting the scree plot library(ggpubr) #for making publication ready plots          
            ## Warning: package 'ggpubr' was congenital under R version iii.vi.3          
            ## Loading required package: magrittr          
            ##  ## Attaching parcel: 'ggpubr'          
            ## The following object is masked from 'parcel:plyr': ##  ##     mutate          
            library(ggforce) #for some nice polygons geoms library(ggalt) #contains some extra geoms library(viridis) #some prissy colour palettes          
            ## Warning: bundle 'viridis' was built under R version three.half-dozen.3          
            ## Loading required package: viridisLite          
            ##  ## Attaching package: 'viridis'          
            ## The following object is masked from 'package:scales': ##  ##     viridis_pal          
            library(hrbrthemes) #some nice themes for ggplot          
            ## Alert: package 'hrbrthemes' was congenital under R version iii.6.3          
            ## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.          
            ##       Please utilise hrbrthemes::import_roboto_condensed() to install Roboto Condensed and          
            ##       if Arial Narrow is not on your organization, please see http://bit.ly/arialnarrow          
            ### fix a plot we'll use later ppp <- ggplot() +   coord_fixed() +    labs(10= paste("PCA 1 " , "(", circular((T.18.pca$eig[1] / sum(T.18.pca$eig))*100, 1), "% explained var" , ")", sep = ""),        y= paste("PCA 2 " , "(", round((T.18.pca$eig[ii] / sum(T.eighteen.pca$eig))*100, ane), "% explained var" , ")", sep = "")) +      geom_hline(yintercept=0, col="darkgrey") +       geom_vline(xintercept=0, col="darkgrey") +      guides(size=guide_legend(title="PCA 3 (18.6%)")) +      geom_segment(data =T.18.pca$co,                x=0, y=0,                xend = 2.5*T.18.pca$co[,1], yend = 2.5*T.eighteen.pca$co[,2],                arrow =  arrow(angle = xxx,length = unit(0.25, "cm"),                               ends = "final", type = "open"),                blastoff=0.4) +   scale_color_viridis(discrete=TRUE, guide=Imitation) +     theme_ipsum()     # make the scree plot in a viewport myscree <- part(eigs, x=0.viii, y=0.i, only=c("left","centre")){   vp <- viewport(x=ten, y=y, width=0.two, tiptop=0.2, just=only)   information <- as.information.frame(cbind(factor(1:length(eigs)), eigs))   sp <- ggplot() +     geom_col(aes(x=V1, y=eigs), data = data, position = "stack") +       labs(ten = NULL, y = Zilch, title = "Scree Plot") +     theme(championship = element_text(size = half-dozen))   print(sp, vp=vp) }          

Plotting using geom_mark_ellipse() function in the ggforce package

            #set up grouping factor for colour, grouping past sites and calculation to dataframe T.18.pca$li[,1+dim(T.xviii.pca$li)[two]]=site.groups  #creating a named logical vector for what legends to display. Want the size fable but non sites. leg <- as.logical(c(ane,0)) names(leg) <- c("size", "col")  ppp +    geom_point(data=T.18.pca$li,              aes(x=Axis1,                  y=Axis2,                  size=Axis3,                  col=T.18.pca$li[,dim(T.18.pca$li)[2]]),#colouring based off grouping factor              evidence.legend = leg) +       scale_color_viridis(discrete=True, guide=Simulated) +      guides(size=guide_legend(championship="PCA 3 (eighteen.6%)")) +      geom_text(data=T.18.pca$co,             aes(x=2.v*Comp1,                 y=2.5*Comp2,                 label=(colnames(T.18))),             size = 2, alpha=0.4) +      geom_mark_ellipse(data =T.xviii.pca$li, aes(x=Axis1, y=Axis2,                                              group=T.18.pca$li[,dim(T.18.pca$li)[2]],                                            fill=T.18.pca$li[,dim(T.eighteen.pca$li)[2]]),                     alpha=0.4, expand=0) +      scale_fill_viridis(discrete=Truthful, guide=Faux) +      guides(fill up=guide_legend(title="Sites"))          
            ## Scale for 'colour' is already present. Adding another scale for 'color', ## which will replace the existing scale.          
            ## Warning in filigree.Phone call(C_stringMetric, as.graphicsAnnot(x$characterization)): font family not ## institute in Windows font database  ## Alarm in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family non ## found in Windows font database          
            ## Warning in grid.Call(C_textBounds, every bit.graphicsAnnot(x$label), x$x, 10$y, : font ## family unit not found in Windows font database          
            ## Alert in grid.Telephone call(C_stringMetric, every bit.graphicsAnnot(ten$characterization)): font family not ## found in Windows font database          
            ## Alert in filigree.Telephone call(C_textBounds, every bit.graphicsAnnot(ten$characterization), x$x, x$y, : font ## family not found in Windows font database  ## Warning in filigree.Phone call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font ## family not found in Windows font database  ## Warning in grid.Call(C_textBounds, every bit.graphicsAnnot(x$characterization), x$ten, x$y, : font ## family non plant in Windows font database  ## Warning in grid.Telephone call(C_textBounds, as.graphicsAnnot(x$characterization), ten$ten, x$y, : font ## family non constitute in Windows font database  ## Alert in filigree.Call(C_textBounds, as.graphicsAnnot(x$label), ten$10, x$y, : font ## family unit not constitute in Windows font database  ## Warning in grid.Call(C_textBounds, equally.graphicsAnnot(ten$label), 10$ten, x$y, : font ## family not plant in Windows font database  ## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), 10$x, ten$y, : font ## family unit not found in Windows font database  ## Alert in grid.Telephone call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font ## family not found in Windows font database  ## Alert in grid.Call(C_textBounds, every bit.graphicsAnnot(x$label), 10$x, 10$y, : font ## family non found in Windows font database          
            ## Alarm in grid.Call.graphics(C_text, equally.graphicsAnnot(x$label), x$x, ten$y, : ## font family non found in Windows font database          
            ## Alarm in grid.Telephone call(C_textBounds, as.graphicsAnnot(x$label), ten$x, x$y, : font ## family non institute in Windows font database  ## Warning in grid.Call(C_textBounds, every bit.graphicsAnnot(x$characterization), ten$x, ten$y, : font ## family non plant in Windows font database  ## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$characterization), x$x, ten$y, : font ## family not establish in Windows font database  ## Warning in filigree.Call(C_textBounds, as.graphicsAnnot(x$characterization), x$10, x$y, : font ## family non institute in Windows font database          
            myscree(T.18.pca$eig / sum(T.18.pca$eig))          

            #tin place labels whereever on the plot with this function, only it doesn't stay relative when size of plotting device changes #filigree.text(label = "text", x=0.83, y=0.75, rot=270, gp=gpar(fontsize=8, col="black"))          

Plotting using geom_encircle() part in the ggalt parcel

            ppp +    geom_point(data=T.18.pca$li,              aes(x=Axis1,                  y=Axis2,                  size=Axis3,                  col=T.18.pca$li[,dim(T.18.pca$li)[2]]),              show.legend = leg) +      guides(size=guide_legend(championship="PCA 3 (18.half-dozen%)")) +      geom_text(information=T.18.pca$co,             aes(x=two.v*Comp1,                 y=2.5*Comp2,                 label=(colnames(T.18))),             size = 2, alpha=0.4) +      geom_encircle(data =T.18.pca$li, aes(x=Axis1, y=Axis2,                                              group=T.18.pca$li[,dim(T.18.pca$li)[ii]],                                            fill=T.18.pca$li[,dim(T.18.pca$li)[2]]),                     alpha=0.4, expand=0) +      scale_fill_viridis(discrete=True, guide=Imitation) +      guides(fill up=guide_legend(title="Sites"))          
            ## Alert in filigree.Call(C_textBounds, every bit.graphicsAnnot(x$label), x$x, x$y, : font ## family unit non plant in Windows font database  ## Warning in filigree.Call(C_textBounds, as.graphicsAnnot(10$characterization), 10$x, 10$y, : font ## family non establish in Windows font database  ## Alarm in grid.Call(C_textBounds, as.graphicsAnnot(ten$label), x$ten, x$y, : font ## family not constitute in Windows font database  ## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), ten$x, x$y, : font ## family non found in Windows font database  ## Alert in grid.Phone call(C_textBounds, as.graphicsAnnot(10$label), x$x, 10$y, : font ## family unit not institute in Windows font database  ## Alarm in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, ten$y, : font ## family not found in Windows font database  ## Alarm in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font ## family not establish in Windows font database  ## Warning in filigree.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font ## family not institute in Windows font database  ## Alarm in grid.Phone call(C_textBounds, as.graphicsAnnot(ten$label), 10$x, x$y, : font ## family not found in Windows font database  ## Warning in grid.Call(C_textBounds, as.graphicsAnnot(10$label), x$ten, x$y, : font ## family not plant in Windows font database  ## Warning in grid.Telephone call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font ## family not found in Windows font database          
            ## Warning in filigree.Telephone call.graphics(C_text, equally.graphicsAnnot(x$label), x$10, x$y, : ## font family not found in Windows font database          
            ## Warning in grid.Call(C_textBounds, equally.graphicsAnnot(x$label), 10$x, x$y, : font ## family not found in Windows font database  ## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, 10$y, : font ## family unit not constitute in Windows font database  ## Warning in grid.Call(C_textBounds, equally.graphicsAnnot(x$label), ten$x, 10$y, : font ## family not found in Windows font database  ## Warning in filigree.Telephone call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font ## family not found in Windows font database          
            myscree(T.18.pca$eig / sum(T.18.pca$eig))          

Predicting using PCA

In this department, we'll show how to predict the coordinates of supplementary individuals and variables using only the information provided by the previously performed PCA.

see here

dolphprommeaveris.blogspot.com

Source: https://rstudio-pubs-static.s3.amazonaws.com/585948_abd70a6fc3e24d4fad8944197bc5dd25.html

0 Response to "Font Family Not Found in Windows Font Database"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel