@@ -277,29 +277,10 @@ setMethod(f="chart_plot",
277
277
P = output_value(dobj ,' loadings' )
278
278
Ev = output_value(dobj ,' eigenvalues' )
279
279
280
- # eigenvalues were square rooted when training PCA
281
- Ev = Ev [,1 ]
282
- Ev = Ev ^ 2
283
-
284
- # # unscale the scores
285
- # ev are the norms of scores
286
- Ts = as.matrix(Ts ) %*% diag(1 / Ev ) # these are normalised scores
287
-
288
- # scale scores and loadings by alpha
289
- Ts = Ts %*% diag(Ev ^ (1 - opt $ scale_factor ))
290
- P = as.matrix(P ) %*% diag(Ev ^ (opt $ scale_factor ))
291
-
292
- # additionally scale the loadings
293
- sf = min(max(abs(Ts [,opt $ components [1 ]]))/ max(abs(P [,opt $ components [1 ]])),
294
- max(abs(Ts [,opt $ components [2 ]]))/ max(abs(P [,opt $ components [2 ]])))
295
- Ts = as.data.frame(Ts )
296
-
297
- rownames(Ts )= rownames(dobj $ scores ) # fix dimnames for SE object
298
- colnames(Ts )= colnames(dobj $ scores )
299
- dobj $ scores $ data = as.data.frame(Ts ) # nb object not returned, so only temporary scaling
280
+ sf = max(abs(Ts )) / max(abs(P )) * opt $ scale_factor
300
281
301
282
# plot
302
- A = data.frame (" x" = P [,opt $ components [1 ]]* sf * 0.8 ," y" = P [,opt $ components [2 ]]* sf * 0.8 )
283
+ A = data.frame (" x" = P [,opt $ components [1 ]]* sf ," y" = P [,opt $ components [2 ]]* sf )
303
284
C = pca_scores_plot(points_to_label = obj $ points_to_label ,xcol = obj $ components [1 ],ycol = obj $ components [2 ],factor_name = obj $ factor_name )
304
285
out = chart_plot(C ,dobj )
305
286
0 commit comments