surveyeditor (version 1.0)

slide: Survey/questionnaire slides

Description

This function generates slides for displaying information (including questions to be asked) and for the subjects to insert answers. 7 types of slides are available (the argument type specifies this; see Arguments below). For type=1 or 2, the slide is solely for display purpose (e.g. showing the instructions of the survey or background information) and responses from the subject are not needed. For other values of type, a 5-column matrix is returned. The column names are ID, Question.number, type, Condition.Likert and Response. Also see Values below. The number of rows is determined by the number of responses gathered by the slide. For example, for type=2 only one reponse is allowed to be given by the subject therefore there will be a 1x5 matrix returned. The below table (in a few partitions) shows the number of allowed responses for different values of type, ccc{ type= Slide type Allowed responses ----- -------------------------------------------- ------------------------------------------------------ 1 Time-restricted display 0 2 Time-unrestricted display 0 3 Numerical response display 1 4 Multiple choice response display Freely set and up to the number of available choices (n.select) 5 Sequential Likert-scale response display The number of conditions given (the length of cond) 6 "Number line marking" response display Freely set (n.select) 7 Gabor-Granger method display 1 }

Usage

slide(id, type, title, content, h, v, size, col, time = NULL, interval = c(-Inf, Inf),
isinteger = F, choices = NULL, layout = NULL, n.select = NULL, box.level = NULL,   
cond = NULL, scale = NULL, grid = NULL, range = NULL, unit = NULL, initial = NULL,  
increment = NULL, order = c("ascending", "descending"), Extra = NULL, Line.draw = NULL)

Arguments

id
numeric(1); The id of the subject. It is part of the returning value of the function (ID) for the purpose of identifying the subject.
type
numeric(1), 1,2,...,7; specifies the type of the slide. Details as below,
  1. Time restricted display that does not allow the subject to enter any answer (that is, for display information only) and that information is displayed for a limited
title
character(1); the title to be displayed on the top of the slide. Should be made as short as possible since it will appear in one of the returning values Question.number. In fact, it is recommended to use titles like "Question 1" and "Demop
content
character(); texts to be displayed in the slide. It can be a vector c( ) containing multiple items. Each item must be quoted. Note: for type=5 or 7 the first component becomes the question that cond
h
numeric(), [0,100];the horizontal location of content hence its length must be the same as that of content. Must be in the interval [0,100].
v
numeric(), [0,100];the vertical location of content hence its length must be the same as that of content. Must be in the interval [0,100].
size
numeric(); the font size of content hence its length must be the same as that of content.
col
character(); the colour of content hence its length must be the same as that of content.
time
(only applies to type=1); numeric(1) the amount of time (in seconds) that the slide is displayed.
interval
(only applies to type=3); numeric(2) the permitted interval the numerical response can fall within.
isinteger
(only applies to type=3); logical(1) TRUE if the numerical response is only allowed to be an integer.
choices
(only applies to type=4); character() or numeric() the choices the subject can choose from.
layout
(only applies to type=4); numeric(2) the layout (number of rows and columns respectively) of the choices.
n.select
(only applies to type=4,6); numeric(1) the number of choices can be selected if type=4 or the number of selection can be made if type=6.
box.level
(only applies to type=3,4,5,6,7); numeric(2), [0,100] if type=3 defines the vertical location of the top of the first box of the choices. numeric(1), [0,100] if type=4,5,6,7 defines the horizontal
cond
(only applies to type=5); character() or numeric() a vector of conditions asked in the sequential Likert-scale question. Example: if content=c("The price is","Please choose one of the following") and
scale
(only applies to type=5); character() or numeric() a set of Likert items the subject can choose from.
grid
(only applies to type=6); numeric(1) the number of minor grids lines to be drawn in between any two tick marks in range.
range
(only applies to type=6); numeric(3) a set of numbers to be displayed as ticks on the number line. The maximum and the minimum become the two ends of the number line.
unit
(only applies to type=6); character(1) or numeric(1) to be displayed as the unit (such as "$", "%", etc.) of the figures on the number line. This is placed right underneath the number line.
initial
(only applies to type=7); numeric(1) the starting value serves as the condition attached to the first sequential question in Gabor-Granger method. Subsequent conditions will decrease (if order="descending") or increas
increment
(only applies to type=7); numeric(1) the amount that the condition increases or decreases by (see initial above).
order
(only applies to type=7); "ascending" or "descending" It defines increasing or decreasing conditions attached to the sequential question.
Extra
See Details below for usage and details list( list(), list() ,...) A list (with usage: Extra=list()) contains another sub-list or multiple sub-lists. Each sub-list refers to a table or a diagram to be displayed hence
Line.draw
See Details below for usage and details Any quoted R commands in the form of character( ) (example: c("abline(v=0, col='red')","lines(seq(-10,20,0.01),seq(-10,20,0.01)*1.2+100, col='yellow')")) These com

