Grapheme-class: A Reference Class for representing consistency test graphemes

Description Fields Methods Examples


A Reference Class for representing consistency test graphemes



A one-element character vector containing the symbol/set of symbols that describe(s) the grapheme, e. g. '7' or 'Monday'. Set at class new() call or using set_symbol method.


A matrix where each row specifies color coordinates for each participant response. Set using set_colors method.


A numeric vector of response times. Set using set_times method.


A one-element character vector which describes the color space that response colors are coded in. Set when using set_colors method.



Return a short (3 character) representation of the grapheme's symbol.

get_consistency_score(na.rm = FALSE, method = "euclidean")

Calculate the consistency score based on the Grapheme instance's response colors. Throws an error if no responses have been registered yet. Always returns NA if all grapheme responses are NA. If na.rm=FALSE, returns NA if any grapheme response is NA. If na.rm=TRUE, returns the consistency score for non-NA responses. This function relies on the base/stats function dist() and so supports only distance calculation methods implemented by dist() (use help(dist) to learn more about it).

get_mean_color(na.rm = FALSE)

Average all registered response's colors and return the result (using the color space set at grapheme initialization) as a 3-element vector.

get_mean_response_time(na.rm = FALSE)

Get the mean of the grapheme's associated response times.


Get the number of response colors that are non-NA, returned as a one-element numeric vector.


Get a list of the grapheme's data, bundled up in a format ready for use in Participant.get_plot_data() method as a row of plot data.


Returns TRUE if the grapheme only has responses with valid colors, FALSE if there are responses with nonvalid colors or there are no responses at all.

set_colors(hex_codes, color_space_spec)

Set response colors, using passed RGB hex codes. Converts the hex codes to color coordinates in the specified color space. Supports the following color spaces: "XYZ", "sRGB", "Apple RGB", "Lab", and "Luv". For all NA values passed, a row of NA values will be included in the matrix (preserving order of responses). Returned/set response colors are in the format of a matrix where each row represents one response/color, and each column represents one color coordinate axis (there are always 3 axes used for the currently supported color spaces)


Set the grapheme's symbol attribute, using a passed one-element character vector.


Add response times, using passed numeric vector.


a <- synr::Grapheme$new(symbol='a')
a$set_colors(c("#101010", NA), "Luv")
a$set_times(c(5, 10))

synr documentation built on Nov. 25, 2021, 1:06 a.m.