Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7899809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:48:18+00:00 2026-06-03T08:48:18+00:00

To provide a reproducible example of an approach, a data set must often be

  • 0

To provide a reproducible example of an approach, a data set must often be provided. Instead of building an example data set, I wish to use some of my own data. However this data can not be released. I wish to replace variable (column) names and factor levels with uninformative place holders (eg. V1….V5, L1….L5).

Is an automated way to do this available?

Ideally, this would be done in R, taking in a data.frame and producing this anonymous data.frame.

With such a data set, simply search and replace variable names in your script and you have a publicly releasable reproducible example.

Such a process may increase the inclusion of appropriate data in reproducible examples and even the inclusion of reproducible examples in questions, comments and bug reports.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:48:20+00:00Added an answer on June 3, 2026 at 8:48 am

    I don’t know whether there was a function to automate this, but now there is 😉

    ## A function to anonymise columns in 'colIDs' 
    ##    colIDs can be either column names or integer indices
    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
    }
    
    ## A data.frame containing sensitive information
    df <- 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 it
    df2 <- anonymiseColumns(df, c(1,3))
    
    ## Check that it worked
    > head(df, 3)
               name  hiscore    passwd
    1 Douglas Bates 99.96714 ROELIAncz
    2 Douglas Bates 99.07243 gDOLNMyVe
    3 John Chambers 99.55322 xIVPHDuEW    
    
    > head(df2, 3)
      name hiscore  V3
    1   Q1 99.96714 V8
    2   Q1 99.07243 V2
    3   Q2 99.55322 V9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please provide some good coding habits that one must follow to optimize vb.net code.
I provide data in server ,and want to send it to client,I use ashx
can someone provide a basic example how to import data from an XML file
Provide an example for the pseudo-regex: Match every url except those from example.com and
interfaces provide a useful abstraction capability. One can have a class Foo implement some
To provide as much information as I can, here's a very basic example of
Can anyone provide some links to good information on setting up Silverlight 2.0 to
Please provide some basic information of how TypeLiteral in Google Guice or Java EE
To provide some context, I'm interested in the creation of an app which allows
Please provide me some iOS game development documentation for beginners. I do already have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.