[R] Getting names of variables without quotes

jim holtman jholtman at gmail.com
Tue Oct 21 21:36:44 CEST 2008


How about putting them to an output file:

pdf("your file name.pdf")
ts.plot(...)
dev.off()

On Tue, Oct 21, 2008 at 2:36 PM, Amarjit Singh Sethi
<set_alt at yahoo.co.in> wrote:
> Dear Menne/ Jorge
>
> Many thanks for the help rendered by you both.
>
> Now, may I augment my problem.
>
> While running the regressions (through 'for' loop), I tried to generate time series plots for each iteration. Although the summary results from regressions were saved in the output file (through sink() statement), yet the plots were not saved. The tried code was:
>
> x=read.table("sample.txt",header=T,sep="\t")
> out="output.txt"
> sink(out)
> x
> nm = names(x)
> nm
> for (i in 1:2)
> {
>  for(j in (i+1):3)
>  {
>    formula= as.formula(paste(nm[i]," ~ ",nm[j],sep=""))
>    slr=lm(formula, data=x)
>    smr=summary(slr)
>    print(smr)
>
>    fit=fitted(slr)
>    tsp=ts.plot(fit)
>
>  }
> }
> sink()
>
>
> Kindly help to get the plots saved, preferably in separate output files for each iteration.
>
> regards
>
> ajss
>
> --- On Sun, 19/10/08, Dieter Menne <dieter.menne at menne-biomed.de> wrote:
>
>> From: Dieter Menne <dieter.menne at menne-biomed.de>
>> Subject: Re: [R] Getting names of variables without quotes
>> To: r-help at stat.math.ethz.ch
>> Date: Sunday, 19 October, 2008, 9:29 PM
>> Amarjit Singh Sethi <set_alt <at> yahoo.co.in>
>> writes:
>>
>> (Please do not use tabs  when sending a data sample, these
>> must be
>> manually edited)
>>
>> V1,V2,V3
>> 15,10,4
>> 6,4,7
>> 10,5,2
>> 8,6,6
>>
>> This does the work. However, I fear that you are going to
>> use it on
>> 100 variables, and I would strongly advice againts
>> searching for
>> linear relations
>> that way.
>>
>> Dieter
>>
>> x=read.table("sample.txt",header=T,sep=",")
>> nm = names(x)
>> for (i in 1:2)
>> {
>>   for(j in (i+1):3) # note that you need the ()!
>>   {
>>     formula=
>> as.formula(paste(nm[i],"~",nm[j],sep=""))
>>     slr=lm(formula, data=x)
>>     smr=summary(slr)
>>     print(smr)
>>   }
>> }
>>
>> ______________________________________________
>> R-help at 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.
>
> Send free SMS to your Friends on Mobile from your
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list