tests/testthat/test-varianceexplainedtable.R

context("VarianceExplainedTable")

eigenvalues <- c(4.44034949720709, 2.35097998387979, 1.9304027562133, 1.45457424415372,
                 1.31193829604834, 1.17591316023307, 1.14058620328207, 1.00902917691777,
                 0.98080181340009, 0.902042938746011, 0.84050508290455, 0.80136345423894,
                 0.763289119220272, 0.70790438610841, 0.66573743087563, 0.626415931584869,
                 0.612885319827727, 0.553121424159804, 0.524079911252419, 0.516512719316901,
                 0.46551890989897, 0.412857122937462, 0.386819475655862, 0.288051746237821,
                 0.138319895699113)

variance.proportions <- c(0.177613979888284, 0.0940391993551916, 0.077216110248532, 0.0581829697661486,
                          0.0524775318419336, 0.0470365264093229, 0.0456234481312827, 0.0403611670767109,
                          0.0392320725360036, 0.0360817175498404, 0.033620203316182, 0.0320545381695576,
                          0.0305315647688109, 0.0283161754443364, 0.0266294972350252, 0.0250566372633948,
                          0.0245154127931091, 0.0221248569663922, 0.0209631964500968, 0.020660508772676,
                          0.0186207563959588, 0.0165142849174985, 0.0154727790262345, 0.0115220698495129,
                          0.00553279582796453)

cumulative.proportions <- c(0.177613979888284, 0.271653179243475, 0.348869289492007, 0.407052259258156,
                            0.459529791100089, 0.506566317509412, 0.552189765640695, 0.592550932717406,
                            0.631783005253409, 0.66786472280325, 0.701484926119432, 0.73353946428899,
                            0.7640710290578, 0.792387204502137, 0.819016701737162, 0.844073339000557,
                            0.868588751793666, 0.890713608760058, 0.911676805210155, 0.932337313982831,
                            0.95095807037879, 0.967472355296288, 0.982945134322523, 0.994467204172035,
                            1)

expect_error(VarianceExplainedTable(eigenvalues, variance.proportions, cumulative.proportions,
    title = "Variance Explained",
    footer = "Unrotated Variance Explained; Input: Correlation matrix; Missing data setting: Use partial data (pairwise correlations); Sample size: 4 to 618)"), NA)
NumbersInternational/flipFormat documentation built on Feb. 26, 2024, 5:36 a.m.