[R] draw a circle with a gradient fill

2017-10-24 Thread Alaios via R-help
Hi all,I would like to draw a simple circle where the color gradient follows 
the rule color = 1/(r^2) where r is the distance from the circle. I would also 
like to add a color bar with values going from -40 to -110 (and associate those 
with the color gradient that fills the circle).
So far I experiemented with draw circle 
install.packages('plotrix')require(plotrix)colors<-c('#fef0d9','#fdcc8a','#fc8d59','#e34a33','#b3')plot(c(-15,15),c(-15,15),type='n')draw.circle(0,
 0, 10, nv = 1000, border = NULL, col = colors[1], lty = 1, lwd = 
1)draw.circle(0, 0, 8, nv = 1000, border = NULL, col = colors[2], lty = 1, lwd 
= 1)draw.circle(0, 0, 6, nv = 1000, border = NULL, col = colors[3], lty = 1, 
lwd = 1)draw.circle(0, 0, 4, nv = 1000, border = NULL, col = colors[4], lty = 
1, lwd = 1)draw.circle(0, 0, 2, nv = 1000, border = NULL, col = colors[5], lty 
= 1, lwd = 1)

but this package does not give easily color gradients and so my solutions 
contains 5 same colors filled rings.
Will there be any suggested improvements on my code above?
Thanks a lotAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] 3D plot with coordinates

2017-06-20 Thread Alaios via R-help
HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So each 
one is having 360 elements each one correpsonding to angular coordinates (1 
degree, 2 degrees, 3 degrees, 360 degrees) and I want to plot those on the 
xyz axes that have degress.
Is there a function or library to look at R cran? The ideal will be that after 
plotting I will be able to rotate the shape.
I would like to thank you in advance for your helpRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] 3D plot with coordinates

2017-06-21 Thread Alaios via R-help
Thanks a lot for the reply.After  looking at different parts of the code today 
I was able to start with simple 2D polar plots as the attached pdf file.  In 
case the attachment is not visible I used the plot.polar function to create 
something like 
that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png
Now the idea now will be to put three of those (for X,Y,Z) in a 3d rotatable 
plane. I tried the rgl function but is not clear how I can use directly polar 
coordinates to draw the points at the three different planes. 
Any ideas on that?
Thanks a lot.RegardsAlex

On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges 
 wrote:
 

 package rgl.

Best,
Uwe Ligges


On 20.06.2017 21:29, Alaios via R-help wrote:
> HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So 
> each one is having 360 elements each one correpsonding to angular coordinates 
> (1 degree, 2 degrees, 3 degrees, 360 degrees) and I want to plot those on 
> the xyz axes that have degress.
> Is there a function or library to look at R cran? The ideal will be that 
> after plotting I will be able to rotate the shape.
> I would like to thank you in advance for your helpRegardsAlex
>     [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
> 


   

XNoSink.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] 3D plot with coordinates

2017-06-21 Thread Alaios via R-help
Thanks Duncan for the replyI can not suppress anything these are radiation 
pattern measurements that are typically are taken at X,Y and Z planes. See an 
example here, where I want to plot the measurements for the red, green and blue 
planes (so the image below withouth the 3d green structure 
inside)https://www.researchgate.net/publication/258391165/figure/fig7/AS:322947316240401@1454008048835/Radiation-pattern-of-Archimedean-spiral-antenna-a-3D-and-b-elevation-cuts-at-phi.png
 

I am quite confident that there is a tool in R to help me do this 3D plot, and 
even better rotatable.
Thanks for the reply to allAlex 

On Wednesday, June 21, 2017 1:07 PM, Duncan Murdoch 
 wrote:
 

 On 21/06/2017 5:23 AM, Alaios via R-help wrote:
> Thanks a lot for the reply.After  looking at different parts of the code 
> today I was able to start with simple 2D polar plots as the attached pdf 
> file.  In case the attachment is not visible I used the plot.polar function 
> to create something like 
> that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png
> Now the idea now will be to put three of those (for X,Y,Z) in a 3d rotatable 
> plane. I tried the rgl function but is not clear how I can use directly polar 
> coordinates to draw the points at the three different planes.
> Any ideas on that?

You can't easily do what you're trying to do.  You have 6 coordinates to 
display:  the 3 angles and values corresponding to each of them.  You 
need to suppress something.

If the values for matching angles correspond to each other (e.g. x=23 
degrees and y=23 degrees and z=23 degrees all correspond to the same 
observation), then I'd suggest suppressing the angles.  Just do a 
scatterplot of the 3 corresponding values.  It might make sense to join 
them (to make a path as the angles change), and perhaps to colour the 
path to indicate the angle (or plot text along the path to show it).

Duncan Murdoch

> Thanks a lot.RegardsAlex
>
>    On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges 
> wrote:
>
>
>  package rgl.
>
> Best,
> Uwe Ligges
>
>
> On 20.06.2017 21:29, Alaios via R-help wrote:
>> HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So 
>> each one is having 360 elements each one correpsonding to angular 
>> coordinates (1 degree, 2 degrees, 3 degrees, 360 degrees) and I want to 
>> plot those on the xyz axes that have degress.
>> Is there a function or library to look at R cran? The ideal will be that 
>> after plotting I will be able to rotate the shape.
>> I would like to thank you in advance for your helpRegardsAlex
>>    [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] 3D plot with coordinates

2017-06-22 Thread Alaios via R-help
Thanks. So after searching 4 hours last night it looks like that there is no R 
package that can do this right now. Any other ideas or suggestions might be 
helpful.RegardsAlex 

On Wednesday, June 21, 2017 3:21 PM, Alaios via R-help 
 wrote:
 

 Thanks Duncan for the replyI can not suppress anything these are radiation 
pattern measurements that are typically are taken at X,Y and Z planes. See an 
example here, where I want to plot the measurements for the red, green and blue 
planes (so the image below withouth the 3d green structure 
inside)https://www.researchgate.net/publication/258391165/figure/fig7/AS:322947316240401@1454008048835/Radiation-pattern-of-Archimedean-spiral-antenna-a-3D-and-b-elevation-cuts-at-phi.png
 

I am quite confident that there is a tool in R to help me do this 3D plot, and 
even better rotatable.
Thanks for the reply to allAlex 

    On Wednesday, June 21, 2017 1:07 PM, Duncan Murdoch 
 wrote:
 

 On 21/06/2017 5:23 AM, Alaios via R-help wrote:
> Thanks a lot for the reply.After  looking at different parts of the code 
> today I was able to start with simple 2D polar plots as the attached pdf 
> file.  In case the attachment is not visible I used the plot.polar function 
> to create something like 
> that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png
> Now the idea now will be to put three of those (for X,Y,Z) in a 3d rotatable 
> plane. I tried the rgl function but is not clear how I can use directly polar 
> coordinates to draw the points at the three different planes.
> Any ideas on that?

You can't easily do what you're trying to do.  You have 6 coordinates to 
display:  the 3 angles and values corresponding to each of them.  You 
need to suppress something.

If the values for matching angles correspond to each other (e.g. x=23 
degrees and y=23 degrees and z=23 degrees all correspond to the same 
observation), then I'd suggest suppressing the angles.  Just do a 
scatterplot of the 3 corresponding values.  It might make sense to join 
them (to make a path as the angles change), and perhaps to colour the 
path to indicate the angle (or plot text along the path to show it).

Duncan Murdoch

