Like dplyr, anomalyDetection also uses the pipe function, %>% to turn function composition into a series of imperative statements.

Arguments

lhs, rhs

An R object and a function to apply to it

Examples

x <- matrix(rnorm(200*3), ncol = 10) N <- nrow(x) p <- ncol(x) # Instead of hc <- horns_curve(x) fa <- factor_analysis(x, hc_points = hc) factor_analysis_results(fa, fa_scores_rotated)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] -0.57797584 1.15515981 0.19737856 -0.55487540 0.2986938215 #> [2,] 1.44109690 0.90272115 1.62570000 0.24442710 -1.3878918091 #> [3,] 0.45959214 0.10265184 1.23904822 0.23359344 1.7099274229 #> [4,] 1.93573622 1.09198067 0.42576682 -0.08715457 -1.9214084526 #> [5,] 0.38807052 0.31143882 2.64133418 0.26156523 0.2069689101 #> [6,] 0.27772189 -1.49721015 0.80465388 -1.32937645 0.7957827841 #> [7,] -0.44276669 0.10394158 -2.26690358 -0.39571520 -0.0257567675 #> [8,] -0.50423880 0.55746729 0.47731329 0.03233000 0.1315032110 #> [9,] -0.12350911 0.31035170 -0.19596635 -0.73326344 -1.0971155912 #> [10,] -1.06279488 -1.47141816 -0.46140147 0.26391091 -0.9208975384 #> [11,] -2.00208395 -1.36144268 0.38890629 -0.28905761 -1.4943777266 #> [12,] 1.72372273 -1.21318475 -1.30676796 -0.21924003 -0.8816799232 #> [13,] 0.93613991 -0.87842012 -0.12911216 1.04461329 0.4902396798 #> [14,] -0.25404355 0.85684550 0.28930868 -1.45511747 1.7962600163 #> [15,] -0.17433559 0.64581844 -0.26820531 -0.19445301 -0.6822869449 #> [16,] -1.82084946 1.04517418 -0.34150395 0.10992322 1.3745001831 #> [17,] -0.15092886 0.34467138 0.23938374 -0.26899169 -0.1159638302 #> [18,] -0.05202973 0.20145638 -0.85320876 -0.24590616 -0.6405799044 #> [19,] 0.62300651 0.60021476 -0.96228635 1.05716557 0.9649281885 #> [20,] 0.84200412 2.38284492 -1.13937264 1.25065218 -0.7678314149 #> [21,] 0.72897203 -0.28451472 1.65133541 -1.19668909 -0.4449945868 #> [22,] 0.66017420 -0.06059736 1.10237372 2.27165143 -1.2566053711 #> [23,] -1.59190497 -0.49433273 1.11768897 -0.81705200 -0.6827013337 #> [24,] -0.42279418 -0.67183806 -0.67059643 1.08652350 -0.6507532067 #> [25,] -0.78268447 0.85603095 0.83136964 1.28322514 0.5866919551 #> [26,] -0.91143792 0.26468899 0.53229732 0.48297693 0.5833127069 #> [27,] -1.50091474 -0.60006930 -0.34620447 1.72213096 1.2950523182 #> [28,] 0.29052766 1.01808508 -1.47070451 -0.10115421 0.2191049925 #> [29,] -0.62973600 0.23290472 -1.58050708 -0.24324039 1.1259312426 #> [30,] 1.11171314 -0.53935199 -0.34496428 0.32884280 -0.1373927938 #> [31,] -0.06361202 1.81835656 0.69102297 0.25794553 -0.0769585606 #> [32,] 1.73658663 -1.95468117 0.64598408 1.43913094 0.1513982129 #> [33,] -0.49792855 0.65676038 -0.58302155 -1.13560557 -1.3927705015 #> [34,] 0.38831801 -0.07915028 0.04231322 0.39040045 -1.6413862072 #> [35,] -0.06182420 -2.15428850 1.77434156 1.87427293 0.3585718688 #> [36,] -0.09914494 -0.27625652 1.43186240 -1.06267749 -1.0139881998 #> [37,] -1.65536688 0.45858011 0.38753973 -0.48034603 0.5651253785 #> [38,] -1.41817442 -0.91947773 -1.06639435 -0.23507815 -1.0589578091 #> [39,] -0.82715721 -1.16236037 0.32653793 1.53522167 -0.5041316312 #> [40,] 2.15036049 -1.52532772 -1.31514562 0.93152483 1.6100002205 #> [41,] -0.50671409 0.86988519 -1.54953082 0.28243874 -0.9081001450 #> [42,] -0.74661275 -0.61874465 0.14180227 -1.37442472 0.2420977228 #> [43,] 0.78770057 -0.13983200 -0.67724265 -0.16972426 -0.0009243226 #> [44,] 0.50153547 0.63224610 -0.97463973 0.22447185 2.0496806165 #> [45,] -0.61013772 0.81152395 -0.22718082 -0.72602486 1.1004186198 #> [46,] -1.42864118 1.21938885 -0.16902050 1.53595044 -1.9833368440 #> [47,] 0.26924012 0.49033931 0.52270818 0.44334186 0.9086430302 #> [48,] 2.19088718 1.06538180 1.23667164 -0.55752302 0.9555967398 #> [49,] 0.75690814 -0.56636725 -0.28473724 -0.41690032 -0.2259500793 #> [50,] 0.33019317 -1.12300543 -0.88683898 -1.54365813 -0.6121216768 #> [51,] 0.11037552 -1.47153791 0.49216884 -1.56942894 1.4076344342 #> [52,] -1.24143907 -0.09300592 0.44047012 0.90460233 1.5916587751 #> [53,] 1.38126423 0.74266888 0.21973224 -2.27946021 -0.6910104096 #> [54,] 0.74909720 0.59241045 -0.34672712 -0.99719369 0.8911360011 #> [55,] 0.90806518 -1.10569842 -1.96540678 0.95227320 -0.4071558687 #> [56,] -0.50038275 1.33979843 1.60459044 0.96843034 0.2836414140 #> [57,] 0.08113944 -0.03700537 -1.07638541 -0.15939321 1.1786910147 #> [58,] -1.03655860 -2.06386636 0.20444280 -1.10907150 -0.3762415176 #> [59,] -0.02786793 0.88770742 -0.50051796 0.47632062 -0.5771508441 #> [60,] -0.03355826 -0.20650997 0.23444770 -1.94206063 -0.2947696691
# You can write horns_curve(x) %>% factor_analysis(x, hc_points = .) %>% factor_analysis_results(fa_scores_rotated)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] -0.57797584 1.15515981 0.19737856 -0.55487540 0.2986938215 #> [2,] 1.44109690 0.90272115 1.62570000 0.24442710 -1.3878918091 #> [3,] 0.45959214 0.10265184 1.23904822 0.23359344 1.7099274229 #> [4,] 1.93573622 1.09198067 0.42576682 -0.08715457 -1.9214084526 #> [5,] 0.38807052 0.31143882 2.64133418 0.26156523 0.2069689101 #> [6,] 0.27772189 -1.49721015 0.80465388 -1.32937645 0.7957827841 #> [7,] -0.44276669 0.10394158 -2.26690358 -0.39571520 -0.0257567675 #> [8,] -0.50423880 0.55746729 0.47731329 0.03233000 0.1315032110 #> [9,] -0.12350911 0.31035170 -0.19596635 -0.73326344 -1.0971155912 #> [10,] -1.06279488 -1.47141816 -0.46140147 0.26391091 -0.9208975384 #> [11,] -2.00208395 -1.36144268 0.38890629 -0.28905761 -1.4943777266 #> [12,] 1.72372273 -1.21318475 -1.30676796 -0.21924003 -0.8816799232 #> [13,] 0.93613991 -0.87842012 -0.12911216 1.04461329 0.4902396798 #> [14,] -0.25404355 0.85684550 0.28930868 -1.45511747 1.7962600163 #> [15,] -0.17433559 0.64581844 -0.26820531 -0.19445301 -0.6822869449 #> [16,] -1.82084946 1.04517418 -0.34150395 0.10992322 1.3745001831 #> [17,] -0.15092886 0.34467138 0.23938374 -0.26899169 -0.1159638302 #> [18,] -0.05202973 0.20145638 -0.85320876 -0.24590616 -0.6405799044 #> [19,] 0.62300651 0.60021476 -0.96228635 1.05716557 0.9649281885 #> [20,] 0.84200412 2.38284492 -1.13937264 1.25065218 -0.7678314149 #> [21,] 0.72897203 -0.28451472 1.65133541 -1.19668909 -0.4449945868 #> [22,] 0.66017420 -0.06059736 1.10237372 2.27165143 -1.2566053711 #> [23,] -1.59190497 -0.49433273 1.11768897 -0.81705200 -0.6827013337 #> [24,] -0.42279418 -0.67183806 -0.67059643 1.08652350 -0.6507532067 #> [25,] -0.78268447 0.85603095 0.83136964 1.28322514 0.5866919551 #> [26,] -0.91143792 0.26468899 0.53229732 0.48297693 0.5833127069 #> [27,] -1.50091474 -0.60006930 -0.34620447 1.72213096 1.2950523182 #> [28,] 0.29052766 1.01808508 -1.47070451 -0.10115421 0.2191049925 #> [29,] -0.62973600 0.23290472 -1.58050708 -0.24324039 1.1259312426 #> [30,] 1.11171314 -0.53935199 -0.34496428 0.32884280 -0.1373927938 #> [31,] -0.06361202 1.81835656 0.69102297 0.25794553 -0.0769585606 #> [32,] 1.73658663 -1.95468117 0.64598408 1.43913094 0.1513982129 #> [33,] -0.49792855 0.65676038 -0.58302155 -1.13560557 -1.3927705015 #> [34,] 0.38831801 -0.07915028 0.04231322 0.39040045 -1.6413862072 #> [35,] -0.06182420 -2.15428850 1.77434156 1.87427293 0.3585718688 #> [36,] -0.09914494 -0.27625652 1.43186240 -1.06267749 -1.0139881998 #> [37,] -1.65536688 0.45858011 0.38753973 -0.48034603 0.5651253785 #> [38,] -1.41817442 -0.91947773 -1.06639435 -0.23507815 -1.0589578091 #> [39,] -0.82715721 -1.16236037 0.32653793 1.53522167 -0.5041316312 #> [40,] 2.15036049 -1.52532772 -1.31514562 0.93152483 1.6100002205 #> [41,] -0.50671409 0.86988519 -1.54953082 0.28243874 -0.9081001450 #> [42,] -0.74661275 -0.61874465 0.14180227 -1.37442472 0.2420977228 #> [43,] 0.78770057 -0.13983200 -0.67724265 -0.16972426 -0.0009243226 #> [44,] 0.50153547 0.63224610 -0.97463973 0.22447185 2.0496806165 #> [45,] -0.61013772 0.81152395 -0.22718082 -0.72602486 1.1004186198 #> [46,] -1.42864118 1.21938885 -0.16902050 1.53595044 -1.9833368440 #> [47,] 0.26924012 0.49033931 0.52270818 0.44334186 0.9086430302 #> [48,] 2.19088718 1.06538180 1.23667164 -0.55752302 0.9555967398 #> [49,] 0.75690814 -0.56636725 -0.28473724 -0.41690032 -0.2259500793 #> [50,] 0.33019317 -1.12300543 -0.88683898 -1.54365813 -0.6121216768 #> [51,] 0.11037552 -1.47153791 0.49216884 -1.56942894 1.4076344342 #> [52,] -1.24143907 -0.09300592 0.44047012 0.90460233 1.5916587751 #> [53,] 1.38126423 0.74266888 0.21973224 -2.27946021 -0.6910104096 #> [54,] 0.74909720 0.59241045 -0.34672712 -0.99719369 0.8911360011 #> [55,] 0.90806518 -1.10569842 -1.96540678 0.95227320 -0.4071558687 #> [56,] -0.50038275 1.33979843 1.60459044 0.96843034 0.2836414140 #> [57,] 0.08113944 -0.03700537 -1.07638541 -0.15939321 1.1786910147 #> [58,] -1.03655860 -2.06386636 0.20444280 -1.10907150 -0.3762415176 #> [59,] -0.02786793 0.88770742 -0.50051796 0.47632062 -0.5771508441 #> [60,] -0.03355826 -0.20650997 0.23444770 -1.94206063 -0.2947696691