Re: [R] Dealing with data frame column names beginning with a numeric

2007-04-17 Thread Patrick Connolly
On Mon, 16-Apr-2007 at 10:12PM +0100, Prof Brian Ripley wrote:

|> On Mon, 16 Apr 2007, Duncan Murdoch wrote:

|> >The name change happens in the conversion to a dataframe, so why not
|> >change the name afterwards?  That is:
|> >
|> >df <- data.frame(mat)
|> >names(df)[3] <- "5T"
|> >boxplot(df, main="blah blah blah")
|> 
|> Or use
|> 
|> boxplot(as.data.frame(mat))
|> 
|> which seems more natural than data.frame(mat, check.names=FALSE) (which 
|> also does the job) or even data.frame(mat).


boxplot(data.frame(mat)) is how it's described in the help, but it
produces the problem that began my discussion (i.e. prepends an "X" to
the name for a dataframe column name).

However, boxplot(as.data.frame(mat)) as suggested by Brian works fine.
So I needed only three keystrokes to get round the problem.

Thank you all.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@stat.math.ethz.ch 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.


Re: [R] Dealing with data frame column names beginning with a numeric

2007-04-16 Thread Prof Brian Ripley
On Mon, 16 Apr 2007, Duncan Murdoch wrote:

> On 4/16/2007 4:22 PM, Patrick Connolly wrote:
>> I wish to set up a simple function using boxplot so that it will be
>> available to someone using R for Windows.  (I myself use Linux.)
>>
>> The way the data is organised makes it convenient to use the boxplot
>> function in a manner similar to this example given in the help.
>>
>>
>>>  mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
>> +   T5 = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
>>>  boxplot(data.frame(mat), main = "boxplot(data.frame(mat), main = ...)")
>>
>> If one of those columns had a numeric beginning to its name, such as:
>>
>>> colnames(mat)[3] <- "5T"
>>
>> and then using boxplot the same way, it will prepend an "X" to the
>> column name "5T" in the changing to a dataframe.
>>
>> I know I could use boxplot with a formula with the dataframe reshaped
>> which would get round the problem, but I wanted to introduce as few
>> new concepts as possible for someone new to using R.  So the question
>> is: Is there a way to get such a name without anything prepended into
>> boxplot when used this way?
>>
>> I've been led to understand that some Windows' plotting devices lend
>> themselves to simpler editing than in Linux, so perhaps there is a
>> simple way to remove the "X" from the plot afterwards.  I know it
>> could be done with a postscript device by editing the file with a text
>> editor but that's not simple with Windows.

You can edit EMF files in a suitable editor.

>> Ideas?
>
> The name change happens in the conversion to a dataframe, so why not
> change the name afterwards?  That is:
>
> df <- data.frame(mat)
> names(df)[3] <- "5T"
> boxplot(df, main="blah blah blah")

Or use

boxplot(as.data.frame(mat))

which seems more natural than data.frame(mat, check.names=FALSE) (which 
also does the job) or even data.frame(mat).

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch 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.


Re: [R] Dealing with data frame column names beginning with a numeric

2007-04-16 Thread Patrick Connolly
On Mon, 16-Apr-2007 at 04:29PM -0400, Gabor Grothendieck wrote:

|> Try this:
|> 
|> boxplot(data.frame(mat), names = colnames(mat))
|> 


Great! Now why didn't I think of that?



-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@stat.math.ethz.ch 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.


Re: [R] Dealing with data frame column names beginning with a numeric

