On Feb 3, 2010, at 4:08 PM, Paul Evans wrote:
Hi,
I wanted to read in a table that had hyphens in the header / column
names. When I read it in however, it replaces the hyphens with a
dot. Which parameter in the read.table function do I need to set to
change this behaviour?
Example code:
jm <- matrix(1:4,2,2)
rownames(jm) <- c('a','b')
colnames(jm) <- c('a-1','a-2')
write.table(jm,'tjm.out',row.names=T,col.names=T,sep='\t')
mm <- read.table('tjm.out',row.names=1,header=T,sep='\t',colClasses
= "character")
print(mm)
a.1 a.2
a 1 3
b 2 4
I would like 'a-1' 'a-2' in the header and not a.1 & a.2
thanks.
If you must, which will mean more typing on your part and probably
lead to obscure errors, set check.names to FALSE:
> mm <- read.table('tjm.out',row.names=1,header=T,sep='\t',colClasses
= "character", check.names=FALSE)
> print(mm)
a-1 a-2
a 1 3
b 2 4
[[alternative HTML version deleted]]
______________________________________________
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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
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.