Extended column names for aesthetics

55 views
Skip to first unread message

Tyberius Prime

unread,
Jan 20, 2010, 7:32:44 AM1/20/10
to ggplot2
Hello group,

I'm trying to plot dataframes that have 'non-variable-name' column
names (think spaces, ^2...) and was wondering if there's a way to pass
those to aes without having to rename the column and then fixing the
legend?

(Background: I'm working on a python wrapper, and while I could solve
this with another layer of indirection, I'd rather not).

Thank you,
so long,
Tyberius Prime

baptiste auguie

unread,
Jan 20, 2010, 8:29:08 AM1/20/10
to Tyberius Prime, ggplot2
Hi,

Try this,

d = data.frame(1:10, rnorm(10))

names(d) = c('with space #', '£$@')

ggplot(d) +
aes(`with space #`, `£$@`, colour = `£$@`) +
geom_point()

HTH,

baptiste

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
>

Tyberius Prime

unread,
Jan 21, 2010, 3:43:46 AM1/21/10
to ggplot2
Thank you,

that was exactly what I was looking for - but googling for 'R escape
variables' or 'R escape variable names' and variations failed me.

So long,
Tyberius Prime

lgautier

unread,
Feb 13, 2010, 3:03:20 AM2/13/10
to ggplot2

On Jan 20, 1:32 pm, Tyberius Prime <tyberius_pr...@coonabibba.de>
wrote:

An other way to solve this would be to use rpy2:
http://rpy.sourceforge.net/rpy2/doc-2.1/html/graphics.html#package-ggplot2

L.

Reply all
Reply to author
Forward
0 new messages