Dear AJSS,
Perhaps:

# -------------------
# Data set
# -------------------

mydata=read.table(textConnection("
   V1    V2    V3
1  15     10      4
2    6      4       7
3  10      5       2
4    8      6       6"),header=TRUE)
closeAllConnections()

# -------------------
# Regression models
# -------------------

# Combinations
library(forward)
comb=t(fwd.combn(colnames(mydata),2))

# Summaries
res=apply(comb,1,function(x){
y1=mydata[,x[1]]
x1=mydata[,x[2]]
m=lm(y1~x1)
summary(m)
}
)
names(res)= apply(comb,1,paste,collapse="/",sep="")

# Output in an external file
sink("C:/out.txt")
res
sink()

HTH,

Jorge


On Sun, Oct 19, 2008 at 11:38 AM, Amarjit Singh Sethi
<set_alt@yahoo.co.in>wrote:

> Dear Jorge/Dieter
> Thank you very much for your help. I indeed have been able to get names of
> the variables through 'noquote( )'statement. Yet my problem (regarding
> running regression analysis iteratively: of V1 upon V2; of V1 upon V3; and
> of V2 upon V3) could not be solved. My input data:
>
>     V1    V2    V3
> 1  15     10      4
> 2    6      4       7
> 3  10      5       2
> 4    8      6       6
> I tried the following code:
> x=read.table("sample.txt",header=T,sep="\t")
> sink("out.txt")
> for (i in 1:2){
> dep=noquote(nm[i])
> for(j in i+1:3){
> ind=noquote(nm[j])
> slr=lm(dep ~ ind, data=x)
> smr=summary(slr)
> smr
> }
> }
> sink()
> But I could not get any results. Kindly help or suggest suitable
> alternative.
> The data and the code are given as attachments also.
> Regards
> ajss
>
>
> --- On *Sun, 19/10/08, Jorge Ivan Velez <jorgeivanvelez@gmail.com>* wrote:
>
> From: Jorge Ivan Velez <jorgeivanvelez@gmail.com>
> Subject: Re: [R] Getting names of variables without quotes
> To: set_alt@yahoo.co.in
> Cc: r-help@r-project.org
> Date: Sunday, 19 October, 2008, 1:04 AM
>
>
>
> Dear AJSS,
> Perhaps ?noquote might be useful for you. Here is an example:
>
> > x=c('V1','V2','V3','V4')
>  > x
> [1] "V1" "V2" "V3" "V4"
> > noquote(x)
> [1] V1 V2 V3 V4
>
> HTH,
>
> Jorge
>
>
> On Sat, Oct 18, 2008 at 3:04 PM, Amarjit Singh Sethi <set_alt@yahoo.co.in>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
>>
>>
>>
>>
>> d Now! http://messenger.yahoo.com/download.php
>>        [[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<http://www.r-project.org/posting-guide..html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> Send free SMS to your Friends on Mobile from your Yahoo! Messenger.
> Download Now! http://messenger.yahoo.com/download.php

	[[alternative HTML version deleted]]

