Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • aacd2c4
  • /
  • FAMD_user_specific.R
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:d8fd1e9cfcc7f37e60953eff468b899acd486169
directory badge Iframe embedding
swh:1:dir:aacd2c4d63c1474c6dd6bc1bf66580c0b3ebed55

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
FAMD_user_specific.R
library(FactoMineR)
library(factoextra)
library(jsonlite)

myArgs <- commandArgs(trailingOnly = TRUE)


data <- read.csv(myArgs)

########################################################################
#run FAMD
run_FAMD <- function(data_frame) {

  data_types <- sapply(data_frame, class)

  run_type <- 'MCA'
  if ((any(data_types=="integer") || any(data_types == "numeric")) && (any(data_types == "factor") || any(data_types == "character"))) {
    run_type <- 'famd'
  } else if ((any(data_types=="integer") || any(data_types == "numeric")) && (!any(data_types == "factor") || !any(data_types == "character"))) {
    run_type <- 'PCA'
  }

  if(run_type == 'famd' || run_type == 'MCA') {
    ################################
    # do FAMD in case of qualitative and quantitative data
    res.famd <- FAMD(data_frame, graph = FALSE)
    var <- get_famd_var(res.famd)

    # print(res.famd$eig)

    var_contrib <- res.famd[["var"]][["contrib"]]

    # Contribution to the first dimension
    # print(fviz_contrib(res.famd, "var", axes = 1))
    # print(fviz_contrib(res.famd, "var", axes = 2))

    data_frame_var_contribution <- as.data.frame(t(var_contrib))

    return(list(data_frame_var_contribution, res.famd$eig, res.famd$ind$coord, res.famd$var$coord, -1))

  } else if (run_type == 'PCA') {
    ##########################
    # in case of only numerical values use PCA
    res.famd = PCA(data_frame, scale.unit=TRUE, ncp=5, graph=FALSE)

    var <- res.famd$var

    # print(res.famd$eig)


    # print(fviz_contrib(res.famd, "var", axes = 1))
    # print(fviz_contrib(res.famd, "var", axes = 2))

    var_contrib <- var$contrib

    data_frame_var_contribution <- as.data.frame(t(var_contrib))

    return(list(data_frame_var_contribution, res.famd$eig, res.famd$ind$coord, res.famd$var$coord, -1))
  }
}

list_final_contributing <- run_FAMD(data)

cat(jsonlite::toJSON(list_final_contributing, pretty=TRUE))


back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API