2007-04-16 Thread Duncan Murdoch
On 4/16/2007 4:22 PM, Patrick Connolly wrote:
> I wish to set up a simple function using boxplot so that it will be
> available to someone using R for Windows.  (I myself use Linux.)
> 
> The way the data is organised makes it convenient to use the boxplot
> function in a manner similar to this example given in the help.
> 
> 
>>  mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
> +   T5 = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
>>  boxplot(data.frame(mat), main = "boxplot(data.frame(mat), main = ...)")
> 
> If one of those columns had a numeric beginning to its name, such as:
> 
>> colnames(mat)[3] <- "5T"
> 
> and then using boxplot the same way, it will prepend an "X" to the
> column name "5T" in the changing to a dataframe.
> 
> I know I could use boxplot with a formula with the dataframe reshaped
> which would get round the problem, but I wanted to introduce as few
> new concepts as possible for someone new to using R.  So the question
> is: Is there a way to get such a name without anything prepended into
> boxplot when used this way?
> 
> I've been led to understand that some Windows' plotting devices lend
> themselves to simpler editing than in Linux, so perhaps there is a
> simple way to remove the "X" from the plot afterwards.  I know it
> could be done with a postscript device by editing the file with a text
> editor but that's not simple with Windows.
> 
> Ideas?

The name change happens in the conversion to a dataframe, so why not 
change the name afterwards?  That is:

df <- data.frame(mat)
names(df)[3] <- "5T"
boxplot(df, main="blah blah blah")

Duncan Murdoch

__
R-help@stat.math.ethz.ch 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.


Re: [R] Dealing with data frame column names beginning with a numeric

2007-04-16 Thread Gabor Grothendieck
Try this:

boxplot(data.frame(mat), names = colnames(mat))

On 4/16/07, Patrick Connolly <[EMAIL PROTECTED]> wrote:
> I wish to set up a simple function using boxplot so that it will be
> available to someone using R for Windows.  (I myself use Linux.)
>
> The way the data is organised makes it convenient to use the boxplot
> function in a manner similar to this example given in the help.
>
>
> >  mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
> +   T5 = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
> >  boxplot(data.frame(mat), main = "boxplot(data.frame(mat), main = ...)")
>
> If one of those columns had a numeric beginning to its name, such as:
>
> > colnames(mat)[3] <- "5T"
>
> and then using boxplot the same way, it will prepend an "X" to the
> column name "5T" in the changing to a dataframe.
>
> I know I could use boxplot with a formula with the dataframe reshaped
> which would get round the problem, but I wanted to introduce as few
> new concepts as possible for someone new to using R.  So the question
> is: Is there a way to get such a name without anything prepended into
> boxplot when used this way?
>
> I've been led to understand that some Windows' plotting devices lend
> themselves to simpler editing than in Linux, so perhaps there is a
> simple way to remove the "X" from the plot afterwards.  I know it
> could be done with a postscript device by editing the file with a text
> editor but that's not simple with Windows.
>
> Ideas?
>
> --
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>   ___Patrick Connolly
>  {~._.~} Great minds discuss ideas
>  _( Y )_Middle minds discuss events
> (:_~*~_:)Small minds discuss people
>  (_)-(_)   . Anon
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>
> __
> R-help@stat.math.ethz.ch 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.
>

__
R-help@stat.math.ethz.ch 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.


[R] Dealing with data frame column names beginning with a numeric

2007-04-16 Thread Patrick Connolly
I wish to set up a simple function using boxplot so that it will be
available to someone using R for Windows.  (I myself use Linux.)

The way the data is organised makes it convenient to use the boxplot
function in a manner similar to this example given in the help.


>  mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
+   T5 = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
>  boxplot(data.frame(mat), main = "boxplot(data.frame(mat), main = ...)")

If one of those columns had a numeric beginning to its name, such as:

> colnames(mat)[3] <- "5T"

and then using boxplot the same way, it will prepend an "X" to the
column name "5T" in the changing to a dataframe.

I know I could use boxplot with a formula with the dataframe reshaped
which would get round the problem, but I wanted to introduce as few
new concepts as possible for someone new to using R.  So the question
is: Is there a way to get such a name without anything prepended into
boxplot when used this way?

I've been led to understand that some Windows' plotting devices lend
themselves to simpler editing than in Linux, so perhaps there is a
simple way to remove the "X" from the plot afterwards.  I know it
could be done with a postscript device by editing the file with a text
editor but that's not simple with Windows.

Ideas?

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@stat.math.ethz.ch 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.