Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Atte Tenkanen
Hm..., Should these two versions produce the same solution? Unfortunately and shame to confess, I don't know much about the colors in R: myColors <- c("#FF7C00","#00BF40","#00") Colors=rgb2hsv(col2rgb(myColors)) apply(Colors,1,mean) h s v 0.2122974 1.000 0.9163

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Atte Tenkanen
Thanks to William and Bert! Atte 16.4.2016, 18.56, William Dunlap kirjoitti: > Since these are color strings, you can use functions in the grDevices > package (other others) to manipulate them. E.g., you can convert them > to various color spaces and perhaps use the mean in one of those > spaces

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Duncan Murdoch
On 16/04/2016 12:33 PM, Atte Tenkanen wrote: Hm..., Should these two versions produce the same solution? I wouldn't expect them to. Duncan Murdoch Unfortunately and shame to confess, I don't know much about the colors in R: myColors <- c("#FF7C00","#00BF40","#00") Colors=rgb2hsv(col2

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread boB Rudis
grDevices has `convertColor()` and the `colorspace` has other functions that can convert from RBG to Lab space. You should convert the RGB colors to Lab and average them that way (or us other functions to convert to HSL or HSV). It all depends on what you are trying to accomplish with the "average"

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Duncan Murdoch
On 16/04/2016 8:47 AM, Atte Tenkanen wrote: Hi, How would you calculate the "mean colour" of several colours, for example c("#FF7C00","#00BF40","#00")? Bert answered your subject line question. Your text is asking something else: if those are colours, you don't want to treat each of th

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread William Dunlap via R-help
Since these are color strings, you can use functions in the grDevices package (other others) to manipulate them. E.g., you can convert them to various color spaces and perhaps use the mean in one of those spaces as your 'average color'. > myColors <- c(One="#FF7C00",Two="#00BF40",Three="#00

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Bert Gunter
... and if you need to convert back: ?as.hexmode -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Apr 16, 2016 at 8:20 AM, Bert Gunter wrote: >

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Bert Gunter
?strtoi You'll have to remove the "#" first, e.g. via substring() -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Apr 16, 2016 at 5:47 AM, Atte

[R] Mean of hexadecimal numbers

2016-04-16 Thread Atte Tenkanen
Hi, How would you calculate the "mean colour" of several colours, for example c("#FF7C00","#00BF40","#00")? Yours, Atte Tenkanen __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help P