Software: Search: Software for Exploring Data Structure: Search Documentation

Search with R

Search with R can be started from the Srcshell run editor or from R. Using the Search R example, here’s how.

Starting from the Srcshell run editor

  1. Download and install Srclib as described in the Search Installation Guide.
  2. In Windows start the Srcshell run editor. In Linux or Mac OS X run emacs with “-l ~/srclib/srcshell.el” as a command-line or icon option.
  3. Open or create and save an XML file (.xml) with the following structure, replacing the R run name and statements and Search run name and statements with your own.
    <R name="search_example">
    
    # search example - R version
    
    # import the input datasets
    
    search_data <- read.delim("search_data.txt")
    save(search_data, file="search_data.rda")
    
    # run search
    
    <search name="search">
    datain search_data;
    dataout search;
    title Hourly earnings analysis;
    depv=v17536 wt=v17612 null=.05 expl=0.4 estimate=r20 group=r30;
    v=(v16306,v16631,v17459,v17466,v17467,v17468,v17483,v17543,v17545);
    v=(v16973,v17538) s;
    run;
    </search>
    
    </R>
    

    If the search.set file exists, perhaps from a previous run, you can reuse it by replacing <search name="search">...</search> with the following.

    <search name="search" />
    
  4. In Srcshell, click "run". In emacs, press F8.

    Once you've created an R setup file, search_example.R in the example, you can reuse it by issuing either of the following commands.

    R CMD BATCH search_example.R
    

    Or

    Rscript search_example.R
    

Starting from R

  1. Download and install Srclib as described in the Search Installation Guide.
  2. Change to the working directory you want to use.
  3. In a text editor, create and save an Search setup file (.set) with the following structure, replacing the Search statements with your own. The name of the opened or saved file should be the one you use in the global name statement below.
    datain search_data;
    dataout search;
    title Hourly earnings analysis;
    depv=v17536 wt=v17612 null=.05 expl=0.4 estimate=r20 group=r30;
    v=(v16306,v16631,v17459,v17466,v17467,v17468,v17483,v17543,v17545);
    v=(v16973,v17538) s;
    run;
    
  4. Start R. In the R editor, open an R setup with the following structure, replacing the srclib location, the R statements and the Search run name with your own, and hit return. Or type the R commands directly into the editor.
    # search example - R version
    
    # import the input datasets
    
    search_data <- read.delim("search_data.txt")
    save(search_data, file="search_data.rda")
    
    # initialize srclib
    
    srclib <<- "~/srclib/R"
    source(file.path(srclib, "init.R", fsep=.Platform$file.sep))
    
    # run search
    
    search(name="search")
    

Last updated 19 July 2016