Last chance! 50% off unlimited learning
Sale ends in
Validate the column name of a data frame
val_cname(tracks, cname, type = "", size = 0, force = 2, def = TRUE)
psyo
. Data frame with tracks.
character
. Column name of column in tracks
that is to be validated.
character
. Type of column in tracks
determined by mode
.
size
. Observation count of column in tracks
determined by length
.
logical. Ignore this check if cname = ""
.
character
# NOT RUN {
\dontrun{
data(psyo)
# Test t_id
t1 <- psyo
t_id <- "id"
e <- val_cname(t1, t_id, size = 15, type = "numeric"); if (e != "") {stop(e)}
# Be aware that id column is saved as "factor" and therefore mode() returns
# numeric.
t2 <- psyo
t_id <- 1
e <- val_cname(t2, t_id); if (e != "") {stop(e)}
t3 <- psyo
t_id <- "id"
e <- val_cname(t3, t_id, size = 15, type = "character"); if (e != "") {stop(e)}
t4 <- psyo
t_id <- "id"
e <- val_cname(t4, t_id, size = 20); if (e != "") {stop(e)}
t5 <- psyo
t_id <- "id"
e <- val_cname(t5, t_id, size = "20"); if (e != "") {stop(e)}
}
# }
Run the code above in your browser using DataLab