The R Project SVN R-packages

Rev

Rev 93 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed


R Under development (unstable) (2019-07-31 r76909) -- "Unsuffered Consequences"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(foreign)
> lookup.xport("Alfalfa.xpt")
$SPEC
$SPEC$headpad
[1] 1360

$SPEC$type
[1] "character" "numeric"   "numeric"   "numeric"   "numeric"   "numeric"  

$SPEC$width
[1] 8 8 8 8 8 8

$SPEC$index
[1] 1 2 3 4 5 6

$SPEC$position
[1]  0  8 16 24 32 40

$SPEC$name
[1] "POP"    "SAMPLE" "REP"    "SEEDWT" "HARV1"  "HARV2" 

$SPEC$label
[1] "" "" "" "" "" ""

$SPEC$format
[1] "" "" "" "" "" ""

$SPEC$sexptype
[1] 16 14 14 14 14 14

$SPEC$tailpad
[1] 0

$SPEC$length
[1] 40


> Alfalfa <- read.xport("Alfalfa.xpt", stringsAsFactors = TRUE)
> summary(Alfalfa)
  POP         SAMPLE         REP           SEEDWT          HARV1      
 MAX:20   Min.   :0.0   Min.   :1.00   Min.   :35.00   Min.   :120.6  
 min:20   1st Qu.:2.0   1st Qu.:1.75   1st Qu.:47.75   1st Qu.:148.3  
          Median :4.5   Median :2.50   Median :59.00   Median :165.8  
          Mean   :4.5   Mean   :2.50   Mean   :56.08   Mean   :163.0  
          3rd Qu.:7.0   3rd Qu.:3.25   3rd Qu.:62.25   3rd Qu.:176.4  
          Max.   :9.0   Max.   :4.00   Max.   :75.00   Max.   :193.4  
     HARV2      
 Min.   :129.1  
 1st Qu.:150.6  
 Median :163.2  
 Mean   :167.1  
 3rd Qu.:179.6  
 Max.   :235.3  
> ## test data provided by FRohde@birchdavis.com
> lookup.xport("test.xpt")
$TEST
$TEST$headpad
[1] 800

$TEST$type
[1] "numeric" "numeric"

$TEST$width
[1] 8 8

$TEST$index
[1] 1 2

$TEST$position
[1] 0 8

$TEST$name
[1] "I" "K"

$TEST$label
[1] "" ""

$TEST$format
[1] "" ""

$TEST$sexptype
[1] 14 14

$TEST$tailpad
[1] 48

$TEST$length
[1] 12


> testdata <- read.xport("test.xpt")
> summary(testdata)
       I              K    
 Min.   :1.00   Min.   :1  
 1st Qu.:1.75   1st Qu.:1  
 Median :2.50   Median :2  
 Mean   :2.50   Mean   :2  
 3rd Qu.:3.25   3rd Qu.:3  
 Max.   :4.00   Max.   :3  
> q()
> proc.time()
   user  system elapsed 
  0.107   0.024   0.121