Value

  • A 5-column matrix is returned in the R console. The column names are ID, Question.number, type, Condition.Likert and Response.
    • IDshowsid.
    • Question.numberistitlebut without spaces.
    • typeistype, the slide type (a integer between 1 and 7).
    • Condition.Likertis thecondin the sequential Likert-scale question, shown asNAiftypeis not7.
    • Responseis the response given by the subject. Therefore, the number of rows may vary depending on number of the response. The returning values of each slide type is described below,
      1. No values returned.
      2. No values returned.
      3. The numerical response given by the subject by clicking the virtual keyboard upon the restrictions ofintervalandisinteger.
      4. A number representing the choice selected (i.e. "1" refers to the first choice being selected, "2" to the second, ...). The number of rows then depends on how many choices the subject is allowed to select as controlled byn.select.
      5. The exact choice (one of the items inscale) the subject selects. That is, ifscaleis of character() so is the response. The number of rows depends on the number of conditions being asked (i.e. length ofcond). Also seeCondition.Likertabove for another returning value.
      6. A number that the mark (or marks if multiple selections allowed) represents on the number line. The number of rows then depends on how many selections (i.e. marks) the subject is allowed to make as controlled byn.select.
      7. The number (the price in the Gabor & Granger 1966 1979) asked in the sequential question in which the subject answers "No".

Returning graphics of examples

slide01.jpeg
slide02.jpeg
slide03.jpeg
slide04.jpeg
slide05.jpeg
slide06.jpeg
slide07.jpeg

Details

