[R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

Duncan Murdoch murdoch.duncan at gmail.com
Mon Jun 8 16:42:45 CEST 2015


On 08/06/2015 10:23 AM, Sarah Goslee wrote:
> Easiest? Use sub() to replace the periods after the fact.
> 
> You can also use the check.names or the col.names arguments to
> read.table() to customize your import.

Yes, check.names is the right idea.  Use check.names = FALSE, then use
sub() or gsub() to replace the spaces with underscores.

Duncan Murdoch

> Sarah
> 
> On Mon, Jun 8, 2015 at 10:15 AM, John Sorkin
> <jsorkin at grecc.umaryland.edu> wrote:
>> I am reading a csv file. The column headers have spaces in them. The spaces are replaced by a period. I want to replace the space by another character (e.g. the underline) rather than the period. Can someone tell me how to accomplish this?Thank you,
>> John
>>
>> John David Sorkin M.D., Ph.D.
>> Professor of Medicine
>> Chief, Biostatistics and Informatics
>> University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine
>> Baltimore VA Medical Center
>> 10 North Greene Street
>> GRECC (BT/18/GR)
>> Baltimore, MD 21201-1524
>> (Phone) 410-605-7119
>> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>>
>>



More information about the R-help mailing list