Skip to contents

Add data to a PSA package

Usage

psa_data(
  data,
  title,
  desc,
  vardesc = list(),
  author = "PSA",
  source = NULL,
  write = TRUE,
  filetype = "csv",
  projdir = "."
)

Arguments

data

the data as a data frame

title

short title of the data

desc

longer description of the data

vardesc

list containing a vector of column names and labels (see faux::codebook for details)

author

authors

source

URL for the source, if blank, links to the file in data-raw

write

whether to create/overwrite the package R file for this data set

filetype

type of file to save data as in the R package

projdir

base directory of project

Value

text of the R file

Examples


if (FALSE) { # \dontrun{
  # simulate a small data set
  demo <- data.frame(
    id = rep(1:3, each = 4),
    trial = rep(1:4, times = 3),
    condition = rep(c("ctl", "exp"), 6),
    rt = rnorm(12, 1000, 300)
  )

  # set up variable descriptions
  vars <- list( description = c(
    id = "Subject identifier",
    trial = "Trial number",
    condition = "Trial condition (ctl or exp)",
    rt = "Reaction time in ms"
  ))

  # add to package
  psa_data(data = demo,
           title = "Demo Data",
           desc = "Demonstrate how to add data to a PSA project",
           vardesc = vars)
} # }