QualCoder | Qualitative data analysis for text , images , audio , video | Machine Learning library
kandi X-RAY | QualCoder Summary
Support
Quality
Security
License
Reuse
- Updates the positions of the text
- Highlight the text
- Removes formatting
- Update annotation annotations
- Import project data
- Convert a datetime into a datetime object
- Write INI file
- Setup the UI
- Translates the UI text
- Update the positions of the text
- Highlight the document
- Creates the text edit menu for the given position
- Loads text from file
- Performs a search on a document
- Creates a table
- Creates a text edit menu
- Generate a picture
- Setup UI
- Export the project
- Populate the table menu
- Updates the positions in the text editor
- Save the current graph
- Import project
- Select attribute names
- Select attributes
- Overrides drop event
- Make a heatmap
QualCoder Key Features
QualCoder Examples and Code Snippets
Trending Discussions on QualCoder
Trending Discussions on QualCoder
QUESTION
Background: I have survey results in an SPSS .sav file. Some of the survey questions were open, where respondents could type their own responses. In SPSS, I can just select one or more columns, and the responses will be output as a text file, with the responses grouped by each question (column contents), and each response separated by a blank line. This text file can then be used for thematic analysis by assigning code to phrases or sentences in the text.
I can't seem to find an easy way of doing the same thing in R. All the usual export formats output as a table. Selecting the columns in RStudio gives text output where each the responses are grouped by respondent rather than by column.
Toy example:
library(labelled)
library(tidyverse)
comments<-tibble(
shakey=as.character(c("To be or not to be", "", "Alas poor Yorick", "", "Is this a dagger that I see before me?", "A rose by any other name")),
versey=as.character(c("", "The boy stood on the burning deck", "", "Oft in the stilly night", "", "Lars Porsena of Clusium, by the nine gods he swore"))
)
var_label(comments$shakey)<-"Can you quote some Shakespeare?"
var_label(comments$versey)<-"Can you quote some poetry?"
The output I want from this is:
*Can you quote some Shakespeare?*
To be or not to be
Alas poor Yorick
Is this a dagger that I see before me?
A rose by any other name
*Can you quote some poetry?*
The boy stood on the burning deck
Oft in the stilly night
Lars Porsena of Clusium, by the nine gods he swore
with the column label as the heading and each column's non-blank responses listed one after the other, separated by a blank line.
The closest I've come so far is:
comlong<-pivot_longer(comments, everything(),
names_to="question",
values_to="response") %>%
arrange(question) %>%
filter(response!="")
but while that gets all the responses in one column, it needs a bit of editing to get it into the desired format above, which is non-trivial on more extensive data.
Final result:
Akrun's additional summarise
line is, I think, the most elegant. Tweaking that gives output very similar to SPSS:
comments %>%
summarise(across(everything(), ~ c(paste0(sprintf('**%s**', cur_column()), "\n\n", sprintf('*%s*', var_label(.))), .))) %>%
pivot_longer(cols = everything(),
names_to = 'question',
values_to = 'response') %>%
arrange(question) %>%
filter(response != '') %>%
select(response) %>%
write.table("comments.md",quote=FALSE, eol="\n\n", row.names=FALSE, col.names=FALSE)
This inserts the column name as well as the label (because I found that sometimes the labels are not sufficiently descriptive), and outputs it as a markdown file, which can be ingested for thematic coding in (eg) Qualcoder. Running:
pandoc comments.md -o comments.odt
will also produce word-processor output if you need it.
ANSWER
Answered 2021-Sep-05 at 15:09We could use summarise
with across
first to extract the var_label
and append by concatenating, then use pivot_longer
library(labelled)
library(dplyr)
library(tidyr)
comments %>%
summarise(across(everything(), ~ c(var_label(.), .))) %>%
pivot_longer(cols = everything(), names_to = 'question',
values_to = 'response') %>%
arrange(question) %>%
filter(response != '')
-output
# A tibble: 9 x 2
question response
1 shakey Can you quote some Shakespeare?
2 shakey To be or not to be
3 shakey Alas poor Yorick
4 shakey Is this a dagger that I see before me?
5 shakey A rose by any other name
6 versey Can you quote some poetry?
7 versey The boy stood on the burning deck
8 versey Oft in the stilly night
9 versey Lars Porsena of Clusium, by the nine gods he swore
or if we are first reshapeing first, there is an option as well i.e. do a group by 'question' and subset the first value of 'question' to extract the var_label
from the original data and concatenate
pivot_longer(comments, everything(),
names_to="question",
values_to="response") %>%
arrange(question) %>%
filter(response!="") %>%
group_by(question) %>%
summarise(response = c(var_label(comments[[first(question)]]),
response), .groups = 'drop')
-output
# A tibble: 9 x 2
question response
1 shakey Can you quote some Shakespeare?
2 shakey To be or not to be
3 shakey Alas poor Yorick
4 shakey Is this a dagger that I see before me?
5 shakey A rose by any other name
6 versey Can you quote some poetry?
7 versey The boy stood on the burning deck
8 versey Oft in the stilly night
9 versey Lars Porsena of Clusium, by the nine gods he swore
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install QualCoder
You can use QualCoder like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page