Simple question about symbols()

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

Simple question about symbols()

murilofm
I'm new to R and i'm having some trouble with a bubble chart.
Basically I have 3 series (a,b,c), but the third one is a binnary variable (assumes only 0 or 1 to the entire data).
How can I use these binnary information to make 2 different colours in a bubble chart?. I.e., I'm using this code:


symbols(inv$a, inv$b, circles=radius, inches=0.35, fg="white",
bg="red", xlab="aa", ylab="bb", add=TRUE)

and i want the bg color to be red if c=1 and blue if c=0.

thanks,

Murilo
Reply | Threaded
Open this post in threaded view
|

Re: Simple question about symbols()

bbolker
murilofm <murilofmoraes <at> gmail.com> writes:

>
> I'm new to R and i'm having some trouble with a bubble chart.
> Basically I have 3 series (a,b,c), but the third one is a binnary variable
> (assumes only 0 or 1 to the entire data).
> How can I use these binnary information to make 2 different colours in a
> bubble chart?. I.e., I'm using this code:
>

  Probably:

symbols(inv$a, inv$b, circles=radius, inches=0.35, fg="white",
   bg="red", xlab="aa", ylab="bb", add=TRUE,
   col=c("blue","red")[inv$c+1])

______________________________________________
[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: Simple question about symbols()

murilofm
Thanks for the answer; I see that col=c("blue","red")[inv$c+1] creates a vector of "red" and "blue" associated with the binnary c.
But still I got everything red.
Reply | Threaded
Open this post in threaded view
|

Re: Simple question about symbols()

David Winsemius

On Apr 19, 2011, at 10:51 PM, murilofm wrote:

> Thanks for the answer; I see that col=c("blue","red")[inv$c+1]  
> creates a
> vector of "red" and "blue" associated with the binnary c.
> But still I got everything red.

If you want tested solution, submit test data.

>
> --
> View this message in context: http://r.789695.n4.nabble.com/Simple-question-about-symbols-tp3461676p3462013.html
> Sent from the R help mailing list archive at Nabble.com.
--

David Winsemius, MD
West Hartford, CT

______________________________________________
[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: Simple question about symbols()

murilofm
The link to the csv file is

http://www.filedropper.com/data_5

I use the "d" variable to create the radius:

radius <- sqrt( inv$d/ pi )

and i tried

symbols(inv$a, inv$b, circles=radius, inches=0.35, fg="white",
   bg="red", xlab="aa", ylab="bb",
   col=c("blue","red")[inv$c+1])

Thanks for the help.
Reply | Threaded
Open this post in threaded view
|

Re: Simple question about symbols()

bbolker
In reply to this post by David Winsemius
David Winsemius <dwinsemius <at> comcast.net> writes:

>
>
> On Apr 19, 2011, at 10:51 PM, murilofm wrote:
>
> > Thanks for the answer; I see that col=c("blue","red")[inv$c+1]  
> > creates a
> > vector of "red" and "blue" associated with the binnary c.
> > But still I got everything red.
>
> If you want tested solution, submit test data.
>

  David also suggests (off-lists) that you use "bg" instead of "col" as
the argument name.  (Another strategy is to go to ?symbols
and search for "colour" -- I wouldn't expect a new user
to guess the c("blue","red")[inv$c+1] stuff, but you probably
could go to the help page and figure out that the appropriate
argument name is "bg" ...)

______________________________________________
[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: Simple question about symbols()

David Winsemius
In reply to this post by murilofm

On Apr 20, 2011, at 8:45 AM, murilofm wrote:

> The link to the csv file is
>
> http://www.filedropper.com/data_5
>
> I use the "d" variable to create the radius:
>
> radius <- sqrt( inv$d/ pi )
>
> and i tried
>
> symbols(inv$a, inv$b, circles=radius, inches=0.35, fg="white",
>   bg="red", xlab="aa", ylab="bb",
>   col=c("blue","red")[inv$c+1])

You should follow the Posting Guide's advice and offer the full code  
you used to read in that data. It's _not_ comma separated, and for  
some reason even using read.csv2 to properly read a semi-colon  
separated file, I also needed to to convert the first two variables  
from factor to numeric  ... please also read the FAQ item on this topic.

Once that was done this "works", since col is _not_ the proper  
argument for coloring with that function:

?symbols

plot.new()
  symbols(inv$a, inv$b, circles=radius, inches=0.35,
          bg=c("blue","red")[inv$c+1])

--

David Winsemius, MD
West Hartford, CT

______________________________________________
[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: Simple question about symbols()

murilofm
Thank you for the answer and sorry about the bad post.... i'll remember that in the future.
By the way, the line code i used to read the data was

inv <- read.csv("data.csv", header=TRUE, sep=";")

I tried before to use the bg, but for some reason it wasn't working out for me.
But now i got it.

Thanks