bluefoxr / COINr

COINr
https://bluefoxr.github.io/COINr/
Other
25 stars 8 forks source link

get_PCA() indicates the presence of NAs for a complete dataset with no missing values #49

Closed MoujibChahid closed 1 year ago

MoujibChahid commented 1 year ago

I'd like to report a failure of the get_PCA() function that presents the following error indicating that NAs are not allowed even though the dataset is complete and has no missing values.

Error in wlist$Weight[match(outPCA$iCodes, wlist$iCode)] <- outPCA$wts : NAs are not allowed in subscripted assignments

I should point out that I'm trying to obtain the relative weights for each dimension (level 2) from the first principal component, as indicated in the COINr documentation. To do this, I've built the " coin " and treated, normalized and aggregated the data. The dataset is written to "Aggregated".

The script used for all these steps is as follows:

library(readxl) iData <- read_excel("/Users/moujib0/Desktop/Panel_purse/Panel_Imputed.xlsx", sheet = "iData") iMeta <- read_excel("/Users/moujib0/Desktop/Panel_purse/Panel_Imputed.xlsx", sheet = "iMeta")

library(COINr) coin <- new_coin(iData = iData, iMeta = iMeta) iData checked and OK. iMeta checked and OK. Error in new_coin(iData = iData, iMeta = iMeta) : Panel data detected, but you have not specifed split_to - please specify this. coin <- new_coin(iData = iData, iMeta = iMeta, split_to = "all") iData checked and OK. iMeta checked and OK. Written data set to .$Data$Raw Written data set to .$Data$Raw Written data set to .$Data$Raw Written data set to .$Data$Raw Written data set to .$Data$Raw Written data set to .$Data$Raw Written data set to .$Data$Raw Written data set to .$Data$Raw coin <- qNormalise(coin, dset = "Raw", f_n = "n_minmax",

  • f_n_para = list(l_u = c(1, 100))) Written data set to .$Data$Normalised Written data set to .$Data$Normalised Written data set to .$Data$Normalised Written data set to .$Data$Normalised Written data set to .$Data$Normalised Written data set to .$Data$Normalised Written data set to .$Data$Normalised Written data set to .$Data$Normalised coin <- Aggregate(coin, dset = "Normalised", f_ag = "a_amean") Written data set to .$Data$Aggregated Written data set to .$Data$Aggregated Written data set to .$Data$Aggregated Written data set to .$Data$Aggregated Written data set to .$Data$Aggregated Written data set to .$Data$Aggregated Written data set to .$Data$Aggregated Written data set to .$Data$Aggregated **> coin <- get_PCA(coin, dset = "Aggregated", Level = 2,
  • weights_to = "PCAwtsLev2", out2 = "coin") Error in wlist$Weight[match(outPCA$iCodes, wlist$iCode)] <- outPCA$wts : NAs are not allowed in subscripted assignments**

The reproducible dataset used for these calculations is attached to my request. get_PCA_Data.xlsx

I would like to thank you in advance for your usual responsiveness and cooperation, and ask you to intervene to resolve the situation.

bluefoxr commented 1 year ago

Hi, get_PCA() only works for coins, not purses.