how to referee a dimension name via a variable?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to referee a dimension name via a variable?

Jie TANG-3
hi, R-users
   I have a data.frame for example  test$newdataday24 and test$newdataday48
I can plot them by
plot(test$newdataday24)
but now i want to plot different data by define a variable to describe them
dayno<-c(24,48)
newnam<-paste("test$newdataday",dayno,sep="")
plot(newnam[1])

but i failed,the error message said that something wrong with plot.window

what can i do to fix my script ? thanks
-
TANG Jie

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: how to referee a dimension name via a variable?

Justin Haynes
try:

newnam<-paste('newdatadat',dayno,sep='')

plot(test[[newnam[1]]])


On Mon, Aug 29, 2011 at 12:29 PM, Jie TANG <[hidden email]> wrote:

> hi, R-users
>   I have a data.frame for example  test$newdataday24 and test$newdataday48
> I can plot them by
> plot(test$newdataday24)
> but now i want to plot different data by define a variable to describe them
> dayno<-c(24,48)
> newnam<-paste("test$newdataday",dayno,sep="")
> plot(newnam[1])
>
> but i failed,the error message said that something wrong with plot.window
>
> what can i do to fix my script ? thanks
> -
> TANG Jie
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: how to referee a dimension name via a variable?

Jie TANG-3
thank you , it works .

another problem is if can could define a variable to express the data.frame?
for example :
datanam<-c("newdata","newdata2")
plot(datanam[1][[newnam[1]]])


2011/8/30 Justin Haynes <[hidden email]>

> try:
>
> newnam<-paste('newdatadat',dayno,sep='')
>
> plot(test[[newnam[1]]])
>
>
> On Mon, Aug 29, 2011 at 12:29 PM, Jie TANG <[hidden email]> wrote:
>
>> hi, R-users
>>   I have a data.frame for example  test$newdataday24 and test$newdataday48
>> I can plot them by
>> plot(test$newdataday24)
>> but now i want to plot different data by define a variable to describe
>> them
>> dayno<-c(24,48)
>> newnam<-paste("test$newdataday",dayno,sep="")
>> plot(newnam[1])
>>
>> but i failed,the error message said that something wrong with plot.window
>>
>> what can i do to fix my script ? thanks
>> -
>> TANG Jie
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>
>


--
TANG Jie
Email: [hidden email]
Tel: 0086-2154896104
Shanghai Typhoon Institute,China

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: how to referee a dimension name via a variable?

Duncan Murdoch-2
On 29/08/2011 3:52 PM, Jie TANG wrote:
> thank you , it works .
>
> another problem is if can could define a variable to express the data.frame?
> for example :
> datanam<-c("newdata","newdata2")
> plot(datanam[1][[newnam[1]]])

Use get():

plot(get(datanam[1])[[newnam[1]]]))

Duncan Murdoch

>
> 2011/8/30 Justin Haynes<[hidden email]>
>
> >  try:
> >
> >  newnam<-paste('newdatadat',dayno,sep='')
> >
> >  plot(test[[newnam[1]]])
> >
> >
> >  On Mon, Aug 29, 2011 at 12:29 PM, Jie TANG<[hidden email]>  wrote:
> >
> >>  hi, R-users
> >>    I have a data.frame for example  test$newdataday24 and test$newdataday48
> >>  I can plot them by
> >>  plot(test$newdataday24)
> >>  but now i want to plot different data by define a variable to describe
> >>  them
> >>  dayno<-c(24,48)
> >>  newnam<-paste("test$newdataday",dayno,sep="")
> >>  plot(newnam[1])
> >>
> >>  but i failed,the error message said that something wrong with plot.window
> >>
> >>  what can i do to fix my script ? thanks
> >>  -
> >>  TANG Jie
> >>
> >>         [[alternative HTML version deleted]]
> >>
> >>  ______________________________________________
> >>  [hidden email] 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.
> >>
> >
> >
>
>

______________________________________________
[hidden email] 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.