On Sun, 2007-07-22 at 21:51 -0700, Stephen Tucker wrote:
> It turns out that "-" and " " (space) are not valid variable names. 

They are valid names, the problem is that they aren't very convenient to
use, as the OP discovered, because they need to be quoted.

Note that if using something like read.csv or read.table, R will correct
these problem variable names for you when you import the data. If you
read this file in for example:

"Mydata","S-sharif","A site"
1,45,34
2,66,45
3,79,56

using read.csv, you get easy to use names

> dat <- read.csv("temp.csv")
> dat
  Mydata S.sharif A.site
1      1       45     34
2      2       66     45
3      3       79     56

You can turn off this safety checking using the argument check.names =
FALSE

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson                 [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to