> Thanks a lot.RegardsAlex
>
>    On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges 
> wrote:
>
>
>  package rgl.
>
> Best,
> Uwe Ligges
>
>
> On 20.06.2017 21:29, Alaios via R-help wrote:
>> HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So 
>> each one is having 360 elements each one correpsonding to angular 
>> coordinates (1 degree, 2 degrees, 3 degrees, 360 degrees) and I want to 
>> plot those on the xyz axes that have degress.
>> Is there a function or library to look at R cran? The ideal will be that 
>> after plotting I will be able to rotate the shape.
>> I would like to thank you in advance for your helpRegardsAlex
>>    [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Writing my 3D plot function

2017-06-25 Thread Alaios via R-help
Hi all,I had a question last week on asking for a function that will help me 
draw three different circles on x,y,z axis based on polar coordinates (Each 
X,Y,Z circle are coming from three independent measurements of 1-360 polar 
coordinates). It turned out that there  is no such function in R and thus I am 
trying to write my own piece of code that hopefully I will be able to share. I 
have spent some time to write some code based on the rgl library (Still not 
100% sure that this was the best option).
My input are three polar circles X,Y,Z with a good example being the image 
belowhttps://www.mathworks.com/help/examples/antenna/win64/xxpolarpattern_helix.png

So for X axis my input is a 2D matrix [360,2] including a single measurement 
per each polar coordinate. The first thing I tried was to turn my polar 
coordinates to cartesian ones by writing two simple functions. This works so 
far and I was able to print three simple circles on 3d spaceb but the problem 
now are the legends I need to put that remain on cartesian coordinates. As you 
can see from the code below all circles should have radius 1 (in terms of 
simplicity) but unfortunately I have the cartesian coordinates legends that do 
not help on reading my Figure. You can help me by executing the code below 

require("rgls")
degreeToRadian<-function(degree){  return   (0.01745329252*degree)}
turnPolarToX<-function(Amplitude,Coordinate){  return 
(Amplitude*cos(degreeToRadian(Coordinate)))}
turnPolarToY<-function(Amplitude,Coordinate){  return 
(Amplitude*sin(degreeToRadian(Coordinate)))}
# Putting the first circle on 3d space. Circle of radius 
1X1<-turnPolarToX(1,1:360)Y1<-turnPolarToY(1,1:360)Z1<-rep(0,360)
# Putting the second circle on 3d space. Circle of radius 
1X2<-turnPolarToX(1,1:360)Y2<-rep(0,360)Z2<-turnPolarToY(1,1:360)
# Putting the third circle on 3d space. Circle of radius 
1X3<-rep(0,360)Y3<-turnPolarToX(1,1:360)Z3<-turnPolarToY(1,1:360)
Min<-min(X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3)Max<-max(X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3)plot3d(X1,Y1,Z1,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=FALSE,add=TRUE,col="red",type="l")plot3d(X2,Y2,Z2,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=FALSE,add=TRUE,col="green",type="l")plot3d(X3,Y3,Z3,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=TRUE,add=FALSE,col="blue",type="l")
Would it be also possible to include an jpeg image file on a rgls plot?
Thanks a lotRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Writing my 3D plot function

2017-06-26 Thread Alaios via R-help
Thanks a lot for this. I never realized that my yahoo mail does not send plain 
text. So this is the code I have 

require("rgls") 

degreeToRadian<-function(degree){ 
return   (0.01745329252*degree) 
} 

turnPolarToX<-function(Amplitude,Coordinate){ 
return (Amplitude*cos(degreeToRadian(Coordinate))) 
} 

turnPolarToY<-function(Amplitude,Coordinate){ 
return (Amplitude*sin(degreeToRadian(Coordinate))) 
} 

X1<-turnPolarToX(1,1:360) 
Y1<-turnPolarToY(1,1:360) 
Z1<-rep(0,360) 


X2<-turnPolarToX(1,1:360) 
Y2<-rep(0,360) 
Z2<-turnPolarToY(1,1:360) 

test3<-runif(360) 
X3<-rep(0,360) 
Y3<-turnPolarToX(1,1:360) 
Z3<-turnPolarToY(1,1:360) 

Min<-min(X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3) 
Max<-max(X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3) 
plot3d(X1,Y1,Z1,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=FALSE,add=TRUE,col="red",type="l")
 
plot3d(X2,Y2,Z2,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=FALSE,add=TRUE,col="green",type="l")
 
plot3d(X3,Y3,Z3,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=TRUE,add=FALSE,col="blue",type="l")



I hope this helps
Regards
Alex
On Monday, June 26, 2017 1:46 AM, Jeff Newmiller  
wrote:



Please look at what I see in your code below (run-on code mush) to understand 
part of why it is important for you to send your email as plain text as the 
Posting Guide indicates.  You might find [1] helpful. 

[1] https://wiki.openstack.org/wiki/MailingListEtiquette
-- 
Sent from my phone. Please excuse my brevity.


On June 25, 2017 2:42:26 PM EDT, Alaios via R-help  wrote:
>Hi all,I had a question last week on asking for a function that will
>help me draw three different circles on x,y,z axis based on polar
>coordinates (Each X,Y,Z circle are coming from three independent
>measurements of 1-360 polar coordinates). It turned out that there  is
>no such function in R and thus I am trying to write my own piece of
>code that hopefully I will be able to share. I have spent some time to
>write some code based on the rgl library (Still not 100% sure that this
>was the best option).
>My input are three polar circles X,Y,Z with a good example being the
>image
>belowhttps://www.mathworks.com/help/examples/antenna/win64/xxpolarpattern_helix.png
>
>So for X axis my input is a 2D matrix [360,2] including a single
>measurement per each polar coordinate. The first thing I tried was to
>turn my polar coordinates to cartesian ones by writing two simple
>functions. This works so far and I was able to print three simple
>circles on 3d spaceb but the problem now are the legends I need to put
>that remain on cartesian coordinates. As you can see from the code
>below all circles should have radius 1 (in terms of simplicity) but
>unfortunately I have the cartesian coordinates legends that do not help
>on reading my Figure. You can help me by executing the code below 
>
>require("rgls")
>degreeToRadian<-function(degree){  return   (0.01745329252*degree)}
>turnPolarToX<-function(Amplitude,Coordinate){  return
>(Amplitude*cos(degreeToRadian(Coordinate)))}
>turnPolarToY<-function(Amplitude,Coordinate){  return
>(Amplitude*sin(degreeToRadian(Coordinate)))}
># Putting the first circle on 3d space. Circle of radius
>1X1<-turnPolarToX(1,1:360)Y1<-turnPolarToY(1,1:360)Z1<-rep(0,360)
># Putting the second circle on 3d space. Circle of radius
>1X2<-turnPolarToX(1,1:360)Y2<-rep(0,360)Z2<-turnPolarToY(1,1:360)
># Putting the third circle on 3d space. Circle of radius
>1X3<-rep(0,360)Y3<-turnPolarToX(1,1:360)Z3<-turnPolarToY(1,1:360)
>Min<-min(X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3)Max<-max(X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3)plot3d(X1,Y1,Z1,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=FALSE,add=TRUE,col="red",type="l")plot3d(X2,Y2,Z2,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=FALSE,add=TRUE,col="green",type="l")plot3d(X3,Y3,Z3,xlim=c(Min,Max),ylim=c(Min,Max),zlim=c(Min,Max),box=TRUE,axe=TRUE,add=FALSE,col="blue",type="l")
>Would it be also possible to include an jpeg image file on a rgls plot?
>Thanks a lotRegardsAlex
>[[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] scalable and dynamic color bar

2017-07-08 Thread Alaios via R-help
Hi,I am using rgl to plot 3d graphics. You can find below some executable code.
I would like to add a color bar that scales as the window size scale. The 
solution I currently have gives a color bar that gets pixelated once you 
maximize the window.
Can you suggest of alternatives?
ThanksAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] add a color bar

2017-07-10 Thread Alaios via R-help
Hi all,the code you will find at the bottom of the screen creates a 3d diagram 
of antenna measurements. I am adding also to this Figure a color bar,and I 
wanted to ask you if I can add a color bar (which package?) that will scale as 
the windows is maximized. My current color bar is a bit too rought and gets 
pixelized each time I maximize the window.
Any suggestions?I would like to thank you for your replyRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] why data.frame, mutate package and not lists

2016-09-14 Thread Alaios via R-help
Hi all,I have seen data.frames and operations from the mutate package getting 
really popular. In the last years I have been using extensively lists, is there 
any reason to not use lists and use other data types for data manipulation and 
storage?
Any article that describe their differences? I would like to thank you for your 
replyRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] why data.frame, mutate package and not lists

2016-09-14 Thread Alaios via R-help
thanks for all the answers. I think also ggplot2 requires data.frames.If you 
want to add variable to data.frame you have to use attach, detach. Right?Any 
more links that discuss thoe two different approaches?Alex 

On Wednesday, September 14, 2016 5:34 PM, Bert Gunter 
 wrote:
 

 This is partially a matter of subjectve opinion, and so pointless; but
I would point out that data frames are the canonical structure for a
great many of R's modeling and graphics functions, e.g. lm, xyplot,
etc.

As for mutate() etc., that's about UI's and user friendliness, and
imho my ho is meaningless.

Best,
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 Wed, Sep 14, 2016 at 6:01 AM, Alaios via R-help  wrote:
> Hi all,I have seen data.frames and operations from the mutate package getting 
> really popular. In the last years I have been using extensively lists, is 
> there any reason to not use lists and use other data types for data 
> manipulation and storage?
> Any article that describe their differences? I would like to thank you for 
> your replyRegardsAlex
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Multinomial Fitting Distrbution

2015-04-21 Thread Alaios via R-help
Dear all,I am trying to fit a heavy tailed distribution and I have tried 
working with the mix function of the mixdist package.It looks like that this 
package allows fitting two distributions (or move) of the same family  and not 
combining different distributions (so mixing a geometric with a normal and so 
on).
After trying with the mix tool all the different combinations have failed. (I 
am not know if images are allowed here as attachments and thus I am sharing a 
link with the uploaded image )
http://alexpal.smugmug.com/photos/i-N76qWsM/0/O/i-N76qWsM.jpg
You can see that the three different families of distribution failed to capture 
correct the heavy tail at the end.
Can you please sugest me which functions (package) I could try in R for 
combining two different distributions for a fit?
I would like to thank you for your reply


|   |
|   |  |   |   |   |   |   |
|  |
|  |
| View on alexpal.smugmug.com | Preview by Yahoo |
|  |
|   |



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] combining two distributions

2014-12-08 Thread Alaios via R-help
(I am sorry if you have received this email twice but it does not look sent on 
my client)

  

 Hi all,I am having some heavy tailed data and I am trying to think of the more 
appropriate package for the fitting.The canonical try should be something like 
exponential and pareto or exponential + gamma (or gamma + gamma with different 
shape parameters). I am trying to have one distribution that is "classical" 
thin tailed one and another one which is more like a power law or close 
(pareto,gamma,weibull, log-normal).
Do you have any recommendation with which packages I can start on and if the 
functions you have in mind they can also provide information like AIC or BIC so 
to help me choose the best combinations?
I would like to thank you in advance for your help
RegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] combining two distributions

2014-12-08 Thread Alaios via R-help
Hi all,I am having some heavy tailed data and I am trying to think of the more 
appropriate package for the fitting.The canonical try should be something like 
exponential and pareto or exponential + gamma (or gamma + gamma with different 
shape parameters). I am trying to have one distribution that is "classical" 
thin tailed one and another one which is more like a power law or close 
(pareto,gamma,weibull, log-normal).
Do you have any recommendation with which packages I can start on and if the 
functions you have in mind they can also provide information like AIC or BIC so 
to help me choose the best combinations?
I would like to thank you in advance for your help
RegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] combining two distributions

2014-12-08 Thread Alaios via R-help
Hi,thanks a lot for the answer. I think that my problem is before packages. I 
have a large amount of different datasets and I had a random look on their 
histograms. I know that some of them look like the combination I have explained 
(exponential+pareto, exponential+gamma) but I am not sure still.I wanted to 
know if there is a "preliminary" approach where a fitting algorithms tries some 
of the suggested combinations and give me hints where to focus my future 
research.I will have a look on the package you suggested.
RegardsAlex
 

 On Monday, December 8, 2014 11:23 PM, Spencer Graves 
 wrote:
   

       Have you considered "distr" and related packages?


      If this does not solve your problem, have you considered 
searching with "findFn" in the "sos" package?  If that still does not 
produce sufficient enlightenment, please try this list again with 
"commented, minimal, self-contained, reproducible code" describing what 
you want in a bit more detail (as indicated at the end of emails on this 
list).


      Spencer


On 12/8/2014 10:45 AM, Alaios via R-help wrote:
> (I am sorry if you have received this email twice but it does not look sent 
> on my client)
>
>    
>
>  Hi all,I am having some heavy tailed data and I am trying to think of the 
>more appropriate package for the fitting.The canonical try should be something 
>like exponential and pareto or exponential + gamma (or gamma + gamma with 
>different shape parameters). I am trying to have one distribution that is 
>"classical" thin tailed one and another one which is more like a power law or 
>close (pareto,gamma,weibull, log-normal).
> Do you have any recommendation with which packages I can start on and if the 
> functions you have in mind they can also provide information like AIC or BIC 
> so to help me choose the best combinations?
> I would like to thank you in advance for your help
> RegardsAlex
>
>      
>     [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] combinations between two vectors

2014-12-18 Thread Alaios via R-help
Hi all,I am looking for a function that would give me all the combinations 
between two vectors.Lets take as example the 

test<-seq(1,3,by=5000)
Browse[2]> test
[1] 1  5001 10001 15001 20001 25001
I want all the combinations between two times the test... I think this is  
called permutation so a function that could do permutation(test,test)and 
produce the following
1,11,50011,100011,15001
3,13,5001...25001,20001,25001,25001
is there such a function ?
RegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] save structure to be accesible later

