Ivan: On Tue, Jan 24, 2012 at 6:47 AM, Ivan Calandra <ivan.calan...@u-bourgogne.fr> wrote: > By "it works anyway", I mean that you can have a dash in a column name, > there is no error or even warning. > I guess that some functions would throw an error or warning, depending on > the requirements, but data.frame() doesn't.
This is false. Please don't guess. Read the Help pages. > data.frame(a = 1:3) #fine > data.frame(a-3 = 1:3) # Error: unexpected '=' in "data.frame(a-3 =" The name in **NOT** OK. However, > data.frame("a-3" = 1:3) # fine a.3 1 1 2 2 3 3 ## A quoted character string can be used as a column name ## The name will be changed to a legal name unless: > data.frame("a-3" = 1:3,check.names=FALSE) a-3 1 1 2 2 3 3 However, as is obvious, there is much mischief possible from such practices, so that they are best avoided. -- Bert > > Ivan > > Le 24/01/12 15:35, David Winsemius a écrit : >> >> >> On Jan 24, 2012, at 4:44 AM, Ivan Calandra wrote: >> >>> Hi Mark, >>> >>> I cannot tell you why (maybe someone else can), but the check.names >>> argument to data.frame() interpret "a.-5" as an unvalid name and convert to >>> to a valid one. What I don't understand is why it isn't "valid" since it >>> works anyway. >> >> >> The dash is not a valid character for column names. What do you mean by >> "it works anyway"? >> > > -- > Ivan CALANDRA > Université de Bourgogne > UMR CNRS/uB 6282 Biogéosciences > 6 Boulevard Gabriel > 21000 Dijon, FRANCE > +33(0)3.80.39.63.06 > ivan.calan...@u-bourgogne.fr > > ______________________________________________ > R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm ______________________________________________ R-help@r-project.org 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.