[R] New to R and need help

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Oct 14 18:18:09 CEST 2002


Martin Maechler <maechler at stat.math.ethz.ch> writes:

> >>>>> "Scott" == Scott Marley <azboater at dakotacom.net>
> >>>>>     on Mon, 14 Oct 2002 08:34:14 -0700 writes:
> 
>     Scott> All,
> 
>     Scott> I just took a cool R workshop and I'm chomping at the
>     Scott> bit to play around with it.  I'm fairly familiar with
>     Scott> SAS and have some data that I used with Sas.  My
>     Scott> question is: How do I take a text file(I think my
>     Scott> instructor called it a rectangular file) and import
>     Scott> it to R.  In sas you use an input statement followed
>     Scott> by Variable name and the column numbers for the
>     Scott> location of the data.  Does R have a similar
>     Scott> procedure?  What would the syntax look like?  Thank
>     Scott> you for any help you can offer.
> 
> help(read.table)

(Why don't we have examples in there??) 

Specifically, you do something like

x <- read.table("myfile.txt")
names(x) <- c("age", "height", "weight")

or, preferably, add a 1st row containing the variable names to the
data file and do

x <- read.table("myfile.txt", header=TRUE)

There's a number of fine points concerning missing value specification
and variable types, for which the help page should be consulted.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list