Learn R Programming

soundcorrs (version 0.4.0)

long2wide: Convert from the long format (single entry per row) to the wide format (multiple entries per row).

Description

Takes a data frame of word pairs/triples/..., each stored in multiple rows, and returns a data frame with the same words but each pair/triple/... stored in one row. WARNING: in the original data frame, entries from all languages must be in the same order.

Usage

long2wide(data, col.lang = "LANGUAGE", skip = NULL)

Arguments

data

[data.frame] The dataset to be converted.

col.lang

[character] Name of the column with language names. Defaults to "LANGUAGE".

skip

[character vector] Names of columns to not convert. Defaults to NULL.

Value

[data.frame] A data frame in the wide format (multiple entries per row).

Details

Data for soundcorrs can be prepared in one of two formats: the 'long format' and the 'wide format'. In the 'long format', each row contains only a single word and metadata associated with it. In the 'wide format', each row contains the entire pair/triple/... of words, and all the metadata associated with them. The 'long format' is convenient for making sure that all the words in a pair/triple/... have the same number of segments, but it cannot be read directly by soundcorrs. long2wide and wide2long convert between the two formats.

See Also

wide2long

Examples

Run this code
# NOT RUN {
# path to sample data in the "long format"
fName <- system.file ("extdata", "data-abc.tsv", package="soundcorrs")
long <- read.table (fName, header=TRUE)
wide <- long2wide (long, skip=c("ID"))
# }

Run the code above in your browser using DataLab