classify: A function to enter data from RICH economic games...

View source: R/classify.R

classifyR Documentation

A function to enter data from RICH economic games automatically

Description

This function allows you to speed up data entry. Simply set a path to the main folder.

Usage

classify(
  path,
  PID = "CTR",
  HHID = "FKA",
  RID = "CR",
  day = 12,
  month = 4,
  year = 2020,
  name = "Cody",
  panels = c("A", "B"),
  questions = c("Friendship, Wealth"),
  game = "PeerRatings",
  order = "ABCD",
  revise = FALSE,
  pattern = ".jpg",
  start = 1,
  stop = 3,
  seed = 1,
  n_panels = 4,
  n_rows = 5,
  n_cols = 9,
  ordered_ids = NULL,
  thresh = c(0.075, 0.075, 0.075),
  lower_hue_threshold = c(135, 265, 175),
  upper_hue_threshold = c(175, 310, 215),
  plot_colors = c("empty", "seagreen4", "purple", "navyblue"),
  lower_saturation_threshold = 0.1,
  lower_luminance_threshold = 0.12,
  upper_luminance_threshold = 0.88,
  border_size = 0.22,
  iso_blur = 0,
  direction = "forward",
  alert_mode = "off",
  automate = TRUE,
  d_x = 20,
  d_y = 20
)

Arguments

path

Full path to main folder.

PID

Unique ID of focal individual/respondent.

HHID

Household ID of focal individual/respondent.

RID

ID of researcher.

day

Day of interview.

month

Month of interview.

year

Year of interview.

name

Name of focal individual/respondent.

panels

ID codes used to indicate panel.

questions

ID codes used to indicate questions.

game

ID for the folder in which these data will be saved.

order

Order of frames/panels of photos as presented to the respodent: e.g., with 4 frames, "ABCD", "CDBA", etc. are legal entries.

revise

When set to TRUE, the classification function is run, without requiring the corners to be redetected.

pattern

File extension of photos. Should be ".jpg" or ".JPG".

start

Location of start of PID in file name. If files are saved as "XXX.jpg" for example, this is 1.

stop

Location of end of PID in file name. If files are saved as "XXX.jpg" for example, this is 3.

seed

A seed for the random number generator to sort the order of photos in the array. This should match the seed used to make the survey.

n_panels

Number of frames/panels/blocks of photos to be output. I use four big panels and randomize order at each game.

n_rows

Number of rows per panel. With 7cm x 10cm photos, I use five rows of photos per panel.

n_cols

Number of rows per panel. With 7cm x 10cm photos, I use six to eight cols of photos per panel.

ordered_ids

A list of IDs if photograph order is to be explicilty coded. This overwrites random sorting.

thresh

Difference in hue density between pre- and post-treatment game boards required to code a token color as present. Can be vectorized if mulple token colors are in use: e.g., c(0.05, 0.35, 0.05).

lower_hue_threshold

A vector of lower hue thresholds for each token color. To use three token colors, instead of the single token in the defaults, use: e.g., c(120, 210, 330).

upper_hue_threshold

A vector of upper hue thresholds for each token color. To use three token colors, instead of the single token in the defaults, use: e.g., c(150, 250, 355).

plot_colors

A vector of labels indicating which token color was used. The first entry must say "empty", other colors can be named as desired, but must be real color names in R. These colors correspond to the above-listed token hues, and this vector should be one cell longer than the hue threshold vectors.

lower_saturation_threshold

Lower limit of greyness before the hue of such pixels is excluded from density calculations.

lower_luminance_threshold

Lower limit of darkness before the hue of such pixels is excluded from density calculations.

upper_luminance_threshold

Upper limit of lightness before the hue of such pixels is excluded from density calculations.

border_size

Image border excluded from density calculations as a fraction of image size.

iso_blur

Width of Gaussian filter applied to image. A value of 0 turns off blurring.

direction

How image skew is corrected. The "forward" algorithm is fast but lower quality. The "backward" algorithm is slow but higher quality. See imwarp function in imager package for technical details.

alert_mode

Audio alert when data entry finishes. Set to "50_Cent" for random lyrics off the hit song "In da Club" (warning, explicit content"), or "Beep" for a borning notification.

automate

will corners be selected manually, or automatically?

d_x

x width of kernel used to scan for corners

d_y

y width of kernel used to scan for corners


ctross/DieTryin documentation built on Sept. 8, 2024, 8:07 p.m.