QScript ValueAttributes

From Q
Jump to navigation Jump to search

ValueAttributes

Values for a question or a single variable. Equivalent to the screen that appears when you click the "..." button in the Variables and Questions tab. Use question.uniqueValues to get the list of available values to use with these methods.

equals(obj)

Whether two objects are the same.
objThe object to compare against.
Returns:true or false
Example:
data_file.getQuestionByName('Q2').equals(data_file.questions()[0])

getCountThisValue(source_value)

Applied to Pick Any questions, this indicates whether a value in the data is counted as a positive response (ticked).
source_valueThe source (original) value.
Returns:true if counted, else false
Example:
v.valueAttributes.getCountThisValue(7)

getIsMissingData(source_value)

Whether this value when encountered should be treated as missing data.
source_valueThe source (original) value.
Returns:true or false

getLabel(source_value)

Gets the label for a data value.
source_valueThe source (original) value.
Returns:The label. If no label has been specified (either in the raw data, or by calling setLabel), then then a string containing the number is returned.

getSourceLabel(source_value)

Gets the source label for a data value.
source_valueThe source (original) value.
Returns:The label specified for this value in the raw data.

getSourceValueByLabel(label)

Searches for an attribute with the supplied label, and returns its source value, which is what you need in the other methods of this class.
labelThe label to search for.
Returns:A number.

getValue(source_value)

Gets the value Q uses for calculations when it encounters a particular value in the source data.
source_valueThe source (original) value.
Returns:The value used in calculations. If no override has been set then the original value will be returned.

knownValues

This will only list the values for which we have attributes (e.g. labels).^M If you need all values in the variable then you need QScriptVariable.uniqueValues.
Returns:An array of numbers or strings, depending on whether the variable(s) are^M numeric.

length

Returns the number of unique values.

setCountThisValue(source_value, count)

Sets whether a data value is counted as a positive response (ticked).
source_valueThe source (original) value.
countWhether to count it (true or false).

setIsMissingData(source_value, is_missing)

Sets whether a value in the data should be treated as missing data.
source_valueThe source (original) value.
is_missingtrue or false

setLabel(source_value, label)

Overrides the label associated with a particular data value.
source_valueThe source (original) value.
labelThe new label.

setValue(source_value, value)

Overrides the value that Q uses for calculations (e.g averages) when it encouters a particular value in the source data.
source_valueThe source (original) value.
valueThe value to use in calculations.

type

Returns 'ValueAttributes'.