2015-02-05 Thread Alaios via R-help
Dear all,I have a function that returns the following list. At the end I will 
call my function 1000 times and I want to keep for each of these 1000 "results" 
(the structure as given below)in an order to be accessible later (Load the 1000 
results and access them within a for loop for example)
How should I approach the issue?I would like to thank you for your 
exampleRegardsAlex
P,S The result of my function



 str(fitcass1)
List of 10
 $ parameters  :'data.frame':   2 obs. of  3 variables:
  ..$ pi   : num [1:2] 0.833 0.167
  ..$ mu   : num [1:2] 8828 11
  ..$ sigma: num [1:2] 18085 1543
 $ se  :'data.frame':   2 obs. of  3 variables:
  ..$ pi.se   : num [1:2] NA NA
  ..$ mu.se   : num [1:2] NA NA
  ..$ sigma.se: num [1:2] NA NA
 $ distribution: chr "gamma"
 $ constraint  :List of 8
  ..$ conpi   : chr "NONE"
  ..$ conmu   : chr "NONE"
  ..$ consigma: chr "NONE"
  ..$ fixpi   : NULL
  ..$ fixmu   : NULL
  ..$ fixsigma: NULL
  ..$ cov : NULL
  ..$ size    : NULL
 $ chisq   : num 52.4
 $ df  : num 5
 $ P   : num 4.57e-10
 $ vmat    : num [1:5, 1:5] NA NA NA NA NA NA NA NA NA NA ...
 $ mixdata :Classes ‘mixdata’ and 'data.frame': 11 obs. of  2 variables:
  ..$ X    : num [1:11] 1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 
1e+05 ...
  ..$ count: int [1:11] 993 137 82 30 21 5 7 14 21 2 ...
 $ usecondit   : logi FALSE
 - attr(*, "class")= chr "mix"



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Parallel for that does not keep the results

2015-02-24 Thread Alaios via R-help
Hi all,I am working in a multi core machine and I am trying to make some 
parallel code to speed up the process.
I have seen already the foreach packet but it looks like that it always combine 
the results on a list. My case though is simpler since I am plotting and saving 
in external files, inside the loop, and thus I do not need to keep anything 
from the loop.My code looks like
    expandMeanSigmaOn<-expand.grid(1:100,100:200,5:10,5000:6000)
   for (i in 1:length(expandMeanSigmaOn$Var1)){
                                        mean1<-expandMeanSigmaOn$Var1[i]
                                        mean2<-expandMeanSigmaOn$Var2[i]
                                        sd1<-expandMeanSigmaOn$Var3[i]
                                        sd2<-expandMeanSigmaOn$Var4[i]
                                   
                                            
fitcass1<-mix(mydata,mixparam(c(mean1,mean2),(c(sd1,sd2)),"gamma")))
                                            
pdf(file=paste(filename,"ON.pdf",sep=""));plot(fitcass1);dev.off() # plotting 
and saving
                                            
save(OnFitList,file=paste(filename,"ON.Rdata",sep="")) # plotting and saving
                                            }
                                        }
 }

as you can see from the code above, given some input values I am trying some 
fits, which then I am saving the results. Do you think that the foreach 
packaget would be suitable (since the returning list can grow very large and 
eat up memory) or should I try some alternative package?
I would like to thank you in advance for your replyRegardsAlex

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] from expand.grid to a list (lapply)

2015-02-25 Thread Alaios via R-help
Hi all,I would like to use an expand.grid functionality that would give me at 
the end a listso far my code looks like:
 sigma_max_On_seq<-seq(0.05,100,length.out=1)
mean_max_On_seq<-seq(2,1),length.out=1)
expandMeanSigmaOn<-expand.grid(mean_max_On_seq,mean_max_On_seq,sigma_max_On_seq,sigma_max_On_seq)
that gives me at the end all the possible combinations as a data 
frame.Browse[1]> str((expandMeanSigmaOn))
'data.frame':   XXX obs. of  4 variables:
 $ Var1: num  1 11432 22864 34295 45727 ...
 $ Var2: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Var3: num  0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 ...
 $ Var4: num  0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim : int  10 10 10 10
  ..$ dimnames:List of 4
  .. ..$ Var1: chr  "Var1= 1.00" "Var1= 11432.44" "Var1= 22863.89" "Var1= 
34295.33" ...
  .. ..$ Var2: chr  "Var2= 1.00" "Var2= 11432.44" "Var2= 22863.89" "Var2= 
34295.33" ...
  .. ..$ Var3: chr  "Var3=  0.05000" "Var3= 31.48065" "Var3= 62.91131" "Var3= 
94.34196" ...
  .. ..$ Var4: chr  "Var4=  0.05000" "Var4= 31.48065" "Var4= 62.91131" "Var4= 
94.34196" ...

 but I want to have a list that I would be able to use it as input into a 
lapply function. The lapply should use then each list entry independently 
giving as input variables only the current $Var1,$Var2,$Var3,$Var4

How I can convert in R the data.frame into a list?
I would like to thank you in advance for your replyRegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Save a list of list and search for values

2015-02-26 Thread Alaios via R-help
Dear all,in my code I am using the mix() function that returns results in a 
list. The result looks like
List of 10
 $ parameters  :'data.frame':   2 obs. of  3 variables:
  ..$ pi   : num [1:2] 0.77 0.23
  ..$ mu   : num [1:2] -7034 162783
  ..$ sigma: num [1:2] 20235 95261
 $ se  :'data.frame':   2 obs. of  3 variables:
  ..$ pi.se   : num [1:2] 0.0423 0.0423
  ..$ mu.se   : num [1:2] 177 12422
  ..$ sigma.se: num [1:2] 1067 65551
 $ distribution: chr "norm"
 $ constraint  :List of 8
  ..$ conpi   : chr "NONE"
  ..$ conmu   : chr "NONE"
  ..$ consigma: chr "NONE"
  ..$ fixpi   : NULL
  ..$ fixmu   : NULL
  ..$ fixsigma: NULL
  ..$ cov : NULL
  ..$ size    : NULL
 $ chisq   : num 28
 $ df  : num 5
 $ P   : num 3.67e-05
 $ vmat    : num [1:5, 1:5] 1.79e-03 -3.69e-01 -1.17e+02 2.95e+01 -2.63e+03 
...
 $ mixdata :Classes ‘mixdata’ and 'data.frame': 11 obs. of  2 variables:
  ..$ X    : num [1:11] 1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 
1e+05 ...
  ..$ count: int [1:11] 993 137 82 30 21 5 7 14 21 2 ...
 $ usecondit   : logi FALSE
 - attr(*, "class")= chr "mix"

In my code I am trying around 10.000 fit (and each of these fits returns the 
list above) and I want to keep those in a way that later on I would be able to 
search inside all the lists.For example I would like to find inside those 
10.000 lists which one has the smallest $chisq value. What would be a suitable 
way to implement that in R? Luckily I am working in a computer with a lot of 
ram so storing 10.000 lists temporary in memory before saving to disk would not 
be a problem.
What would you suggest me?
RegardsAlex

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Save a list of list and search for values

2015-02-27 Thread Alaios via R-help
Hi,thanks all for the answer.I am using mclapply to call the lapply many times 
as needed. My function returns only a value if the fit is succesful.For testing 
if the fit is sucessfuly my code works like that
fitcass1<-tryCatch(mix(mixdat=mydataOnVector,mixpar=params,dist=distribution),error=function(e)
 list(e,"Error"))
