[R] Getting names of variables without quotes
Charles C. Berry
cberry at tajo.ucsd.edu
Sun Oct 19 01:32:41 CEST 2008
On Sun, 19 Oct 2008, Amarjit Singh Sethi wrote:
> Â
> Dear R-helpers,
> hello
> I am seeking your help in somehow getting names of variables without quotes (" ").
> Let us say, we have a table with 3 variables V1, V2 and V3. After the table is read, I get names of the variables (thro' the following code) as under quotes (like "V1" rather than the original representation V1)
> Â
> Â x=read.table("sample.txt",header=T,sep="\t")
>> x
> Â Â Â V1Â Â Â V2Â Â Â V3
> 1Â 15Â Â Â Â 10Â Â Â Â Â 4
> 2Â Â Â 6Â Â Â Â Â Â 4Â Â Â Â Â Â 7
> 3Â 10Â Â Â Â Â 5Â Â Â Â Â Â 2
> 4Â Â Â 8Â Â Â Â Â 6Â Â Â Â Â Â 6
>> nm=names(x)
>> nm
> [1] "V1" "V2" "V3" Â In fact I need the variables in the
> original representation (i.e., as they appear in the input data file)
> so as to use them repeatedly (through loop statement) in regression
> analysis. Kindly help. Regards ajss
I'll second Dieter's comment about HTML mail... ARGH!!
But I will also hazard a guess that you are not going to solve your
problem by forcing "V1" to print without quotes.
Rather, you should check out
?as.formula
Pay special attention to the last case in
example( as.formula )
HTH,
Chuck
>
>
>
>
> d Now! http://messenger.yahoo.com/download.php
> [[alternative HTML version deleted]]
>
>
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help
mailing list