s-news
[Top] [All Lists]

Re: help interpret a line of code

To: "'Terrence Murphy'" <Terrence.Murphy@yale.edu>, s-news@lists.biostat.wustl.edu
Subject: Re: help interpret a line of code
From: "Austin, Matt" <maustin@amgen.com>
Date: Tue, 29 Nov 2005 16:44:42 -0800
Look at the help files for matrix and rep

?matrix
?rep


## Read dataset
c83 <- read.table('c:\\bin.txt', header = T)

## Create matrix x
x <- matrix( data = 0,                ## fill with zeros
             nrow = sum( c83$total),  ## number of rows
                                      ## equal to the sum
                                      ## of the c83$total vector
             ncol = 4)                ## 4 columns

## Create 2 vectors of zeros with length 
## equal to the sum of the 'total' variable
## from the c83 dataset and assign to y and g

y <- rep( 0, times = sum(c83$total))
g <- rep( 0, times = sum(c83$total))

## Assign 0 to k
k <- 0


--Matt

> -----Original Message-----
> From: s-news-owner@lists.biostat.wustl.edu
> [mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Terrence
> Murphy
> Sent: Tuesday, November 29, 2005 11:46 AM
> To: s-news@lists.biostat.wustl.edu
> Subject: [S] help interpret a line of code
> 
> 
> Dear Users,
> 
> I'm new to Splus and pardon this question, but don't understand the 
> following  lines in a program
> I'm trying to use:
> 
> c83<-read.table('c:\\bin.txt',header=T)
> x<-matrix(0,sum(c83$total),4)
> y<-rep(0,sum(c83$total))
> g<-rep(0,sum(c83$total))
> k<-0
> 
> The first line reads data from a text file into a vector 
> called c83. The 
> second line establishes a
> matrix x but with what? What is the value of  c83$total ? 
> What do the three 
> terms 0, c83$total  and 4 stand for with regard to the dimensions and 
> contents of the matrix x?
> 
> I assume the last three lines set up vectors of 0 with 
> respective lengths 
> of  c83$total , c83$total , and 0, no ?
> 
> Any help greatly appreciated.
> 
> 
> Terrence E. Murphy, Ph.D.
> Program on Aging
> Yale University
> 1 Church St., 7th Floor
> New Haven, CT 06437
> terrence.murphy@yale.edu
> phone: 203-764-9805
> fax:      203-764-9831 
> 
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news
> 

<Prev in Thread] Current Thread [Next in Thread>