if (fitcass1[[2]]=="Error"){
                                              print(sprintf("error at fitting 
gamma distribution with %s periods. Mean %f %f Sd %f 
%f",flag,mean1,mean2,sd1,sd2))

                                            }else{ 
(code trunctated)... where I do some plots

so at the end of the function the code looks like
if (fitcass1[[2]]!="Error")
                                        return(fitcass1)

then I am calling the function above with
keeptheBigListAsJimSuggested<-mclapply(expandMeanSigmaOn_list,callFunctionAbove,mydataOnVector=mydataOnVector,filename=filename,mc.cores=64)

If I am not wrong that would work. I will try later after my code stops 
executing. 
Any more comments on this?
RegardsAlex

 

 On Thursday, February 26, 2015 3:39 PM, jim holtman  
wrote:
   

 You store it as a list of lists and can then use the lapply function
to navigate for values.

result <- lapply(1:1, function(x){
    mix(param[x])  # whatever your call to 'mix' is with some data
})





Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Thu, Feb 26, 2015 at 9:27 AM, Alaios via R-help  wrote:
> Dear all,in my code I am using the mix() function that returns results in a 
> list. The result looks like
> List of 10
>  $ parameters  :'data.frame':  2 obs. of  3 variables:
>  ..$ pi  : num [1:2] 0.77 0.23
>  ..$ mu  : num [1:2] -7034 162783
>  ..$ sigma: num [1:2] 20235 95261
>  $ se          :'data.frame':  2 obs. of  3 variables:
>  ..$ pi.se  : num [1:2] 0.0423 0.0423
>  ..$ mu.se  : num [1:2] 177 12422
>  ..$ sigma.se: num [1:2] 1067 65551
>  $ distribution: chr "norm"
>  $ constraint  :List of 8
>  ..$ conpi  : chr "NONE"
>  ..$ conmu  : chr "NONE"
>  ..$ consigma: chr "NONE"
>  ..$ fixpi  : NULL
>  ..$ fixmu  : NULL
>  ..$ fixsigma: NULL
>  ..$ cov    : NULL
>  ..$ size    : NULL
>  $ chisq      : num 28
>  $ df          : num 5
>  $ P          : num 3.67e-05
>  $ vmat        : num [1:5, 1:5] 1.79e-03 -3.69e-01 -1.17e+02 2.95e+01 
>-2.63e+03 ...
>  $ mixdata    :Classes ‘mixdata’ and 'data.frame':    11 obs. of  2 variables:
>  ..$ X    : num [1:11] 1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 
>1e+05 ...
>  ..$ count: int [1:11] 993 137 82 30 21 5 7 14 21 2 ...
>  $ usecondit  : logi FALSE
>  - attr(*, "class")= chr "mix"
>
> In my code I am trying around 10.000 fit (and each of these fits returns the 
> list above) and I want to keep those in a way that later on I would be able 
> to search inside all the lists.For example I would like to find inside those 
> 10.000 lists which one has the smallest $chisq value. What would be a 
> suitable way to implement that in R? Luckily I am working in a computer with 
> a lot of ram so storing 10.000 lists temporary in memory before saving to 
> disk would not be a problem.
> What would you suggest me?
> RegardsAlex
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Save a list of list and search for values

2015-02-27 Thread Alaios via R-help
Sorry Jim I forgot to reply on what I am trying to do.I  have many data sets 
that contain some numbers: I am trying to fit those with a mixture 
distribution. For that I am using the mix function that returns me back the 
fitted parameters and the chi square (which is a first performance 
indicator).After all the fits are completed and gathered on the big list, I 
would like to see which are the fits with the better chi square numbers and 
what are their typical numbers. After I see that results I would have to think 
more on how to proceed
RegardsAlex
 

 On Friday, February 27, 2015 1:58 PM, Alaios  wrote:
   

 Hi,thanks all for the answer.I am using mclapply to call the lapply many times 
as needed. My function returns only a value if the fit is succesful.For testing 
if the fit is sucessfuly my code works like that
fitcass1<-tryCatch(mix(mixdat=mydataOnVector,mixpar=params,dist=distribution),error=function(e)
 list(e,"Error"))
if (fitcass1[[2]]=="Error"){
                                              print(sprintf("error at fitting 
gamma distribution with %s periods. Mean %f %f Sd %f 
%f",flag,mean1,mean2,sd1,sd2))

                                            }else{ 
(code trunctated)... where I do some plots

so at the end of the function the code looks like
if (fitcass1[[2]]!="Error")
                                        return(fitcass1)

then I am calling the function above with
keeptheBigListAsJimSuggested<-mclapply(expandMeanSigmaOn_list,callFunctionAbove,mydataOnVector=mydataOnVector,filename=filename,mc.cores=64)

If I am not wrong that would work. I will try later after my code stops 
executing. 
Any more comments on this?
RegardsAlex

 

 On Thursday, February 26, 2015 3:39 PM, jim holtman  
wrote:
   

 You store it as a list of lists and can then use the lapply function
to navigate for values.

result <- lapply(1:1, function(x){
    mix(param[x])  # whatever your call to 'mix' is with some data
})





Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Thu, Feb 26, 2015 at 9:27 AM, Alaios via R-help  wrote:
> Dear all,in my code I am using the mix() function that returns results in a 
> list. The result looks like
> List of 10
>  $ parameters  :'data.frame':  2 obs. of  3 variables:
>  ..$ pi  : num [1:2] 0.77 0.23
>  ..$ mu  : num [1:2] -7034 162783
>  ..$ sigma: num [1:2] 20235 95261
>  $ se          :'data.frame':  2 obs. of  3 variables:
>  ..$ pi.se  : num [1:2] 0.0423 0.0423
>  ..$ mu.se  : num [1:2] 177 12422
>  ..$ sigma.se: num [1:2] 1067 65551
>  $ distribution: chr "norm"
>  $ constraint  :List of 8
>  ..$ conpi  : chr "NONE"
>  ..$ conmu  : chr "NONE"
>  ..$ consigma: chr "NONE"
>  ..$ fixpi  : NULL
>  ..$ fixmu  : NULL
>  ..$ fixsigma: NULL
>  ..$ cov    : NULL
>  ..$ size    : NULL
>  $ chisq      : num 28
>  $ df          : num 5
>  $ P          : num 3.67e-05
>  $ vmat        : num [1:5, 1:5] 1.79e-03 -3.69e-01 -1.17e+02 2.95e+01 
>-2.63e+03 ...
>  $ mixdata    :Classes ‘mixdata’ and 'data.frame':    11 obs. of  2 variables:
>  ..$ X    : num [1:11] 1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 
>1e+05 ...
>  ..$ count: int [1:11] 993 137 82 30 21 5 7 14 21 2 ...
>  $ usecondit  : logi FALSE
>  - attr(*, "class")= chr "mix"
>
> In my code I am trying around 10.000 fit (and each of these fits returns the 
> list above) and I want to keep those in a way that later on I would be able 
> to search inside all the lists.For example I would like to find inside those 
> 10.000 lists which one has the smallest $chisq value. What would be a 
> suitable way to implement that in R? Luckily I am working in a computer with 
> a lot of ram so storing 10.000 lists temporary in memory before saving to 
> disk would not be a problem.
> What would you suggest me?
> RegardsAlex
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] check a list that a sublist exists

2015-03-03 Thread Alaios via R-help
Hi all,I have a list that has the following fields.
$`80`
[1] "Error in if (fitcass1[[2]] == \"Error\") { : \n  Fehlender Wert, wo 
TRUE/FALSE nötig ist\n"
attr(,"class")
[1] "try-error"
attr(,"condition")



$`81`
[1] 0

$`9`
[1] 0

$`79`
$parameters
    pi   mu    sigma
1 0.9996796725 1.654832 127.6542
2 0.0003203275 17183.001125 302.8063

$se
 pi.se  mu.se sigma.se
1 2.113882e-05  0.1439152 14.22274
2 2.113882e-05 38.3582148  NaN

$distribution
[1] "gamma"



and so one. The content of each first level sublist are never the same. I want 
for each first-level sublist my list has to check fast that the current element 
, lets say the 79th has the $parameters.then I would keep only the numbers from 
the sublists that have this $parameters inside them and skip all the rest.
I tried something like exists(Mylist[[i]]$parameters) but it does not workI 
also tried the is.numeric(Mylist[[i]]$parameters)) but this line fails when the 
current sublist does not contain the $parameters field.
Can you please help me sort this out?
RegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] From replicate to accesing sublists

2015-04-01 Thread Alaios via R-help
Dear all,I have a R structure that was created with replicate.The data sets 
looks to be a matrix with each cell being a list.
str(error_suburban_0[,1],max.level=1)
List of 4
 $ vaR  :List of 20
  ..- attr(*, "class")= chr "variogram"
 $ Shadowing:List of 2
  ..- attr(*, "class")= chr "geodata"
 $ FIT  :List of 1
 $ propmodel:List of 12
  ..- attr(*, "class")= chr "lm"


The error_suburban is a matrix that each field so 
error_suburban_0[,1], error_suburban_0[,2], error_suburban_0[,3], 
error_suburban_0[,4],... and so on,  contains the four sublists
$ vaR  :List of 20
  ..- attr(*, "class")= chr "variogram"
 $ Shadowing:List of 2
  ..- attr(*, "class")= chr "geodata"
 $ FIT  :List of 1
 $ propmodel:List of 12
  ..- attr(*, "class")= chr "lm"


I would like to pick for each of these matrix elements to collect only the 
$Shadowing sublist
error_suburban_0[,1], error_suburban_0[,2], error_suburban_0[,3], 
error_suburban_0[,4]... and so on

Right now I am implementing this by a for loop that access each matrix element 
sequentially.

Can you please advice me if there is a better approach to do that in R?
Regards
Alex
 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] change language at console

2015-04-01 Thread Alaios via R-help
Hi all,I am a linux R user and my default R environemnt (after writing R in 
linux console) returns the error messages in German (I am not the system 
adminitstrator and I can not change system settings). I know that the English 
package is also installed so I guess I need to set some environmental variable 
for this.Any idea how I am doing that?
RegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] From replicate to accesing sublists

2015-04-01 Thread Alaios via R-help
Thanks.The code you gave me at the end works correctly.. I was wondering if 
there is more efficient way to access each element withouth this classic for 
loop.
RegardsAlex
 


 On Wednesday, April 1, 2015 5:54 PM, David Winsemius 
 wrote:
   

 
On Apr 1, 2015, at 3:34 AM, Alaios via R-help wrote:

> Dear all,I have a R structure that was created with replicate.The data sets 
> looks to be a matrix with each cell being a list.
> str(error_suburban_0[,1],max.level=1)
> List of 4
> $ vaR      :List of 20
>  ..- attr(*, "class")= chr "variogram"
> $ Shadowing:List of 2
>  ..- attr(*, "class")= chr "geodata"
> $ FIT      :List of 1
> $ propmodel:List of 12
>  ..- attr(*, "class")= chr "lm"
> 
> 
> The error_suburban is a matrix that each field so 
> error_suburban_0[,1], error_suburban_0[,2], error_suburban_0[,3], 
> error_suburban_0[,4],... and so on,  contains the four sublists
> $ vaR      :List of 20
>  ..- attr(*, "class")= chr "variogram"
> $ Shadowing:List of 2
>  ..- attr(*, "class")= chr "geodata"
> $ FIT      :List of 1
> $ propmodel:List of 12
>  ..- attr(*, "class")= chr "lm"
> 
> 
> I would like to pick for each of these matrix elements to collect only the 
> $Shadowing sublist
> error_suburban_0[,1], error_suburban_0[,2], error_suburban_0[,3], 
> error_suburban_0[,4]... and so on
> 
> Right now I am implementing this by a for loop that access each matrix 
> element sequentially.

It would have been better to show the results of dim() or dput(). Matrix 
objects (which are capable of holding lists) should be accessible with either a 
single or double argument to "[". This should deliver contents:

for (i in 1:4)  print(  error_suburban_0[i]$Shadowing )

If the matrix has 4 or more rows, then that would be accessing only from the 
first column. If fewer than 4 rows, you would be wrapping around to later 
columns.

-- 
David.

> 
> Can you please advice me if there is a better approach to do that in R?
> Regards
> Alex
>  
> 
>     [[alternative HTML version deleted]]

This is a plain text mailing list. Please reconfigure your email client to sent 
in plain text.

-- 

David Winsemius
Alameda, CA, USA


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] starting with mixture distribution

2014-11-30 Thread Alaios via R-help
Hi.I was using the last night the fitdistr package to start with some fitting. 
I have some data sets that even though have a very gaussian distribution it 
looks like that also it has some very heavy tails, that can not be accurately 
be modelled by a gaussian distribution.Where should I give a try with mixture 
of distribution?
RegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] threshold and replace values in a matrix

2015-10-21 Thread Alaios via R-help
Dear all I have a table as that.
test<-matrix(data=rnorm(100),ncol=10)
and I want to find the values that are below my thresholdthreshold<- -0.5and 
replace them with a -1 instead.

I can of course write a double nested for loop to check one by one elementif 
(test[i,j]<= threshold)   test[i,j]<- -1
but that would be rather inneficient sice I have very large tables.
Does R offer any "automation" for matrix data types?
I would like to thank you in advance for your replyRegardsAlex

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] threshold and replace values in a matrix

2015-10-21 Thread Alaios via R-help
Thanks. replace also looks to work okay. 


 On Wednesday, October 21, 2015 3:43 PM, PIKAL Petr 
 wrote:
   

 Hi

I wonder why you are asking that after quite a long use of R.

test[test < (-.5)] <- (-1)

Double loops seems to me the last resort in R if any other approach fails.

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios
> via R-help
> Sent: Wednesday, October 21, 2015 3:35 PM
> To: R-help Mailing List
> Subject: [R] threshold and replace values in a matrix
>
> Dear all I have a table as that.
> test<-matrix(data=rnorm(100),ncol=10)
> and I want to find the values that are below my thresholdthreshold<- -
> 0.5and replace them with a -1 instead.
>
> I can of course write a double nested for loop to check one by one
> elementif (test[i,j]<= threshold)  test[i,j]<- -1 but that would be
> rather inneficient sice I have very large tables.
> Does R offer any "automation" for matrix data types?
> I would like to thank you in advance for your replyRegardsAlex
>
>      [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] merging-binning data

