Create circular bins using x and y- coordinates - r

I am trying to split my data frame into circular bins from a specific point (center of the plot) using 2 variables (x and y coordinates). The aim is to bin the data into 5 different circles starting from a point (2255, 2008) where the total matrix is (5599X4000). Can someone help me do that using R?

Related

What type of R graph can I use to display frequency on the x axis and length on y?

I have a dataset of length values for plants sampled in a number of specific square areas
eg., not actual data - just a representation
I want to create a graph in R that has the number of plants per plot (per area squared) on the x axis and the average length on the y axis - effectively exploring the effect of density per plot on length as pictured below.
Just wondering what the best function/package would be to do this in
Thanks

Making binned polar plots

Python newbie here
I have 3 sets of 1x130677 data, theta (0 to 360), R (0 to 30) and C. I want to create a polar plot that is binned in 5 degrees of theta increments and and 1 unit length of R. The C values are C(theta,R) [-not a function], first data in theta and R correspond to the first data in C. Each bin should contain multiple C values and average them and then the whole plot will be color coded. This is a close example:Polar histogram in Python for given r, theta and z values
Any help making this plot is greatly appreciated!
thank you

How to combine multiple 2D R plots into a single 3D plot

I am trying to stack multiple 2d plots into a single 3d plot in R.
For example, I want to try and put these plots
into a single 3d image. The z axis would be the biomass density, y axis be the size and the x axis be the time step (and then hopefully I could use a surface plot to join up all the lines). My aim is to try and show the wave travelling through the size over a long period of time instead of showing lots of images.
Does anyone know how to do this?

how to set the ranges of coordinates X & Y for observation window geometry in spatstat package in R

Hi? I have a data of seedlings distribution which contains species types, X and Y coordinates in UTM. I want to create a point pattern by their X & Y coordinate location with the help of ppp() function in spatstat package. I tried it with following 2 ways:
p.patt <- ppp(mydata$X, mydata$Y)
p.patt <- ppp(mydata$X, mydata$Y, owin(c(100,131), c(100,130)))
But there is a “Warning message: 435 points were rejected as lying outside the specified window” for both of them.
I guess this is related to ranges of X and Y coordinates that should be specified in this code in c(…), c(…). I checked the range of X &Y and R gave me following ranges:
for X: 368615 and 368746,
for Y: 4587355 and 4587485
When I plot the data, a shape of the plot looks like "tilted rombo". I don't know if it is help.
Here I have just randomly chosen tried some numbers: 100 & 131 & 130. I couldn’t find any information how to set them online.
So my question is how I can use these ranges of coordinates to set observation window geometry of point patterm in spatstat package in R?.
Thank you very much in advance!
The numbers in the owin call are not the width and height of the window; they are the X and Y coordinates of the corners of the window.
Since the range of X coordinate values of the data points is from 368615 to 368746, the window needs to contain this range, at least. Similarly the range of Y values must be contained in the window. The minimal window that will not give a warning is
p.patt <- ppp(mydata$X, mydata$Y, owin(c(368615,368746), c(4587355,4587485)))
or equivalently
p.patt <- ppp(mydata$X, mydata$Y, c(368615,368746), c(4587355,4587485))
But this is just the minimal window that is acceptable; for a proper analysis, you need information about the survey region. If it is not a rectangle then, as Ege says, you need to specify owin(poly=...) using the coordinate locations of the vertices of the polygon.
Don't you have information about the plot? E.g. the coordinates of the corners of a polygonal region delimiting the plot? If you have these coordinates use them as input in the argument poly of owin. See the help file for owin for details. In lack of any information you can try ripras to estimate the boundary of the plot.
What you do right now is to say that you define a point pattern in the rectangle [0,131]×[0,130] and then you provide a bunch of points with coordinates outside this area (much larger coordinate values) and they are all discarded.

Select particular objects/rows from heatmap in R

I have mixed data type that contain numeric and categorical attributes to which I am planning to apply cluster algorithms.
As a first step, I produced a distance matrix using the daisy() function and Gower distance measure. I have displayed the distance matrix using a heatmap and a levelplot function in R.
It seems as if there is strong similarity between some of the objects in my data and I want to check some of the similar/dissimilar objects to satisfy myself that the measure is working well on my data.
How do I select the similar/dissimilar objects from the heatmap and link them to the original data set to be able to evaluate them?
This is how I plot my heatmap using R. IDX is my distance Matrix.
new.palette=colorRampPalette(c("black","yellow","#007FFF","white"),space="rgb")
levelplot(IDX_as[1:ncol(IDX_as),ncol(IDX_as):1],col.regions=new.palette(20))
quartz(width=7,height=6) #make a new quartz window of a given size
par(mar=c(2,3,2,1)) #set the margins of the figures to be smaller than default
layout(matrix(c(1,2),1,2,byrow=TRUE),widths=c(7,1)) #set the layout of the quartz window. This will create two plotting regions, with width ratio of 7 to 1
image(IDX_as[1:ncol(IDX_as),ncol(IDX_as):1],col=new.palette(20),xaxt="n",yaxt="n") #plot a heat map matrix with no tick marks or axis labels
axis(1,at=seq(0,1,length=20),labels=rep("",20)) #draw in tick marks
axis(2,at=seq(0,1,length=20),labels=rep("",20))
#adding a color legend
s=seq(min(IDX_as),max(IDX_as),length=20) #20 values between minimum and maximum values of m
l=matrix(s,ncol=length(s),byrow=TRUE) #coerce it into a horizontal matrix
image(y=s,z=l,col=new.palette(20),ylim=c(min(IDX),max(IDX)),xaxt="n",las=1) #plot a one-column heat map
heatmap(IDX_as,symm=TRUE,col=new.palette(20))

Resources