SCCS R package install

From InterSciWiki
Jump to: navigation, search


http://www.r-bloggers.com/installing-r-packages/

SCCS R package projects to do list - Manual for Dataset Construction and Causal Analysis

Setting up R on Windows

  • Download R from here: http://www.r-project.org/
  • Make sure R is in your path. You can verify this by going to "Control Panel -> System -> Advanced -> Environment Variables -> Path -- e.g. add to the end of your path, e.g. [Existing Path];C:\Program Files\R\R-2.11.1\bin\ (depending on the version of R)
  • Download RTools from http://www.murdoch-sutherland.com/Rtools/ (make sure it's compatible w/ your version of R and Windows)
  • README.txt

Build and Install SCCS R Package *Rccs*

For the PC

Once you have R installed on your machine, perform the following steps:

Create a directory at the root of c:\
ie cd \
then md \My Directory
cd c:\My Directory
md sccs
put the zip drive there
open the zip (tar)
press the internal button to "extract" the contents of zipfile
(If you click on the tar or zip file and see five files inside it you may have to COPYALL, close the tar file, and PASTE them into sccs). YOU MIGHT NEED TO UNZIP A SECOND FILE WITHIN THE ORIGINAL ZIP: Viewing those files then Ctrl-C to copy the all, but PASTE them back into the original (lowest level) sccs directory. These two are equivalent alternatives: the first is doubly zipped (zip within a zip), the second more simply zipped.
  • When asked for a password, thats the password to your computer, your logic password on your PC.
  • ? download sccs.1.0.tar.gz to c:\My Documents\sccs
  • ? download sccs.1.0.tar to c:\My Documents\sccs
  • IMPT NOTE: All zip, tar, and gz files have an internal button to "extract" the zipped files from the home directory where the zip is located to that or other subdirectories. Thats what you need to do.

Only then can you do the next step, "install.bat" or for the mac "install.sh"

  • In DOS (under All Programs/Accessories/C:\ command prompt): You should now be able to cd into the working directory and type 'dir' (a DOS command in the DOS window) and see two sub directories: 'sccs' and 'examples' as well as two files for installing the sccs library into R, one for windows (install.bat) and for unix based systems (install.sh).
  • There is a step missing here because install.bat calls R CMD check sccs. But also it wants the *.tar file. So from the original extract site you have to RIGHT CLICK on drwhite-Statistical-Inference-SCCS-a79bcaa.tar and save as/ onto c:/My Documents/sccs.
  • If you can't unsip drwhite-Statistical-Inference-SCCS-a79bcaa.tar.gz the install the unzip at http://www.gzip.org/
or -- I am suspiscious of this one --- install from http://www.freedownloadmanager.org/downloads/unzip_tar_files_info/ - I am suspiscious of this one ---
  • Run install.bat by typing './install.bat' or 'install.bat
  • For a mac Run install.sh by typing './install.sh'
  • Verify the sccs R package was installed correctly by loading R and within the R shell ('R' in the DOS window) typing: 'library(sccs)' and then 'data(sccs)' and verify there were no errors. The last command 'data(sccs)' should print the sccs dataset to the screen. If not, type 'sccs'.

For the mac

Issues

Tara's brother: Mac. The directory they were having you use to install the application files was "C:\My Documents" I believe, and this is not the location of the my documents folder. On Windows 7 the "My Documents" folder is @ "C:\Users\<username>\Documents". On windows xp, I think the location is something like "C:\Documents and Settings\<username>\My Documents\". I needed to update the locations in two places, one was in a large script block.

DRW: For the UCI Lab the only place students can save files in c:\My Documents. That's where we put the files.

It also seemed like some libraries were missing. Some of the instructions links were not working, giving 404: Page not found errors and instead I had to attempt to build out the libraries from source. I think my knowledge of Linux helped out here since I am accustomed to installing libraries. I would recommend going through the instructions and clicking on each link to find out which ones are not working.

DRW: Yes, needs to be checked again for Mac and PC

Extra Installs if needed

  • You may need to install Microsoft's HTML Help Workshop using Internet Explorer (iE). Make sure R is in your path. You can verify this by going to "Control Panel -> System -> Advanced -> Environment Variables -> Path. -- add to your path ;C:\Program Files\HTML Help Workshop

EduMod74

EduMod74 is a UCI EduMod test file

Making and Expanding databases

R programs for converting databases to *.Rdata *.rar file, right click and save

Migalski classroom

  • Last year we used setwd("C:/My Documents/MI) as the subdirectory for the software
  • This year we will use setwd("C:/My Documents/sccs")
  • So set up the programs and data according to the instructions below, on C:/My Documents/sccs
  • Thanks.
  • Students identify their projects by an alias = "initials+theme", e.g. DRWpolygyny, XYZvalue_children, so all their projects will show up at that site (see: EduMod74). DRW will need to be able to access files there and delete files, and I will need access to DOS, including DOS commands such as
attrib      and attrib -a which unprotects files

Auxiliary programs: Format my_sccs for indep_vars

This program takes a restr1 file as input with a column of my_sccs variables and converts to indep_vars format

FORTRAN

     character*20 A
     write (*,"(A)") " Have my_sccs column in restr1, output in restr2"
     pause
     open (1,file="restr1")
     open (2,file="restr2")
     do i=1,999
     read (1,*) A
       if (A(1:1).ne.'#') then
        do j=1,20
        if (A(j:j).eq.'=') then
        write (*,'(1x,3A)')  '"',A(1:j-1),'",'                                   
         write (2,'(1x,3A\)')  '"',A(1:j-1),'",'
        goto 1
        endif
        enddo     

1 endif

     if (mod(i,10).eq.0) then
     write (2,*) 
     endif
     enddo
     end

Auxiliary programs: Maps

e.g., create depvar equal to dep_var above my_sccs

depvar=sccs$v860
my_sccs<-data.frame(
dep_var=sccs$v860,

then for source( substitute

source("examples/src/run_model.R") #does for this model multiple imputation, two stage ols, saves to file to working directory.
lat<-sccs$v833.1
lon<-sccs$v833.2
plot(lon,lat, cex=.1)
ztxt=as.character(depvar) #above "my_sccs( " -- a new line inserted: depvar= as defined in my_sccs( 
text(lon,lat,ztxt)
ols_stats$restrict_stats
ols_stats$r2
ols_stats$restrict_diagnostics