2015-11-03 Thread Alaios via R-help
Dear all,I am not exactly sure on what is the proper name of what I am trying 
to do.
I have a vector that looks like
 binDistance
   [,1]
 [1,] 238.95162
 [2,] 143.08590
 [3,]  88.50923
 [4,] 177.67884
 [5,] 277.54116
 [6,] 342.94689
 [7,] 241.60905
 [8,] 177.81969
 [9,] 211.25559
[10,] 279.72702
[11,] 381.95738
[12,] 483.76363
[13,] 480.98841
[14,] 369.75241
[15,] 267.73650
[16,] 138.55959
[17,] 137.93181
[18,] 184.75200
[19,] 254.64359
[20,] 328.87785
[21,] 273.15577
[22,] 252.52830
[23,] 252.52830
[24,] 252.52830
[25,] 262.20084
[26,] 314.93064
[27,] 366.02996
[28,] 442.77467
[29,] 521.20323
[30,] 465.33071
[31,] 366.60582
[32,]  13.69540
so numbers that start from 13 and go up to maximum 522 (I have also many other 
similar sets).I want to put these numbers into 5 categories and thus I have 
tried cut


Browse[2]> 
test<-cut(binDistance,seq(min(binDistance)-0.1,max(binDistance),length.out=scaleLength+1))
Browse[2]> test
 [1] (217,318]  (115,217]  (13.7,115] (115,217]  (217,318]  (318,420] 
 [7] (217,318]  (115,217]  (115,217]  (217,318]  (318,420]  (420,521] 
[13] (420,521]  (318,420]  (217,318]  (115,217]  (115,217]  (115,217] 
[19] (217,318]  (318,420]  (217,318]  (217,318]  (217,318]  (217,318] 
[25] (217,318]  (217,318]  (318,420]  (420,521]  (420,521]  (420,521] 
[31] (318,420]  (13.7,115]
Levels: (13.7,115] (115,217] (217,318] (318,420] (420,521]


I want then for the numbers of my initial vector that fall within the same 
"category" lets say the (318,420] to be collected on a vector.I rephrase it the 
indexes of my initial vector that have a value between 318 to 420 to be put in 
a same vector that I can process then as I want.
How I can do that effectively in R?
I would like to thank you for your replyRegardsAlex

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] merging-binning data

2015-11-04 Thread Alaios via R-help
Thanks for the answer. Split does not give me the indexes though but only in 
which group they fall in. I also need the index of the group. Is the first, the 
second .. group?Alex
 


 On Tuesday, November 3, 2015 5:05 PM, Ista Zahn  wrote:
   

 Probably

split(binDistance, test).

Best,
Ista

On Tue, Nov 3, 2015 at 10:47 AM, Alaios via R-help  wrote:
> Dear all,I am not exactly sure on what is the proper name of what I am trying 
> to do.
> I have a vector that looks like
>  binDistance
>            [,1]
>  [1,] 238.95162
>  [2,] 143.08590
>  [3,]  88.50923
>  [4,] 177.67884
>  [5,] 277.54116
>  [6,] 342.94689
>  [7,] 241.60905
>  [8,] 177.81969
>  [9,] 211.25559
> [10,] 279.72702
> [11,] 381.95738
> [12,] 483.76363
> [13,] 480.98841
> [14,] 369.75241
> [15,] 267.73650
> [16,] 138.55959
> [17,] 137.93181
> [18,] 184.75200
> [19,] 254.64359
> [20,] 328.87785
> [21,] 273.15577
> [22,] 252.52830
> [23,] 252.52830
> [24,] 252.52830
> [25,] 262.20084
> [26,] 314.93064
> [27,] 366.02996
> [28,] 442.77467
> [29,] 521.20323
> [30,] 465.33071
> [31,] 366.60582
> [32,]  13.69540
> so numbers that start from 13 and go up to maximum 522 (I have also many 
> other similar sets).I want to put these numbers into 5 categories and thus I 
> have tried cut
>
>
> Browse[2]> 
> test<-cut(binDistance,seq(min(binDistance)-0.1,max(binDistance),length.out=scaleLength+1))
> Browse[2]> test
>  [1] (217,318]  (115,217]  (13.7,115] (115,217]  (217,318]  (318,420]
>  [7] (217,318]  (115,217]  (115,217]  (217,318]  (318,420]  (420,521]
> [13] (420,521]  (318,420]  (217,318]  (115,217]  (115,217]  (115,217]
> [19] (217,318]  (318,420]  (217,318]  (217,318]  (217,318]  (217,318]
> [25] (217,318]  (217,318]  (318,420]  (420,521]  (420,521]  (420,521]
> [31] (318,420]  (13.7,115]
> Levels: (13.7,115] (115,217] (217,318] (318,420] (420,521]
>
>
> I want then for the numbers of my initial vector that fall within the same 
> "category" lets say the (318,420] to be collected on a vector.I rephrase it 
> the indexes of my initial vector that have a value between 318 to 420 to be 
> put in a same vector that I can process then as I want.
> How I can do that effectively in R?
> I would like to thank you for your replyRegardsAlex
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] merging-binning data

2015-11-04 Thread Alaios via R-help
Thanks it works great and gives me group numbers as integers and thus I can 
with which group the elements as needed (which (groups== 2))
Question though is how to keep also the labels for each group. For example that 
my first group is the [13,206)
RegardsAlex
 


 On Wednesday, November 4, 2015 1:00 PM, Boris Steipe 
 wrote:
   

 I would transform the original numbers into integers which you can use as 
group labels. The row numbers of the group labels are the indexes of your 
values.

Example: assume your input vector is dBin

nGroups <- 5  # number of groups
groups <- (dBin - min(dBin)) / (max(dBin) - min(dBin)) # rescale to the range 
[0,1]
groups <- floor(groups * nGroups) + 1  # discretize to nGroups integers

Now you can eg. get the indices for group 2

groups[groups == 2]

Depending on the nature of your input data, it may be better to keep these 
groups in a column adjacent to your values, rather than in a separate vector, 
or even better to just calculate the groups on the fly in your downstream 
analysis with the approach given above in a function, rather than storing them 
at all. These are simple operations that should not add perceptibly to 
execution time.

Cheers,
Boris






On Nov 4, 2015, at 6:40 AM, Alaios via R-help  wrote:

> Thanks for the answer. Split does not give me the indexes though but only in 
> which group they fall in. I also need the index of the group. Is the first, 
> the second .. group?Alex
> 
> 
> 
>    On Tuesday, November 3, 2015 5:05 PM, Ista Zahn  wrote:
> 
> 
> Probably
> 
> split(binDistance, test).
> 
> Best,
> Ista
> 
> On Tue, Nov 3, 2015 at 10:47 AM, Alaios via R-help  
> wrote:
>> Dear all,I am not exactly sure on what is the proper name of what I am 
>> trying to do.
>> I have a vector that looks like
>>  binDistance
>>            [,1]
>>  [1,] 238.95162
>>  [2,] 143.08590
>>  [3,]  88.50923
>>  [4,] 177.67884
>>  [5,] 277.54116
>>  [6,] 342.94689
>>  [7,] 241.60905
>>  [8,] 177.81969
>>  [9,] 211.25559
>> [10,] 279.72702
>> [11,] 381.95738
>> [12,] 483.76363
>> [13,] 480.98841
>> [14,] 369.75241
>> [15,] 267.73650
>> [16,] 138.55959
>> [17,] 137.93181
>> [18,] 184.75200
>> [19,] 254.64359
>> [20,] 328.87785
>> [21,] 273.15577
>> [22,] 252.52830
>> [23,] 252.52830
>> [24,] 252.52830
>> [25,] 262.20084
>> [26,] 314.93064
>> [27,] 366.02996
>> [28,] 442.77467
>> [29,] 521.20323
>> [30,] 465.33071
>> [31,] 366.60582
>> [32,]  13.69540
>> so numbers that start from 13 and go up to maximum 522 (I have also many 
>> other similar sets).I want to put these numbers into 5 categories and thus I 
>> have tried cut
>> 
>> 
>> Browse[2]> 
>> test<-cut(binDistance,seq(min(binDistance)-0.1,max(binDistance),length.out=scaleLength+1))
>> Browse[2]> test
>>  [1] (217,318]  (115,217]  (13.7,115] (115,217]  (217,318]  (318,420]
>>  [7] (217,318]  (115,217]  (115,217]  (217,318]  (318,420]  (420,521]
>> [13] (420,521]  (318,420]  (217,318]  (115,217]  (115,217]  (115,217]
>> [19] (217,318]  (318,420]  (217,318]  (217,318]  (217,318]  (217,318]
>> [25] (217,318]  (217,318]  (318,420]  (420,521]  (420,521]  (420,521]
>> [31] (318,420]  (13.7,115]
>> Levels: (13.7,115] (115,217] (217,318] (318,420] (420,521]
>> 
>> 
>> I want then for the numbers of my initial vector that fall within the same 
>> "category" lets say the (318,420] to be collected on a vector.I rephrase it 
>> the indexes of my initial vector that have a value between 318 to 420 to be 
>> put in a same vector that I can process then as I want.
>> How I can do that effectively in R?
>> I would like to thank you for your replyRegardsAlex
>> 
>>        [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] merging-binning data

2015-11-04 Thread Alaios via R-help
you are right.by labels I mean the "categories", "breaks" that my data fall 
in.To be part of group 2 for example you have to be in the range of [110,223) I 
need to keep those for my plots.
Did I describe it more precisely now?Alex
 


 On Wednesday, November 4, 2015 2:09 PM, Boris Steipe 
 wrote:
   

 I don't understand: 
 - where does the "label" come from? (It's not an element of your data that I 
see.)
 - what do you want to do with this "label" i.e. how does it need to be 
associated with the data?


B.



On Nov 4, 2015, at 7:57 AM, Alaios  wrote:

