 
					莫回无
					我不知道是否有被自动执行此功能,但现在没有;)## A function to anonymise columns in 'colIDs' ##    colIDs can be either column names or integer indicesanonymiseColumns <- function(df, colIDs) {    id <- if(is.character(colIDs)) match(colIDs, names(df)) else colIDs    for(id in colIDs) {        prefix <- sample(LETTERS, 1)        suffix <- as.character(as.numeric(as.factor(df[[id]])))        df[[id]] <- paste(prefix, suffix, sep="")    }    names(df)[id] <- paste("V", id, sep="")    df}## A data.frame containing sensitive informationdf <- data.frame(    name = rep(readLines(file.path(R.home("doc"), "AUTHORS"))[9:13], each=2),    hiscore = runif(10, 99, 100),    passwd = replicate(10, paste(sample(c(LETTERS, letters), 9), collapse="")))## Anonymise itdf2 <- anonymiseColumns(df, c(1,3))## Check that it worked> head(df, 3)           name  hiscore    passwd1 Douglas Bates 99.96714 ROELIAncz2 Douglas Bates 99.07243 gDOLNMyVe3 John Chambers 99.55322 xIVPHDuEW    > head(df2, 3)  name hiscore  V31   Q1 99.96714 V82   Q1 99.07243 V23   Q2 99.55322 V9