Extra This argument aims to create plots and tables in the slide hence Extra is one of the optional arguments in slide. The usage of this argument must follow the list containing sub-lists format: slide(... ,Extra=list( list(), ... ), ...). For example, Extra=list(list(...,type="p",...),list(type=...,"p",...) ,list(type=...,"t",...)) refers to two point plots and a table to be created while Extra=list(list(type="h2",...) while refers to a relative-frequency histogram to be created. The "list containing sub-lists" format must always be used regardless of the number of plots and tables. What arguments are required in each sub-list depend on type. The below table (in a few partitions) gives a summary, cccc{ type= loc sub-list[[1]] sub-list[[2]] ------------------------------------------ ---------------- ------------------ ------------------ p (Point plot) Required Required Required l (Line plot) Required Required Required b (Both point & line plot) Required Required Required h1 (Histogram Required Required with frequency) h2 (Histogram with Required Required relative frequency) t (Table) Required ------------------------------------------ ---------------- ------------------ ------------------ Input type: numeric(4) numeric() numeric() or character() } cccc{ type= ticks xlabl ylabl ------------------------------------------ ------------------- ------------------- ------------------- p (Point plot) Required Optional Optional l (Line plot) Required Optional Optional b (Both point & line plot) Required Optional Optional h1 (Histogram Required Optional Optional with frequency) h2 (Histogram with Required Optional Optional relative frequency) t (Table) ------------------------------------------ ------------------- ------------------- ------------------- Input type: list(2) if type="p","l","b" character(1) character(1) or list(1) if type="h1","h2" } ccccc{ type= title col table size ------------------------------------------ ------------------- ------------------- ------------------- ------------------- p (Point plot) Optional l (Point plot) Optional b (Both point & line plot) Optional h1 (Histogram Optional Optional with frequency) h2 (Histogram with Optional Optional relative frequency) t (Table) Required Required ------------------------------------------ ------------------- ------------------- ------------------- ------------------- Input type: character(1) character() matrix() numeric(3) }
  • loc:numeric(4)the location of the plot or table. These four numbers defines the left, lower, right and upper bound of the plot or table.
  • sub-listlist[[1]]:numeric() or character()The first component of the sub-list. Iftype="p","l"or"b", this is the data shown on the x-axis. Iftype="h1"or"h2", this is the data whose frequency or relative frequency will be evaluated.
  • sub-listlist[[2]]:numeric()The second component of the sub-list, this is the data shown on the y-axis.
  • ticks:list(2) if type="p","l","b" or list(1) if type="h1","h2"Fortype="p","l"or"b",ticks[[1]]andticks[[2]]become the tick marks of the x- and y-axis respectively. Fortype="h1"or"h2",ticks[[1]]becomes the tick marks on the y-axis.
  • xlabl:character()The lable of the x-axis. The name attached tolist[[1]]will be used instead.
  • ylabl:character()The lable of the y-axis. The name attached tolist[[2]]will be used instead.
  • title:character()The title of the plot.
  • col:character()The colour of each bar fortype="h1","h2". The bars are not coloured (or white) if NULL.
  • table:a matrix with dimnames( ). The table will be created with the dimension and, with the row & column names the same as that oftable.
  • item:numeric(3)refers to the font size of the row, column names then in-table information.
Line.draw A single or a set of double quoted R commands. Any texts in between the quotes will be executed. A vector c( ) is used for multiple commands. Since the double quotes are reserved in this case, single quotes should be used in the commands instead. For example, Line.draw="abline(v=0,col='red')" instead of Line.draw="abline(v=0,col="red")".

References

Gabor, G & Granger, CWJ (1966) "Price as an indicator of Quality: Report on an Enquiry", Economica, 33(129), pp.43-70. Gabor, G & Granger, CWJ (1979) "The Attitude of the Consumer to Prices", Management Decision, 17(8), pp.619-634. Kanayet, F & Opfer, J (2009) "Why Children's Number-line Estimates Follow Fechner's Law", Cognitive Science Conference Proceedings 2009, pp.1936-41. Siegler, RS & Opfer, JE (2003) "The Development of Numerical Estimation: Evidence for Multiple Representations of Numerical Quantity", Psychological Science, 14(3), May 2003, pp.237-243.

See Also

cover,identity,read.write

Examples

Run this code
slide(id=1234,type=1,title="Question 1",content=c("Testing1","Testing2"),
h=c(0,0),v=c(100,80),size=c(3,2),col=c("blue","pink"),time=4,Line.draw=c("abline
(h=seq(0,100,50),col='red',lty=4)","abline(v=seq(0,100,100),col='green')"))
slide(id=1234,type=2,title="Instructions",content=c("* Please give 
genuine response according to your belief.","* Any part of the survey is 
irreversible meaning that you cannot change the\n response you give in the previous 
slide.","* Once you click on any green button you proceed to the next slide."),
h=c(0,0,0),v=c(80,70,55),size=c(2,2,2),col=c("black","black","black"))
slide(id=1234,type=3,title="Question 2",content="What is the average 
score of all groups?",h=0,v=100,size=2,col="black",box.level=c(70,100),Extra=list
(list(date=c(rep("Boys-Pass",6),rep("Girls-Pass",4),rep("Boys-Fail",4),
rep("Girls-Fail",2)),type="h1",loc=c(10,30,40,60),ticks=list(seq(0,6,1)),
xlabl="Grades",ylabl="Number\nof\nass\n& fail",title="Grade distribution",
col=c(rep("skyblue",2),rep("red",2))),list(Table=matrix(c(rep(c("M","F"),2),
round(rnorm(4,100,10),2),rep("Test A",2),rep("Test B",2)),ncol=4,byrow=T,
dimnames=list(c("Gender","Average\nScore","Test\ntype"),paste("Group",1:4))),
size=c(1.5,1.5,2),type="t",loc=c(55,30,90,60))))
slide(id=123,type=4,title="Question 3",content=c("What do you think 
the return on the 2015-May-21 will be?","Please choose one of the followings"),
h=c(0,0),v=c(90,80),size=c(2,1.5),col=c("black","blue"),choices=c("Goes down",
"Remains the same","Goes up"),layout=c(1,3),box.level=75,n.select=1,
Extra=list(list(Date=paste("2015-May-",1:20,sep=""),return=rnorm(20),type="b",
loc=c(20,10,80,50),ticks=list(c(seq(0,20,5)),c(seq(-2,3,1))),ylabl="Return",
title="Daily return")))
slide(id=123,type=5,title="Question 4",content=c("The market price is 
$","(0 refers to 'Strongly disagree' ... 5 refers to 'Strongly agree')"),
h=c(0,0),v=c(80,70),size=c(2,1.5),col=c("black","orange"),cond=seq(10,12,0.5),
scale=seq(0,5,0.5),box.level=50)
slide(id=123,type=6,title="Question 5",content="Within which two numbers
 do you think the return on the 2015-May-21 will fall into?",h=0,v=100,size=2,
col="black",range=seq(-3,3,1),grid=5,unit="%",box.level=85,n.select=2,Extra=
list(list(Date=paste("2015-May-",1:20,sep=""),return=rnorm(20),type="b",loc=
c(20,10,80,45),ticks=list(c(seq(0,20,5)),c(seq(-2,3,1))),ylabl="Return",title=
"Daily return")))
slide(id=123,type=7,title="Question 6",content="Would you take the milk 
if it costs $",h=0,v=80,size=2,col="black",initial=3,increment=1,order="descending"
,box.level=70)

Run the code above in your browser using DataLab