'graphical analysis of item theory in R with itan package

I am analyzing tests with the itan package which turns out to be an incredible weapon to analyze item and of the few that I know it will be possible to shape the graphics that this package returns, I will paste the codes as they are shown on your page

library(itan)
datos<-data(datos) #data that is already part of the itan package
clave<-data(clave)

respuestas <- datos[,-1]
alternativas <- LETTERS[1:5]

#Alternative frequency chart

g <- graficarFrecuenciaAlternativas(respuestas, alternativas, clave)
g$i01
g$i02
g$i03
g$i04

enter image description here

The general question is whether it is possible to change the aesthetics of these graphics to fit them to my project?

r


Solution 1:[1]

Doing some research I found the source code of the packet on the next page:

enter link description here

With which it will be enough to simply modify the following code

graficarFrecuenciaAlternativas <- function(respuestas, alternativas, clave=NULL) {

  item <- ncol(respuestas)
  fa <-calcularFrecuenciaAlternativas(respuestas, alternativas)
  names <- colnames(fa)

  output  <- c();

  for (i in 1:item) {
    colnames(fa) <- ifelse(colnames(fa) == clave[[i]],
                           paste(c("*"), colnames(fa), sep = ""),
                           colnames(fa))
    fam <- melt(fa[i,], id.vars = "item")
    output[[i]] <- ggplot2::ggplot(fam, aes_string(x="variable", y="value", fill="variable")) +
                   ggplot2::geom_col(show.legend = F) +
                   ggplot2::labs(title = paste("\u00CDtem ", i),
                                 x="Alternativa",
                                 y="Frecuencia") +
                   ggplot2::theme(plot.title = element_text(size=18, face="bold" ,hjust=0.5))
    colnames(fa) <- names
  }

  names(output) <- colnames(respuestas)

  return(output);

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 yefersonG