> Thanks it works great and gives me group numbers as integers and thus I can 
> with which group the elements as needed (which (groups== 2))
> 
> Question though is how to keep also the labels for each group. For example 
> that my first group is the [13,206)
> 
> Regards
> Alex
> 
> 
> 
> On Wednesday, November 4, 2015 1:00 PM, Boris Steipe 
>  wrote:
> 
> 
> I would transform the original numbers into integers which you can use as 
> group labels. The row numbers of the group labels are the indexes of your 
> values.
> 
> Example: assume your input vector is dBin
> 
> nGroups <- 5  # number of groups
> groups <- (dBin - min(dBin)) / (max(dBin) - min(dBin)) # rescale to the range 
> [0,1]
> groups <- floor(groups * nGroups) + 1  # discretize to nGroups integers
> 
> Now you can eg. get the indices for group 2
> 
> groups[groups == 2]
> 
> Depending on the nature of your input data, it may be better to keep these 
> groups in a column adjacent to your values, rather than in a separate vector, 
> or even better to just calculate the groups on the fly in your downstream 
> analysis with the approach given above in a function, rather than storing 
> them at all. These are simple operations that should not add perceptibly to 
> execution time.
> 
> Cheers,
> Boris
> 
> 
> 
> 
> 
> 
> On Nov 4, 2015, at 6:40 AM, Alaios via R-help  wrote:
> 
> > Thanks for the answer. Split does not give me the indexes though but only 
> > in which group they fall in. I also need the index of the group. Is the 
> > first, the second .. group?Alex
> > 
> > 
> > 
> >    On Tuesday, November 3, 2015 5:05 PM, Ista Zahn  
> >wrote:
> > 
> > 
> > Probably
> > 
> > split(binDistance, test).
> > 
> > Best,
> > Ista
> > 
> > On Tue, Nov 3, 2015 at 10:47 AM, Alaios via R-help  
> > wrote:
> >> Dear all,I am not exactly sure on what is the proper name of what I am 
> >> trying to do.
> >> I have a vector that looks like
> >>  binDistance
> >>            [,1]
> >>  [1,] 238.95162
> >>  [2,] 143.08590
> >>  [3,]  88.50923
> >>  [4,] 177.67884
> >>  [5,] 277.54116
> >>  [6,] 342.94689
> >>  [7,] 241.60905
> >>  [8,] 177.81969
> >>  [9,] 211.25559
> >> [10,] 279.72702
> >> [11,] 381.95738
> >> [12,] 483.76363
> >> [13,] 480.98841
> >> [14,] 369.75241
> >> [15,] 267.73650
> >> [16,] 138.55959
> >> [17,] 137.93181
> >> [18,] 184.75200
> >> [19,] 254.64359
> >> [20,] 328.87785
> >> [21,] 273.15577
> >> [22,] 252.52830
> >> [23,] 252.52830
> >> [24,] 252.52830
> >> [25,] 262.20084
> >> [26,] 314.93064
> >> [27,] 366.02996
> >> [28,] 442.77467
> >> [29,] 521.20323
> >> [30,] 465.33071
> >> [31,] 366.60582
> >> [32,]  13.69540
> >> so numbers that start from 13 and go up to maximum 522 (I have also many 
> >> other similar sets).I want to put these numbers into 5 categories and thus 
> >> I have tried cut
> >> 
> >> 
> >> Browse[2]> 
> >> test<-cut(binDistance,seq(min(binDistance)-0.1,max(binDistance),length.out=scaleLength+1))
> >> Browse[2]> test
> >>  [1] (217,318]  (115,217]  (13.7,115] (115,217]  (217,318]  (318,420]
> >>  [7] (217,318]  (115,217]  (115,217]  (217,318]  (318,420]  (420,521]
> >> [13] (420,521]  (318,420]  (217,318]  (115,217]  (115,217]  (115,217]
> >> [19] (217,318]  (318,420]  (217,318]  (217,318]  (217,318]  (217,318]
> >> [25] (217,318]  (217,318]  (318,420]  (420,521]  (420,521]  (420,521]
> >> [31] (318,420]  (13.7,115]
> >> Levels: (13.7,115] (115,217] (217,318] (318,420] (420,521]
> >> 
> >> 
> >> I want then for the numbers of my initial vector that fall within the same 
> >> "category" lets say the (318,420] to be collected on a

Re: [R] merging-binning data

2015-11-04 Thread Alaios via R-help
Thanks for your comments. Actually only the last group has a single element. 
The first group is always "full" of members and as that it works fine. Some 
constant spacing between the groups would be good as well and thus I will check 
quantiles.
Thanks for the great support and time invested on thisRegardsAlex



 On Wednesday, November 4, 2015 3:34 PM, Boris Steipe 
 wrote:
   

 Whatever approach is "best" to define subsets depends completely on the 
semantics of the data. Your approach (a fixed number of equally spaced breaks) 
is the right one if the absolute ranges of the data is important. It should be 
obvious that either the top or the bottom group could contain only a single 
element, and also that any or all of the intermediate groups could be empty. 

If you want to control the number of elements in your groups, use quantiles 
instead. 

Your application may require to define the breaks in other ways. The code I 
have given you doesn't generalize well, as it depends on the equal spacing of 
breaks. As I mentioned earlier, I would not store the groups at all - but would 
define a function that returns a vector of elements in the group, and in the 
function body I would clearly and explicitly define the conditions for group 
membership (and comment it). That is how you make code for a task like this 
explicit and _maintainable_.


Cheers,
Boris


On Nov 4, 2015, at 9:19 AM, Alaios  wrote:

> Thanks everything is solved and I was even able to plot boxplots as needed.
> The only minor is that the max element falls in the last category and is only 
> the single one element. Perhaps this can be from the way my data look like.
> Retgards
> Alex
> 
> 
> 
> On Wednesday, November 4, 2015 3:06 PM, Boris Steipe 
>  wrote:
> 
> 
> The breaks are just the min() and max() in your groups. Something like
> 
>  sprintf("[%5.2f,%5.2f]", min(dBin[groups==2]), max(dBin[groups==2]))
> 
> ... should achieve what you need.
> 
> 
> B.
> 
> 
> 
> On Nov 4, 2015, at 8:45 AM, Alaios  wrote:
> 
> > you are right.
> > by labels I mean the "categories", "breaks" that my data fall in.
> > To be part of group 2 for example you have to be in the range of [110,223) 
> > I need to keep those for my plots.
> > 
> > Did I describe it more precisely now?
> > Alex
> > 
> > 
> > 
> > On Wednesday, November 4, 2015 2:09 PM, Boris Steipe 
> >  wrote:
> > 
> > 
> > I don't understand: 
> > - where does the "label" come from? (It's not an element of your data that 
> > I see.)
> > - what do you want to do with this "label" i.e. how does it need to be 
> > associated with the data?
> > 
> > 
> > B.
> > 
> > 
> > 
> > On Nov 4, 2015, at 7:57 AM, Alaios  wrote:
> > 
> > > Thanks it works great and gives me group numbers as integers and thus I 
> > > can with which group the elements as needed (which (groups== 2))
> > > 
> > > Question though is how to keep also the labels for each group. For 
> > > example that my first group is the [13,206)
> > > 
> > > Regards
> > > Alex
> > > 
> > > 
> > > 
> > > On Wednesday, November 4, 2015 1:00 PM, Boris Steipe 
> > >  wrote:
> > > 
> > > 
> > > I would transform the original numbers into integers which you can use as 
> > > group labels. The row numbers of the group labels are the indexes of your 
> > > values.
> > > 
> > > Example: assume your input vector is dBin
> > > 
> > > nGroups <- 5  # number of groups
> > > groups <- (dBin - min(dBin)) / (max(dBin) - min(dBin)) # rescale to the 
> > > range [0,1]
> > > groups <- floor(groups * nGroups) + 1  # discretize to nGroups integers
> > > 
> > > Now you can eg. get the indices for group 2
> > > 
> > > groups[groups == 2]
> > > 
> > > Depending on the nature of your input data, it may be better to keep 
> > > these groups in a column adjacent to your values, rather than in a 
> > > separate vector, or even better to just calculate the groups on the fly 
> > > in your downstream analysis with the approach given above in a function, 
> > > rather than storing them at all. These are simple operations that should 
> > > not add perceptibly to execution time.
> > > 
> > > Cheers,
> > > Boris
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > On Nov 4, 2015, at 6:40 AM, Alaios via R-help  
> > > wrote:
> > &g

Re: [R] [FORGED] Re: merging-binning data

2015-11-05 Thread Alaios via R-help
Thanks.That is what I want. It is more that I do not know how to read factors 
that these two functions return
Browse[1]> y
$`13.6954016405008`
[1] (13.2,115]
Levels: (13.2,115] (115,217] (217,318] (318,420] (420,522]

$`88.5092280867206`
[1] (13.2,115]
Levels: (13.2,115] (115,217] (217,318] (318,420] (420,522]

$`137.931810364616`
[1] (115,217]
Levels: (13.2,115] (115,217] (217,318] (318,420] (420,522]

 str(y)
List of 30
 $ 13.6954016405008: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 1
 $ 88.5092280867206: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 1
 $ 137.931810364616: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 2
 $ 138.559590072838: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 2
 $ 143.085897171535: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 2
 $ 177.678839068735: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 2
 $ 177.819693807561: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 2
 $ 184.752000138622: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 2
 $ 211.255591076421: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 2
 $ 238.951618624679: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 3
 $ 241.609050762905: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 3
 $ 252.528297510773: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 3 3 3
 $ 254.643586371518: Factor w/ 5 levels "(13.2,115]","(115,217]",..: 3

I need to be able to keep the items within their groups and at the same time to 
keep the label of the group so to be able to use it for plotting purposes.
How I can do that?RegardsAlex
 


 On Wednesday, November 4, 2015 11:20 PM, Rolf Turner 
 wrote:
   

 
I have been vaguely following this thread and have become very confused 
given the complications that seem to have appeared.

The original question was:

>>>>> On Tue, Nov 3, 2015 at 10:47 AM, Alaios via R-help  
>>>>> wrote:
>>>>>> Dear all,I am not exactly sure on what is the proper name of what I am 
>>>>>> trying to do.
>>>>>> I have a vector that looks like

Actually you appear to have a 32 x 1 *matrix* (NOT the same thing!) that 
looks like:

>>>>>>    binDistance
>>>>>>              [,1]
>>>>>>    [1,] 238.95162
>>>>>>    [2,] 143.08590
>>>>>>    [3,]  88.50923
>>>>>>    [4,] 177.67884
>>>>>>    [5,] 277.54116
>>>>>>    [6,] 342.94689
>>>>>>    [7,] 241.60905
>>>>>>    [8,] 177.81969
>>>>>>    [9,] 211.25559
>>>>>> [10,] 279.72702
>>>>>> [11,] 381.95738
>>>>>> [12,] 483.76363
>>>>>> [13,] 480.98841
>>>>>> [14,] 369.75241
>>>>>> [15,] 267.73650
>>>>>> [16,] 138.55959
>>>>>> [17,] 137.93181
>>>>>> [18,] 184.75200
>>>>>> [19,] 254.64359
>>>>>> [20,] 328.87785
>>>>>> [21,] 273.15577
>>>>>> [22,] 252.52830
>>>>>> [23,] 252.52830
>>>>>> [24,] 252.52830
>>>>>> [25,] 262.20084
>>>>>> [26,] 314.93064
>>>>>> [27,] 366.02996
>>>>>> [28,] 442.77467
>>>>>> [29,] 521.20323
>>>>>> [30,] 465.33071
>>>>>> [31,] 366.60582
>>>>>> [32,]  13.69540

