Title: | Import and Analysis of OMR Data from FormScanner |
---|---|
Description: | Import data of tests and questionnaires from FormScanner. FormScanner is an open source software that converts scanned images to data using optical mark recognition (OMR) and it can be downloaded from <http://sourceforge.net/projects/formscanner/>. The spreadsheet file created by FormScanner is imported in a convenient format to perform the analyses provided by the package. These analyses include the conversion of multiple responses to binary (correct/incorrect) data, the computation of the number of corrected responses for each subject or item, scoring using weights,the computation and the graphical representation of the frequencies of the responses to each item and the report of the responses of a few subjects. |
Authors: | Michela Battauz |
Maintainer: | Michela Battauz <[email protected]> |
License: | GPL-3 |
Version: | 1.1.1 |
Built: | 2025-01-14 03:20:19 UTC |
Source: | https://github.com/cran/fsia |
Import data of tests and questionnaires from FormScanner. FormScanner is an open source software that converts scanned images to data using optical mark recognition (OMR) and it can be downloaded from <http://sourceforge.net/projects/formscanner/>. The spreadsheet file created by FormScanner is imported in a convenient format to perform the analyses provided by the package. These analyses include the conversion of multiple responses to binary (correct/incorrect) data, the computation of the number of corrected responses for each subject or item, scoring using weights, the computation and the graphical representation of the frequencies of the responses to each item and the report of the responses of a few subjects.
Package: | fsia |
Type: | Package |
Version: | 1.1.1 |
Date: | 2017-06-23 |
License: | GPL-3 |
Data of questionnaires and tests are often collected on paper forms.
FormScanner is an open source software that converts scanned images
to data using optical mark recognition (OMR).
Function read.formscanner
of the fsia package
can be used to import data from FormScanner in R.
The correct response (key) can be specified using function
addkey
.
It is also possible to specify weights for each response using
function addweights
.
If items have a key, data can be converted
to binary variables using function resp2binary
.
In this case, the number of corrected responses for each person
and for each item can also be computed by using functions
person.stat
and item.stat
.
These functions can also be used to compute a score using the
weights previously specified.
Function freq
calculates the absolute or percentage
frequencies of the responses to each item. The frequencies can
be printed on screen or plotted on a graph. In both cases, the
true responses (if any) are highlighted.
The responses given by one or a few subjects can be displayed
on a graph by using function report
.
The key is shown on the right and wrong responses can be immediately
identified by the red colour.
The package includes two data sets for illustrative purposes.
Data sets test
and questionnaire
contain the result of importing csv files with function read.formscanner
.
Data set key
contains the correct responses of the
items of the test data sets. Data set weights
contains
the weights of each correct response, while data set weights_multiple
contains the weights of each response.
Michela Battauz
Maintainer: Michela Battauz <[email protected]>
Borsetta, A. (2017). FormScanner [Computer Software], URL http://sourceforge.net/projects/formscanner/.
# IMPORT DATA FROM FORMSCANNER # find the directory with package fsia dir_pkg <- find.package("fsia") # the example files are in the directory examples # create the path questionnaire_path <- file.path(dir_pkg, "examples", "scan_results_questionnaire.csv") test_path <- file.path(dir_pkg, "examples", "scan_results_test.csv") # import file "scan_results_questionnaire.csv" questionnaire_imp<-read.formscanner(questionnaire_path, dummy = "Q5.sources") questionnaire_imp # questionnaire_imp is equal to the data questionnaire # import file "scan_results_test.csv" test_imp <- read.formscanner(test_path, conc = paste("id", 1:6, sep = ""), id = "id1") test_imp # test_imp is equal to the data test # ADD THE KEY # create the path for file "key.csv" key_path <- file.path(dir_pkg, "examples", "key.csv") # add the key testk <- addkey(test_imp, keyfile = key_path) testk$key # ADD WEIGHTS # create the path for file "weights.csv" weights_path <- file.path(dir_pkg, "examples", "weights.csv") # specify the weights for each correct response testw <- addweights(testk, weightsfile = weights_path) testw$weights # create the path for file "weights_multiple.csv" weights_mult_path <- file.path(dir_pkg, "examples", "weights_multiple.csv") # specify the weights for each response testwm <- addweights(test_imp, weightsfile = weights_mult_path) testwm$weights # CONVERT DATA TO BINARY VARIABLES resp01 <- resp2binary(obj = testk, col = 2:41) resp01[, 2:5] # ASSIGN WEIGHTS TO RESPONSES resps <- resp2scores(obj = testw, col =2:41) resps[, 2:5] # ASSIGN WEIGHTS TO RESPONSES (MULTIPLE WEIGHTS) resps <- resp2scores(obj = testwm, col =2:41) resps[, 2:5] # PERSON STATISTICS (selected only 4 items) pst <- person.stat(obj = testk, col = 2:5) pst pst <- person.stat(obj = testw, col = 2:5, weights = TRUE) pst pst <- person.stat(obj = testwm, col = 2:5, weights = TRUE) pst # ITEM STATISTICS ist <- item.stat(obj = testk, col = 2:41) head(ist) ist <- item.stat(obj = testw, col = 2:41, weights = TRUE) head(ist) ist <- item.stat(obj = testwm, col = 2:41, weights = TRUE) head(ist) # FREQUENCIES OF THE RESPONSES fr <- freq(obj = testk, col = c("Question03", "Question04")) fr par(mfrow = c(1, 2)) plot(fr, ask = FALSE) # RESPONSES OF TWO SUBJECTS par(mfrow = c(1, 2)) report(obj = testk, col = 2:11, whichid = c("102344", "245784")) report(obj = testw, col = 2:11, whichid = c("102344", "245784"), weights = TRUE) par(mfrow = c(1, 1)) report(obj = testwm, col = 2:11, whichid = c("102344", "245784"), weights = TRUE)
# IMPORT DATA FROM FORMSCANNER # find the directory with package fsia dir_pkg <- find.package("fsia") # the example files are in the directory examples # create the path questionnaire_path <- file.path(dir_pkg, "examples", "scan_results_questionnaire.csv") test_path <- file.path(dir_pkg, "examples", "scan_results_test.csv") # import file "scan_results_questionnaire.csv" questionnaire_imp<-read.formscanner(questionnaire_path, dummy = "Q5.sources") questionnaire_imp # questionnaire_imp is equal to the data questionnaire # import file "scan_results_test.csv" test_imp <- read.formscanner(test_path, conc = paste("id", 1:6, sep = ""), id = "id1") test_imp # test_imp is equal to the data test # ADD THE KEY # create the path for file "key.csv" key_path <- file.path(dir_pkg, "examples", "key.csv") # add the key testk <- addkey(test_imp, keyfile = key_path) testk$key # ADD WEIGHTS # create the path for file "weights.csv" weights_path <- file.path(dir_pkg, "examples", "weights.csv") # specify the weights for each correct response testw <- addweights(testk, weightsfile = weights_path) testw$weights # create the path for file "weights_multiple.csv" weights_mult_path <- file.path(dir_pkg, "examples", "weights_multiple.csv") # specify the weights for each response testwm <- addweights(test_imp, weightsfile = weights_mult_path) testwm$weights # CONVERT DATA TO BINARY VARIABLES resp01 <- resp2binary(obj = testk, col = 2:41) resp01[, 2:5] # ASSIGN WEIGHTS TO RESPONSES resps <- resp2scores(obj = testw, col =2:41) resps[, 2:5] # ASSIGN WEIGHTS TO RESPONSES (MULTIPLE WEIGHTS) resps <- resp2scores(obj = testwm, col =2:41) resps[, 2:5] # PERSON STATISTICS (selected only 4 items) pst <- person.stat(obj = testk, col = 2:5) pst pst <- person.stat(obj = testw, col = 2:5, weights = TRUE) pst pst <- person.stat(obj = testwm, col = 2:5, weights = TRUE) pst # ITEM STATISTICS ist <- item.stat(obj = testk, col = 2:41) head(ist) ist <- item.stat(obj = testw, col = 2:41, weights = TRUE) head(ist) ist <- item.stat(obj = testwm, col = 2:41, weights = TRUE) head(ist) # FREQUENCIES OF THE RESPONSES fr <- freq(obj = testk, col = c("Question03", "Question04")) fr par(mfrow = c(1, 2)) plot(fr, ask = FALSE) # RESPONSES OF TWO SUBJECTS par(mfrow = c(1, 2)) report(obj = testk, col = 2:11, whichid = c("102344", "245784")) report(obj = testw, col = 2:11, whichid = c("102344", "245784"), weights = TRUE) par(mfrow = c(1, 1)) report(obj = testwm, col = 2:11, whichid = c("102344", "245784"), weights = TRUE)
Adds the correct responses (key) to a data frame.
addkey(obj, keyline = NULL, keyfile = NULL, keydata = NULL)
addkey(obj, keyline = NULL, keyfile = NULL, keydata = NULL)
obj |
An object containing the data imported by function |
keyline |
the number of line of the data containing the correct responses to the items. This line is deleted from the data and used as key. |
keyfile |
the name of the file with the correct responses to the items. Column names should match the names of the items. |
keydata |
an R data frame containing the correct responses to the items. Column names should match the names of the items. |
keyfile
and keydata
can contain more items than obj
.
In this case, items not contained in obj
are dropped in the output.
A list with data
, key
, and eventually weights
.
Michela Battauz
data(test) data(key) testk <- addkey(test, keydata = key)
data(test) data(key) testk <- addkey(test, keydata = key)
Adds the weights associated with the responses to the items to a data frame.
addweights(obj, weightsfile = NULL, weightsdata = NULL)
addweights(obj, weightsfile = NULL, weightsdata = NULL)
obj |
An object containing the data imported by function |
weightsfile |
the name of the file with the weights. Column names should match the names of the items. |
weightsdata |
an R data frame containing the weights. Column names should match the names of the items. |
If weightsfile
and weightsdata
have only one row, they should contain the weights that
are assigned to the correct responses. These are defined by addkey
.
To specify a different weight to every response of each item, weightsfile
and weightsdata
should have one row for each response. In this case there should be a field named response
.
weightsfile
and weightsdata
can contain more items than obj
.
In this case, items not contained in obj
are dropped in the output.
A list with data
, eventually key
, and weights
.
Michela Battauz
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple)
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple)
Calculates and plots the absolute or percentage frequencies of the responses to each item.
freq(obj, columns, perc = FALSE) ## S3 method for class 'frlist' plot(x, display = TRUE, ask = TRUE, ...)
freq(obj, columns, perc = FALSE) ## S3 method for class 'frlist' plot(x, display = TRUE, ask = TRUE, ...)
obj |
An object containing the data imported by function |
columns |
A vector containing which columns to use. Columns can be specified by name or number. |
perc |
logical; if |
x |
An object of class |
display |
logical; if |
ask |
logical; if |
... |
further arguments passed to or from other methods. |
Function freq
returns an abject of class frlist
containing a list with components
item |
the name of the item. |
tab |
an object of class |
key |
the key of the item. |
Michela Battauz
data(test) data(key) testk <- addkey(test, keydata = key) fr <- freq(obj = testk, col = c("Question03", "Question04")) fr par(mfrow=c(1,2)) plot(fr, ask = FALSE) fr <- freq(obj = testk, col = 2:11, perc = TRUE) fr par(mfrow = c(2,5)) plot(fr, ask = FALSE)
data(test) data(key) testk <- addkey(test, keydata = key) fr <- freq(obj = testk, col = c("Question03", "Question04")) fr par(mfrow=c(1,2)) plot(fr, ask = FALSE) fr <- freq(obj = testk, col = 2:11, perc = TRUE) fr par(mfrow = c(2,5)) plot(fr, ask = FALSE)
This function computes some statistics for each item.
item.stat(obj, columns, weights = FALSE)
item.stat(obj, columns, weights = FALSE)
obj |
An object containing the data imported by function |
columns |
A vector containing which columns to use. Columns can be specified by name or number. |
weights |
Logical. If TRUE weights are used to compute the score. |
A data frame with the following variables.
item |
item label. |
score |
total score for each item. If |
max |
maximum score for each item. |
perc |
ratio between score and max. |
Michela Battauz
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) # number of correct responses for each item ist <- item.stat(obj = testk, col = 2:41) head(ist) # sum of weights of correct responses for each item ist <- item.stat(obj = testw, col = 2:41, weights = TRUE) head(ist) # sum of weights of every response for each item ist <- item.stat(obj = testwm, col = 2:41, weights = TRUE) head(ist)
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) # number of correct responses for each item ist <- item.stat(obj = testk, col = 2:41) head(ist) # sum of weights of correct responses for each item ist <- item.stat(obj = testw, col = 2:41, weights = TRUE) head(ist) # sum of weights of every response for each item ist <- item.stat(obj = testwm, col = 2:41, weights = TRUE) head(ist)
This data set contains the correct responses of the items in the test data set.
data("key")
data("key")
A data frame with variables Question01 - Question40
.
Michela Battauz
data(key) key
data(key) key
This function computes some statistics for each person.
person.stat(obj, columns, weights = FALSE)
person.stat(obj, columns, weights = FALSE)
obj |
An object containing the data imported by function |
columns |
A vector containing which columns to use. Columns can be specified by name or number. |
weights |
Logical. If TRUE weights are used to compute the score. |
A data frame with the following variables.
id |
person label. |
score |
total score for each person. If |
max |
maximum score for each person. |
perc |
ratio between score and max. |
Michela Battauz
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) # number of correct responses for each person (only 4 items) pst <- person.stat(obj = testk, col = 2:5) pst # sum of weights of correct responses for each person pst <- person.stat(obj = testw, col = 2:5, weights = TRUE) pst # sum of weights of every response for each person pst <- person.stat(obj = testwm, col = 2:5, weights = TRUE) pst
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) # number of correct responses for each person (only 4 items) pst <- person.stat(obj = testk, col = 2:5) pst # sum of weights of correct responses for each person pst <- person.stat(obj = testw, col = 2:5, weights = TRUE) pst # sum of weights of every response for each person pst <- person.stat(obj = testwm, col = 2:5, weights = TRUE) pst
This data set contains responses to a questionnaire.
data("questionnaire")
data("questionnaire")
A data frame with 5 observations on the following 14 variables.
File.name |
file name. |
Q1.gender |
gender. |
Q2.age |
age. |
Q3.restaurants |
how often eat at restaurants. |
Q4.movies |
watching movies is fun. |
Q4.music |
I like listening to music. |
Q4.reading |
reading is an indispensable part of life. |
Q5.sources |
sources of information. |
Q6.interviewer |
interviewer. |
Q5.sources.internet |
dummy variable for response internet. |
Q5.sources.magazines |
dummy variable for response magazines. |
Q5.sources.newspapers |
dummy variable for response newspapers. |
Q5.sources.radio |
dummy variable for response radio. |
Q5.sources.TV |
dummy variable for response TV. |
This data set is obtained by importing file "scan_results_questionnaire.csv"
with function read.formscanner
.
Michela Battauz
data(questionnaire) questionnaire
data(questionnaire) questionnaire
This function imports data from the FormScanner software.
read.formscanner(file, col.names, conc = NULL, id = NULL, dummy = NULL)
read.formscanner(file, col.names, conc = NULL, id = NULL, dummy = NULL)
file |
the name of the csv file to be imported. |
col.names |
the names of the columns. If |
conc |
a vector containing which columns to concatenate. Columns can be specified by name or number. |
id |
name of the column that uniquely identifies the row. |
dummy |
a vector containing the columns to convert to dummy variables. Columns can be specified by name or number. |
If some columns are concatenated using argument conc
,
the name of the newly created variable is the name of the first column.
test
and questionnaire
are instances of the output of function read.formscanner
.
When id
is obtained as the concatenation of different columns
using argument conc
, id
should be set equal to the first column concatenated.
A data frame.
Michela Battauz
Borsetta, A. (2016). FormScanner, [Computer Software], URL http://sourceforge.net/projects/formscanner/.
# find the directory with package fsia dir_pkg <- find.package("fsia") # the example files are in the directory examples # create the path questionnaire_path <- file.path(dir_pkg, "examples", "scan_results_questionnaire.csv") test_path <- file.path(dir_pkg, "examples", "scan_results_test.csv") # import file "scan_results_questionnaire.csv" questionnaire_imp<-read.formscanner(questionnaire_path, dummy = "Q5.sources") questionnaire_imp # questionnaire_imp is equal to the data questionnaire # import file "scan_results_test.csv" test_imp <- read.formscanner(test_path, conc = paste("id", 1:6, sep = ""), id = "id1") test_imp # test_imp is equal to the data test
# find the directory with package fsia dir_pkg <- find.package("fsia") # the example files are in the directory examples # create the path questionnaire_path <- file.path(dir_pkg, "examples", "scan_results_questionnaire.csv") test_path <- file.path(dir_pkg, "examples", "scan_results_test.csv") # import file "scan_results_questionnaire.csv" questionnaire_imp<-read.formscanner(questionnaire_path, dummy = "Q5.sources") questionnaire_imp # questionnaire_imp is equal to the data questionnaire # import file "scan_results_test.csv" test_imp <- read.formscanner(test_path, conc = paste("id", 1:6, sep = ""), id = "id1") test_imp # test_imp is equal to the data test
This function produces a graphic with the responses given by one or a few subjects and shows the correct ones.
report(obj, columns, whichid, grid = TRUE, main = "", las = 0, itemlab = NULL, weights = FALSE)
report(obj, columns, whichid, grid = TRUE, main = "", las = 0, itemlab = NULL, weights = FALSE)
obj |
An object containing the data imported by function |
columns |
A vector containing which columns to use. Columns can be specified by name or number. |
whichid |
A vector containing the values of variable |
grid |
logical; if |
main |
an overall title for the plot. |
las |
numeric in 0,1,2,3; the style of axis labels (see |
itemlab |
labels of the items. |
weights |
logical. If |
Correct responses are colored green, wrong responses are colored red.
Michela Battauz
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) par(mfrow = c(1, 2)) report(obj = testk, col = 2:11, whichid = c("102344", "245784")) report(obj = testw, col = 2:11, whichid = c("102344", "245784"), weights = TRUE) par(mfrow = c(1, 1)) report(obj = testwm, col = 2:11, whichid = c("102344", "245784"), weights = TRUE)
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) par(mfrow = c(1, 2)) report(obj = testk, col = 2:11, whichid = c("102344", "245784")) report(obj = testw, col = 2:11, whichid = c("102344", "245784"), weights = TRUE) par(mfrow = c(1, 1)) report(obj = testwm, col = 2:11, whichid = c("102344", "245784"), weights = TRUE)
Converts data to binary (correct/incorrect) responses, according to the key.
resp2binary(obj, columns)
resp2binary(obj, columns)
obj |
An object containing the data imported by function |
columns |
A vector containing which columns to use. Columns can be specified by name or number. |
The data frame data
contained in obj
with columns
replaced by binary data.
Michela Battauz
data(test) data(key) testk <- addkey(test, keydata = key) resp01 <- resp2binary(obj = testk, col = 2:41) resp01
data(test) data(key) testk <- addkey(test, keydata = key) resp01 <- resp2binary(obj = testk, col = 2:41) resp01
Assigns a weight to the responses.
resp2scores(obj, columns)
resp2scores(obj, columns)
obj |
An object containing the data imported by function |
columns |
A vector containing which columns to use. Columns can be specified by name or number. |
The data frame data
contained in obj
with columns
replaced by scored responses.
Michela Battauz
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) # ASSIGN WEIGHTS TO RESPONSES resps <- resp2scores(obj = testw, col =2:41) resps[, 2:5] # ASSIGN WEIGHTS TO RESPONSES (MULTIPLE WEIGHTS) resps <- resp2scores(obj = testwm, col =2:41) resps[, 2:5]
data(test) data(key) data(weights) data(weights_multiple) testk <- addkey(test, keydata = key) testw <- addweights(testk, weightsdata = weights) testwm <- addweights(test, weightsdata = weights_multiple) # ASSIGN WEIGHTS TO RESPONSES resps <- resp2scores(obj = testw, col =2:41) resps[, 2:5] # ASSIGN WEIGHTS TO RESPONSES (MULTIPLE WEIGHTS) resps <- resp2scores(obj = testwm, col =2:41) resps[, 2:5]
This data set contains multiple choice responses to 40 items.
data("test")
data("test")
A data frame with 5 observations on the following 44 variables.
File.name |
file name. |
Question01-Question40 |
responses given to the items. |
i.course |
course, |
i.university |
university. |
id |
identification number. |
This data set is obtained by importing file "scan_results_test.csv"
with function read.formscanner
.
Michela Battauz
key
, read.formscanner
, weights
, weights_multiple
data(test) test
data(test) test
This data set contains the weights of the correct responses of the items in the test data set.
data("weights")
data("weights")
A data frame with variables Question01 - Question40
.
Michela Battauz
data(weights) weights
data(weights) weights
This data set contains the weights of each responses of the items in the test data set.
data("weights_multiple")
data("weights_multiple")
A data frame with variables
response |
responses A, B, C, D. |
Question01-Question40 |
weights for each response to each item. |
Michela Battauz
data(weights_multiple) weights_multiple
data(weights_multiple) weights_multiple