Coder Social home page Coder Social logo

sdcr's Introduction

For any questions regarding your visit to the GESIS Secure Data Center (SDC), please contact us personally and always pay attention to the guidelines for your visit

People who work with R also want access to sensitive data which are provided in the GESIS Secure Data Center. Yet, R often does not have the same feature set as other software packages, such as Stata. This R-package aims to imitate some of these functions:

  • Creating a log file from an R script
  • Extracting an R script from a log file
  • ...

The package can be installed with the R command:

devtools::install_github("stefmue/sdcR")

Creating a log file file from an R script

Currently, you can create a logfile from an R script by placing a footer to your script (see below) and running the command produce_log_file() as follows:

# STOP ADDING CODE BELOW -------------------------------------------------------

# DO NOT CHANGE OR EDIT THE FOLLOWING LINES. MUST REMAIN AT THE END OF THIS FILE
sdcR::produce_log_file(source_file = current_file(),
                       log_file = paste0(current_file(), ".log"))

Alternatively, you can simply use the command produce_log_file() to create a log file from an external session. For example:

sdcR::produce_log_file(source_file = "/path/to/your/fancy_R_script.R",
                       log_file = "/path/to/your/fancy_R_script.R.log")

What we will ask you to do in the SDC, however, is to use this first appraoch as it is more error-prone and holds everything in one place.

Creating a log file file from an R script

After a logfile was produced (and checked by us for sensitivity) you may want to extract the R code from the it. This can be done using again two approaches. The footer approach would be:

# STOP ADDING CODE BELOW -------------------------------------------------------

# DO NOT CHANGE OR EDIT THE FOLLOWING LINES. MUST REMAIN AT THE END OF THIS FILE
sdcR::produce_log_file(source_file = current_file(),
                       log_file = paste0(current_file(), ".log"))
                       
sdcR::code_from_log(paste0(current_file(), ".log"), "./test/OUTPUTCODE.R")

And the external approach:

sdcR::produce_log_file(source_file = "/path/to/your/fancy_R_script.R",
                       log_file = "/path/to/your/fancy_R_script.R.log")
                       
                       
sdcR::code_from_log("/path/to/your/fancy_R_script.R.log", 
                    "/path/to/your/fancy_R_script.R.log.R")                       

As you might already imagine, what we will ask you to do in the SDC is again to use the first approach.

tl;dr

  1. Store the logfile we have sent to you in a folder of your choice
  2. Make sure its the only logfile in this folder
  3. Open RStudio
  4. setwd() to the folder of your file
  5. Copy & paste and then run the following command:
if (!require(devtools)) {
  install.packages("devtools")
} else {
  library(devtools)
}


if (!require(sdcR)) {
  install_github("sdcR")
} else {
  library(sdcR)
}


sdcR::code_from_log(
  list.files(pattern = ".log"),
  paste0(list.files(pattern = ".log"), ".R")
)
}

sdcr's People

Contributors

stefanjuenger avatar

Stargazers

Jan-Philipp Kolb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.