Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate Row Name Error for FAMD Visualization

Tags:

r

r-rownames

I'm trying to perform this function in R: fviz_famd_ind() and keep getting an error. It works on the wine dataset provided in the package, but not on my cleaned data set from Telco.Customer.Churn from IBM.

I've created the object of the FAMD function using the cleaned data set called dfcfamd1. I've verified there are no duplicate row or column names in the sets using any(duplicated(rownames())) for both Telco.Customer.Churn and dfcfamd1 which both return FALSE.

fviz_famd_ind(dfcfamd1)

> Error in `.rowNamesDF<-`(x, value = value) : 
>   duplicate 'row.names' are not allowed
> In addition: Warning message:
> non-unique values when setting 'row.names': ‘No’, ‘Yes’

Sample Data below

head(Telco.Customer.Churn)

    customerID  gender  SeniorCitizen  Partner  Dependents  tenure
1   7590-VHVEG  Female              0      Yes          No       1
2   5575-GNVDE    Male              0       No          No      34
3   3668-QPYBK    Male              0       No          No       2

 PhoneService    MultipleLines InternetService OnlineSecurity
1          No               No             DSL             No
2         Yes               No             DSL            Yes
3         Yes              Yes     Fiber optic             No


  OnlineBackup DeviceProtection  TechSupport  StreamingTV   
1          Yes               No            No          No
2           No               No            No          No
3           No              Yes            No         Yes

 StreamingMovies        Contract  PaperlessBilling       PaymentMethod
1             No   Month-to-month               Yes   Electronic check
2             No         One year                No       Mailed check
3             No   Month-to-month               Yes       Mailed check

  MonthlyCharges    TotalCharges    Churn
1          29.85           29.85       No
2          56.95         1889.50       No
3          53.85          108.15      Yes

The output should give me a graphical output which it does for the package data, but not for my data.

Attempting to set names to unique, I get a vector error:

rownames(dfcfamd1) = make.names(names, unique=TRUE)

> Error in as.character(names) : 
>   cannot coerce type 'builtin' to vector of type 'character'
like image 693
Bashta Avatar asked Oct 16 '25 17:10

Bashta


1 Answers

The issue is that names is a function

 rownames(dfcfamd1) = make.names(names, unique=TRUE)

instead it should be

 row.names(dfcfamd1) = make.names(row.names(dfcfamd1), unique=TRUE)
like image 103
akrun Avatar answered Oct 18 '25 06:10

akrun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!