Raise exception in de
I'm currently writing an R script to anonimize data gathered from social media. There's one column which includes the (digital) name of the author and I'm trying to anonimize this column. I found this script on Stackoverflow already:
anonymiseColumns <- 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
}
(Thanks Josh O'brien: How to create example data set from private data (replacing variable names and levels with uninformative place holders)?) This piece of script works perfectly well. However, I'd like to keep 1 specific author name. Namely, the name of the retailer (let's use 'Walmart' as an example) should become 'retailer'. There should be a way to deal with this, but I just haven't been able to figure it out.
链接地址: http://www.djcxy.com/p/24796.html上一篇: 合并期间与数据帧列相关的错误
下一篇: 在de中引发异常