Learn R Programming

kutils (version 0.93)

keyDiff: Compares a key provided to keyUpdate with the return of keyUpdate

Description

Compares a key provided to keyUpdate with the return of keyUpdate

Usage

keyDiff(oldkey, newkey)

Arguments

oldkey
key that was provided to keyUpdate function
newkey
updated key returned by keyUpdate function

Value

summary of differences between the two keys

Examples

Run this code
library(rockchalk)
dat1 <- data.frame("Score" = c(1, 2, 3, 42, 4, 2),
                   "Gender" = c("M", "M", "M", "F", "F", "F"))
## First try with a long key
key1 <- keyTemplate(dat1, long = TRUE)
key1[5, "value_new"] <- 10
key1[6, "value_new"] <- "female"
key1[7, "value_new"] <- "male"
key1[key1$name_old == "Score", "name_new"] <- "NewScore"
dat2 <- data.frame("Score" = 7, "Gender" = "other", "Weight" = rnorm(3))
dat2 <- plyr::rbind.fill(dat1, dat2)
dat2 <- dat2[-1,]
key2 <- keyUpdate(key1, dat2, append = TRUE)
keyDiff(key1, key2)

Run the code above in your browser using DataLab