I have a questionnaire that contains answers with large text and I am not able to generate my graphs for analysis.
The graphics always come out with the text completely unformatted. I've tried using [![axis.text.x = element_text (angle = 90, hjust = 1)][1]][1]
but it didn't work.
My dataset: http://www.sharecsv.com/s/b0bad3c5144e5b5f70fd90b6f99413a3/q8.csv
structure(list(Artefatos = structure(10:1, .Label = c("Catálogo dos Sistemas Informatizados (Catálogo de Serviços de TIC - Acordo de Nível de Serviços e Métricas e Indicadores para Desempenho dos Serviços e Acordos de Nível de Serviço)",
"Contratação de Bens e Serviços de TIC (Gerenciar Aquisições de Software)",
"Gerenciar Ativos de TIC (Hardware,Licenças e Custos)", "Gestão de Riscos de Segurança da Informação",
"Gestão de Riscos de TIC", "Modelagem de Processos de Negócio (Automatizados/a Automatizar)",
"Processo de Desenvolvimento de Software (Gerenciamento da Qualidade,Configuração)",
"Processo de Gerenciamento de Incidentes e Problemas (Central de Serviços)",
"Processo de Gerenciamento de Mudanças", "Processo de Gestão de Contratos de TIC"
), class = "factor"), counts = c(7L, 2L, 4L, 5L, 2L, 5L, 5L,
6L, 9L, 5L), prop = c(14, 4, 8, 10, 4, 10, 10, 12, 18, 10), lab.ypos = c(7,
16, 22, 31, 38, 45, 55, 66, 81, 95), prop_desenv = c(70, 20,
40, 50, 20, 50, 50, 60, 90, 50)), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -10L))
My analyses code:
q8 <- read.csv("q8.csv",
header = TRUE,
quote="\"",
sep=",",
stringsAsFactors= TRUE,
strip.white = TRUE,
encoding = "UTF-8")
titulo <- "my title"
#seleciona atributo e realiza contagem
df <- q8 %>%
group_by(QUESTAO8) %>%
rename (Artefatos = QUESTAO8) %>%
summarise(counts = n()) %>%
arrange(desc(Artefatos)) %>%
mutate(prop = round(counts*100/sum(counts), 1),
lab.ypos = cumsum(prop) - 0.5*prop,
prop_desenv = (prop*100)/(nrow(Answers)*100/nrow(q8)))
#mostra os dados do atributo
sprintf("Quantidade de registros: %d", nrow(q8))
df
#plota o atributo
ggplot(df, aes(x = Artefatos, y = counts)) +
geom_bar(
aes(color = Artefatos, fill = Artefatos),
stat = "identity", position = position_stack()
)+
xlab(titulo)+
ylab("Amount")+
theme(axis.text.x = element_blank())
ggplot(df, aes(x = Artefatos, y = counts)) +
geom_bar(fill = "#0073C2FF", stat = "identity") +
xlab(titulo)+
ylab("Amount")+
theme(axis.text.x = element_text(angle = 90))
#percentual em relacao ao total de itens
ggplot(df, aes(x = Artefatos, y = prop_desenv)) +
geom_bar(
aes(color = Artefatos, fill = Artefatos),
stat = "identity", position = position_stack()
)+
xlab(titulo)+
ylab("Percentage of Artefacts")+
theme(axis.text.x = element_blank())
#percentual em relacao ao total de itens
ggplot(df, aes(x = Artefatos, y = prop_desenv)) +
geom_bar(
aes(fill = Artefatos),
stat = "identity", position = position_stack()
)+
xlab(titulo)+
ylab("Percentage of Artefacts")+
theme(axis.text.x = element_blank())
#percentual em relacao ao total de respostas
ggplot(df, aes(x = "", y = prop, fill = Artefatos)) +
geom_bar(width = 0.7, stat = "identity", color = "white") +
geom_text(aes(y = lab.ypos, label = prop), color = "black") +
ylab("Proportion")+
xlab(titulo)
ggplot(df, aes(x = "", y = prop, fill = Artefatos)) +
geom_bar(width = 1, stat = "identity", color = "white") +
geom_text(aes(y = lab.ypos, label = prop), color = "white") +
coord_polar("y", start = 0) +
ylab("Proportion")