[R] Periods instead of spaces in dataframe names?
tarnold at smpllc.com
Tue Feb 11 18:44:02 CET 2003
Thanks to John, Sundar, and Peter Dalgaard for their quick and helpful (and
correct!) answers to my questions.
By explaining the check.names argument and the need to escape the "." to be
"\\." in gsub(), I now have several ways to solve the problem.
I also found the "strwrap" function, so now I can easily put neat titles on my
charts without manual formatting or retyping data.
The more I use R, the easier it gets. But without the help of the community of
users, I really would be stuck.
> -----Original Message-----
> From: r-help-admin at stat.math.ethz.ch
> [mailto:r-help-admin at stat.math.ethz.ch]On Behalf Of John Fox
> Sent: Tuesday, February 11, 2003 10:21 AM
> To: Tom Arnold
> Cc: R-Help
> Subject: Re: [R] Periods instead of spaces in dataframe names?
> Dear Tom,
> When you read the data into a data frame via read.csv, the character
> strings in the first row of the data file, which you've indicated is to be
> interpreted as a header, are used for column names; in the process, blanks
> are converted to periods, since nonstandard names including blanks are more
> difficult to deal with; names(df) just returns the name of column 13 in
> the data frame. You could use the gsub function to recover the blanks --
> something like gsub("\\."," ", names(df)). Alternatively, you could
> specify the argument check.names=FALSE to read.csv to avoid substituting
> periods for blanks in the first place, but this probably isn't a good idea.
> See ?read.csv for details.
> I hope that this helps,
More information about the R-help