A later addendum to the question indicated that the OP wanted labels for 
the result consisting of the endpoints of the intervals into which the 
data were subdivided.  Unless I am misunderstanding, this is trivial to 
accomplish using cut() and split():

x <- c(238.95162, 143.0859, 88.50923, 177.67884, 277.54116, 342.94689,
241.60905, 177.81969, 211.25559, 279.72702, 381.95738, 483.76363,
480.98841, 369.75241, 267.7365, 138.55959, 137.93181, 184.752,
254.64359, 328.87785, 273.15577, 252.5283, 252.5283, 252.5283,
262.20084, 314.93064, 366.02996, 442.77467, 521.20323, 465.33071,
366.60582, 13.6954)

f <- cut(x,5)

y <- split(x,f)

y

$`(13.2,115]`
[1] 88.50923 13.69540

$`(115,217]`
[1] 143.0859 177.6788 177.8197 211.2556 138.5596 137.9318 184.7520

$`(217,318]`
  [1] 238.9516 277.5412 241.6090 279.7270 267.7365 254.6436 273.1558 
252.5283
  [9] 252.5283 252.5283 262.2008 314.9306

$`(318,420]`
[1] 342.9469 381.9574 369.7524 328.8779 366.0300 366.6058

$`(420,522]`
[1] 483.7636 480.9884 442.7747 521.2032 465.3307


Is this not the result that you want?  If not, what *is* the result that 
you want?

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] improve my ggplot look

2015-11-19 Thread Alaios via R-help
Dear all,the following line of code
print me a map of an area with the points I need. I only new two minor 
adjustments
    ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, colour =Error), 
data = PlotPoints, size = 6)+ 
scale_colour_gradient2(low=muted("red"),mid="green", high=muted("blue"),trans = 
"log")+geom_point(aes(Longitude,Latitude),data=stationaryPoint,colour="Red",shape="s",size=12)
 

I want to specify my color ramp to have the specific scale 
0,10,040,130,4

I also want to plot in a way where the fonts will be binger and the legends as 
well.Any ideas how I can do that?
I would like to thank you for your reply
RegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] improve my ggplot look

2015-11-24 Thread Alaios via R-help
Dear Dennis, it would be better if not plotting the lon and lat. Keeping it 
blank is better for the aesthetics of my map.
I am not sure how I can give a reproducible example herebut I want to  
   ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, 
colour=Divergence), data = PlotPoints, size =10)+
 scale_colour_gradient2(low=muted("red"),mid="green", high=muted("blue"),trans 
="log")+geom_point(aes(Longitude,Latitude),size=15,data=stationaryPoint,colour="Red",shape="X",size=15)
 log10(seq(1,20,length.out=100))
to make the color scale with fixed colors (0.3 for green for example) and 
increase it in size so the numbers in the bar are still visible when the figure 
is getting smaller in size
RegardsAlex

On Friday, November 20, 2015 11:02 PM, Dennis Murphy  
wrote:
 

 Hi Alex:

The documentation for ggmap tells you that its x-y coordinates are
lat-long. What did you want to plot instead?

There are several theme options for legends, as well as a few more in
the guide_legend() function. As far as the color scale, you should be
able to set it with hex codes in each map.

Since there is no reproducible example with which to work, I can't
really help/comment much further. If you come up with one, please post
it back to the group so that others can see it. Some of them have more
experience with mapping in ggplot2 than I do.

Dennis

On Thu, Nov 19, 2015 at 8:45 PM, Alaios  wrote:
> dear Dennis,
> thanks for your answers.
> I have changed my code to look like
>
>    ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, colour
> =Divergence), data = PlotPoints, size =10)+
> scale_colour_gradient2(low=muted("red"),mid="green",
> high=muted("blue"),trans =
> "log")+geom_point(aes(Longitude,Latitude),size=15,data=stationaryPoint,colour="Red",shape="X",size=15)#
> log10(seq(1,20,length.out=100))
>
>
> current issues:
> -ggmap : plots the coordinates (longitudes and latitudes like x and y
> labels), which I do not want to do
> -Increase font size in the color bar
> -the color scale as it is now is totally fine, it is more that I want to
> make the colors there fixed, since different maps have slightly different
> numbers printed there (not much but that hinders comparisons between the
> maps).
>
> I would like to thank you for your support
> Regards
> Alex
>
>
>
> On Thursday, November 19, 2015 7:13 PM, Dennis Murphy 
> wrote:
>
>
> Let's try this againsorry for hitting Send inadvertently.
>
> On Thu, Nov 19, 2015 at 5:09 AM, Alaios via R-help 
> wrote:
>> Dear all,the following line of code
>> print me a map of an area with the points I need. I only new two minor
>> adjustments
>>    ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, colour
>> =Error), data = PlotPoints, size = 6)+
>> scale_colour_gradient2(low=muted("red"),mid="green",
>> high=muted("blue"),trans =
>> "log")+geom_point(aes(Longitude,Latitude),data=stationaryPoint,colour="Red",shape="s",size=12)
>>
>> I want to specify my color ramp to have the specific scale
>> 0,10,040,130,4
>
> You can specify the hex codes for colors in any of the scale_colour*()
> functions.
>>
>> I also want to plot in a way where the fonts will be binger and the
>> legends as well.Any ideas how I can do that?
>
> See ?theme.
>
> Dennis
>
>
>
>> I would like to thank you for your reply
>> RegardsAlex
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] improve my ggplot look

2015-11-24 Thread Alaios via R-help
I am giving to the community two examples
My code currently look like:
breaks<-c(0,0.01,0.05,0.08,0.1,0.15,0.2,0.3,0.5,0.7,0.9,1)
ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, colour 
=Divergence), data = PlotPoints, size =10)+ 
scale_colour_gradientn(colours=rainbow(9),breaks=breaks)+
geom_point(aes(Longitude,Latitude),size=15,data=stationaryPoint,colour="Red",shape="X",size=15)
where I added the gradientn in attempt to specify specific limits with a 
specific color for a a given range.
I am attaching two examples where you would seethat the values on the colorramp 
are not the same. In the first case is the 0.20 that gets the purple number and 
in the second case the 1 (the latter is not printed in the color ramp)
Can someone explain me in what small change Ineed here?
I would like to thank you for your replyRegardsAlex
 


On Tuesday, November 24, 2015 12:43 PM, Alaios via R-help 
 wrote:
 

 Dear Dennis, it would be better if not plotting the lon and lat. Keeping it 
blank is better for the aesthetics of my map.
I am not sure how I can give a reproducible example herebut I want to  
   ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, 
colour=Divergence), data = PlotPoints, size =10)+
 scale_colour_gradient2(low=muted("red"),mid="green", high=muted("blue"),trans 
="log")+geom_point(aes(Longitude,Latitude),size=15,data=stationaryPoint,colour="Red",shape="X",size=15)
 log10(seq(1,20,length.out=100))
to make the color scale with fixed colors (0.3 for green for example) and 
increase it in size so the numbers in the bar are still visible when the figure 
is getting smaller in size
RegardsAlex

    On Friday, November 20, 2015 11:02 PM, Dennis Murphy  
wrote:
 

 Hi Alex:

The documentation for ggmap tells you that its x-y coordinates are
lat-long. What did you want to plot instead?

There are several theme options for legends, as well as a few more in
the guide_legend() function. As far as the color scale, you should be
able to set it with hex codes in each map.

Since there is no reproducible example with which to work, I can't
really help/comment much further. If you come up with one, please post
it back to the group so that others can see it. Some of them have more
experience with mapping in ggplot2 than I do.

Dennis

On Thu, Nov 19, 2015 at 8:45 PM, Alaios  wrote:
> dear Dennis,
> thanks for your answers.
> I have changed my code to look like
>
>    ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, colour
> =Divergence), data = PlotPoints, size =10)+
> scale_colour_gradient2(low=muted("red"),mid="green",
> high=muted("blue"),trans =
> "log")+geom_point(aes(Longitude,Latitude),size=15,data=stationaryPoint,colour="Red",shape="X",size=15)#
> log10(seq(1,20,length.out=100))
>
>
> current issues:
> -ggmap : plots the coordinates (longitudes and latitudes like x and y
> labels), which I do not want to do
> -Increase font size in the color bar
> -the color scale as it is now is totally fine, it is more that I want to
> make the colors there fixed, since different maps have slightly different
> numbers printed there (not much but that hinders comparisons between the
> maps).
>
> I would like to thank you for your support
> Regards
> Alex
>
>
>
> On Thursday, November 19, 2015 7:13 PM, Dennis Murphy 
> wrote:
>
>
> Let's try this againsorry for hitting Send inadvertently.
>
> On Thu, Nov 19, 2015 at 5:09 AM, Alaios via R-help 
> wrote:
>> Dear all,the following line of code
>> print me a map of an area with the points I need. I only new two minor
>> adjustments
>>    ggmap(mp, darken = 0) + geom_point(aes(Longitude, Latitude, colour
>> =Error), data = PlotPoints, size = 6)+
>> scale_colour_gradient2(low=muted("red"),mid="green",
>> high=muted("blue"),trans =
>> "log")+geom_point(aes(Longitude,Latitude),data=stationaryPoint,colour="Red",shape="s",size=12)
>>
>> I want to specify my color ramp to have the specific scale
>> 0,10,040,130,4
>
> You can specify the hex codes for colors in any of the scale_colour*()
> functions.
>>
>> I also want to plot in a way where the fonts will be binger and the
>> legends as well.Any ideas how I can do that?
>
> See ?theme.
>
> Dennis
>
>
>
>> I would like to thank you for your reply
>> RegardsAlex
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do

[R] getting values from php or javascript

2016-01-22 Thread Alaios via R-help
Dear all,I would like to execute some php or javascripts I found on the web.

see at middle of this page towards bottom
http://www.howtocreate.co.uk/php/gridref.php#samples

Is there any way I can call the php function for example directly from R?
I would like to thank you in advance for your replyRegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] find numbers that fall in a region or the next available.

2016-02-02 Thread Alaios via R-help
Dear all,I have GPS coordinates (one vector for longitude and one for latitude: 
GPSLong and GPSLat) of small are that is around 300meters X 300 meters 
(location falls inside UK).At the same time I have two more vectors (Longitude 
and Latitude) that include position of food stores again the UK
I would like to find within my 300x300 square area which as the food stores 
that fall inside.I thought to try to find which of the Longitude of the food 
stores fall inside my area. I tried something the below

Longitude[Longitude>(min(GPSLong)-0.001)&&Longitude<(max(GPSLong)+0.001)]
but this returned me zero results.The next option would be the code to return 
me at least the place that falls outside but still is close to that region.'Do 
you have any idea how to do that and not fall back in the time consuming look 
at each element iteration?
I would like to thank you for your replyRegardsAlex



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] [FORGED] find numbers that fall in a region or the next available.

