Learn R Programming

PsychWordVec (version 2025.3)

sum_wordvec: Calculate the sum vector of multiple words.

Description

Calculate the sum vector of multiple words.

Usage

sum_wordvec(data, x = NULL, verbose = TRUE)

Value

Normalized sum vector.

Arguments

data

A wordvec (data.table) or embed (matrix), see data_wordvec_load.

x

Can be:

  • NULL: use the sum of all word vectors in data

  • a single word: "China"

  • a list of words: c("king", "queen")

    cc(" king , queen ; man | woman")

  • an R formula (~ xxx) specifying words that positively and negatively contribute to the similarity (for word analogy): ~ boy - he + she ~ king - man + woman ~ Beijing - China + Japan

verbose

Print information to the console? Defaults to TRUE.

Download

Download pre-trained word vectors data (.RData): https://psychbruce.github.io/WordVector_RData.pdf

See Also

normalize

most_similar

dict_expand

dict_reliability

Examples

Run this code
sum_wordvec(normalize(demodata), ~ king - man + woman)

Run the code above in your browser using DataLab