2016-02-03 Thread Alaios via R-help
Thanks. I am using distm of the geoshere package.I still wonder if there is a 
package that can tell me if a gps coordinate or not falls inside my area that 
is defined as:
bbox <- c(min(PlotPoints[, 1])-0.001, min(PlotPoints[, 2])-0.001, 
max(PlotPoints[, 1])+0.001, max(PlotPoints[, 2])+0.001)

PlotPoints are gps coordinates.
That would make it sure that I have no mistakes in my code.
Any ideas?Alex 

On Tuesday, February 2, 2016 11:33 PM, Rolf Turner 
 wrote:
 

 On 03/02/16 11:04, Alaios via R-help wrote:
> Dear all,I have GPS coordinates (one vector for longitude and one for
> latitude: GPSLong and GPSLat) of small are that is around 300meters X
> 300 meters (location falls inside UK).At the same time I have two
> more vectors (Longitude and Latitude) that include position of food
> stores again the UK I would like to find within my 300x300 square
> area which as the food stores that fall inside.I thought to try to
> find which of the Longitude of the food stores fall inside my area. I
> tried something the below
>
> Longitude[Longitude>(min(GPSLong)-0.001)&&Longitude<(max(GPSLong)+0.001)]
> but this returned me zero results.The next option would be the code
> to return me at least the place that falls outside but still is close
> to that region.'Do you have any idea how to do that and not fall back
> in the time consuming look at each element iteration?
> I would like to thank you for your reply


You could make use of the distfun() function from the spatstat package. 
  Represent your "small area" as an object of class "owin".  The 
longitude and latitude coordinates will be treated as if they were 
Euclidean coordinates, but over distances of the order of 300 metres 
this should not matter much.  You could of course convert your long and 
lat coordinates to metres, using some appropriate projection, which 
might make more sense in your context.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] [FORGED] find numbers that fall in a region or the next available.

2016-02-03 Thread Alaios via R-help
That is a great tip thanks.That would indeed bring me points that are the 
closes to my area.. but if I am not wront that returns points that are part of 
a circle surface. It might be that I get a point that is just 50 meters outside 
of my map area. Is not that true? I would need after I find closest point to 
confirm which ones fall inside my map region.
Alex
 

On Wednesday, February 3, 2016 8:36 PM, David L Carlson  
wrote:
 

 Look at the point.in.polygon() and over() functions in package sp.

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios via 
R-help
Sent: Wednesday, February 3, 2016 2:42 AM
To: Rolf Turner; R-help Mailing List
Subject: Re: [R] [FORGED] find numbers that fall in a region or the next 
available.

Thanks. I am using distm of the geoshere package.I still wonder if there is a 
package that can tell me if a gps coordinate or not fal

ls inside my area that is defined as:
bbox <- c(min(PlotPoints[, 1])-0.001, min(PlotPoints[, 2])-0.001, 
max(PlotPoints[, 1])+0.001, max(PlotPoints[, 2])+0.001)

PlotPoints are gps coordinates.
That would make it sure that I have no mistakes in my code.
Any ideas?Alex 

    On Tuesday, February 2, 2016 11:33 PM, Rolf Turner 
 wrote:


 On 03/02/16 11:04, Alaios via R-help wrote:
> Dear all,I have GPS coordinates (one vector for longitude and one for
> latitude: GPSLong and GPSLat) of small are that is around 300meters X
> 300 meters (location falls inside UK).At the same time I have two
> more vectors (Longitude and Latitude) that include position of food
> stores again the UK I would like to find within my 300x300 square
> area which as the food stores that fall inside.I thought to try to
> find which of the Longitude of the food stores fall inside my area. I
> tried something the below
>
> Longitude[Longitude>(min(GPSLong)-0.001)&&Longitude<(max(GPSLong)+0.001)]
> but this returned me zero results.The next option would be the code
> to return me at least the place that falls outside but still is close
> to that region.'Do you have any idea how to do that and not fall back
> in the time consuming look at each element iteration?
> I would like to thank you for your reply


You could make use of the distfun() function from the spatstat package. 
  Represent your "small area" as an object of class "owin".  The
longitude and latitude coordinates will be treated as if they were 
Euclidean coordinates, but over distances of the order of 300 metres 
this should not matter much.  You could of course convert your long and 
lat coordinates to metres, using some appropriate projection, which 
might make more sense in your context.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


  
    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Data structure to hold the following

2016-02-15 Thread Alaios via R-help
Dear all,I am using R to emulate radio propagation dynamics.
I have 90 antennas in a region and each of these 90 antennas hold information 
about 36 points (these are all exactly the same and there is no need to 
differentiate them further)
Each of these antennas now should keep information about the distances from the 
36 points (each of the 90 antennas have a different distance for each of the 
unique 36 points), which gives use in total 90 times a 36 elements vector.
Each antenna should also keep a [36,600] matrix (each matrix describes in 
details the relation between one of the 90 antennas and one of the 36 points 
and 600 elements are needed for doing that). In total that mines 90 times 
[36,600] matrices

What is an appropriate data structure for doing that in R ? I am giving fixed 
numbers here but in reality the 90,36 and 600 are just examples. Variable 
should be used here and thus we do not talk about fixed data structures before 
hand. 

I would like to thank you for your replyRegardsAlex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Data structure to hold the following

2016-02-15 Thread Alaios via R-help
The tables and vectors storing the data will be used for accessing the data 
(sequentially is also fine) to do calculations as needed.
RegardsAlex 

On Monday, February 15, 2016 7:17 PM, Bert Gunter  
wrote:
 

 I would say that it depends on what you want to do with the data.
Bert


On Monday, February 15, 2016, Alaios via R-help  wrote:

Dear all,I am using R to emulate radio propagation dynamics.
I have 90 antennas in a region and each of these 90 antennas hold information 
about 36 points (these are all exactly the same and there is no need to 
differentiate them further)
Each of these antennas now should keep information about the distances from the 
36 points (each of the 90 antennas have a different distance for each of the 
unique 36 points), which gives use in total 90 times a 36 elements vector.
Each antenna should also keep a [36,600] matrix (each matrix describes in 
details the relation between one of the 90 antennas and one of the 36 points 
and 600 elements are needed for doing that). In total that mines 90 times 
[36,600] matrices

What is an appropriate data structure for doing that in R ? I am giving fixed 
numbers here but in reality the 90,36 and 600 are just examples. Variable 
should be used here and thus we do not talk about fixed data structures before 
hand.

I would like to thank you for your replyRegardsAlex


        [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



-- 
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 )



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] greek characters in Figures

2016-05-02 Thread Alaios via R-help
Dear all,I am trying to write in my Figure labels short equations that contain 
greek characters

For example:  C(h) = sigma^2 * rho(h).   

I am googling it and there are many packages available but unfortunately they 
do not look available for my 3.2.4 latex version

install.packages("latex2expr")Installiere Paket nach 
‘/home/apa/R/x86_64-pc-linux-gnu-library/3.2’(da ‘lib’ nicht 
spezifiziert)Warnung: kann nicht auf den Index für das Repository 
https://cran.cnr.Berkeley.edu/src/contrib zugreifen:  nicht unterstütztes URL 
SchemaWarnmeldung:Paket ‘latex2expr’ ist nicht verfügbar (for R version 3.2.4 
Revised) 

Any ideas what else I can try?I would like to thank you in advance for your 
replyRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] greek characters in Figures

2016-05-04 Thread Alaios via R-help
> install.packages("latex2exp")Installiere Paket nach 
> ‘/home/apa/R/x86_64-pc-linux-gnu-library/3.2’(da ‘lib’ nicht 
> spezifiziert)Warnung: kann nicht auf den Index für das Repository 
> https://cran.cnr.Berkeley.edu/src/contrib zugreifen:  nicht unterstütztes URL 
> SchemaWarnmeldung:Paket ‘latex2exp’ ist nicht verfügbar (for R version 3.2.4 
> Revised) > install.packages("latex2expr")Installiere Paket nach 
> ‘/home/apa/R/x86_64-pc-linux-gnu-library/3.2’(da ‘lib’ nicht 
> spezifiziert)Warnung: kann nicht auf den Index für das Repository 
> https://cran.cnr.Berkeley.edu/src/contrib zugreifen:  nicht unterstütztes URL 
> SchemaWarnmeldung:Paket ‘latex2expr’ ist nicht verfügbar (for R version 3.2.4 
> Revised) 
 

On Monday, May 2, 2016 9:39 PM, David Winsemius  
wrote:
 

 
> On May 2, 2016, at 10:32 AM, Alaios via R-help  wrote:
> 
> Dear all,I am trying to write in my Figure labels short equations that 
> contain greek characters
> 
> For example:  C(h) = sigma^2 * rho(h).  
> 
> I am googling it and there are many packages available but unfortunately they 
> do not look available for my 3.2.4 latex version
> 
> install.packages("latex2expr")

My efforts found a 'latex2exp' but no 'latex2expr'. Are you sure you are not 
missplelling the package name?


> Installiere Paket nach ‘/home/apa/R/x86_64-pc-linux-gnu-library/3.2’(da ‘lib’ 
> nicht spezifiziert)Warnung: kann nicht auf den Index für das Repository 
> https://cran.cnr.Berkeley.edu/src/contrib zugreifen:  nicht unterstütztes URL 
> SchemaWarnmeldung:Paket ‘latex2expr’ ist nicht verfügbar (for R version 3.2.4 
> Revised) 
> 
> Any ideas what else I can try?I would like to thank you in advance for your 
> replyRegardsAlex
>     [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] moran's I visualization example

2016-05-05 Thread Alaios via R-help
Hi there,in case one has found a nice and easy reproducible example of a 
Morans'I example where neighborhoods are depicted and their calculated 
correlations are visible as well.Point is to make some examples that I can 
share with students that want to understand fast what is the notion about.
RegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] How these Plots are called? Which package

2017-01-14 Thread Alaios via R-help
Hello,how I can try something like that in R (in the attachment I am providing 
a sketch).Which packages would you try to use?I would like to thank you in 
advance for your helpRegardsAlex
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] How these Plots are called? Which package

2017-01-14 Thread Alaios via R-help
can you see it now? I have uploaded it on my dropbox
https://www.dropbox.com/s/9eikpabu6xflasa/Figure.jpg?dl=0
 

On Saturday, January 14, 2017 12:57 PM, John Kane  
wrote:
 

 No sign of attachment. 
 

On Saturday, January 14, 2017 5:42 AM, Alaios via R-help 
 wrote:
 

 Hello,how I can try something like that in R (in the attachment I am providing 
a sketch).Which packages would you try to use?I would like to thank you in 
advance for your helpRegardsAlex
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.