How to symbolize groups separately in a graph (R) - r

I have a small data set consisting of two columns of data and a column designating which of the two sites the data was taken at. I have used xyplot to sort by groups, but I can't figure out how to alter the symbology of each group separately. I also need to add a regression line, and can only figure out how to do that in plot. What graphics package can give me these features in the same graph?
I have looked into different graphics packages to find one in which I can do everything I need, but I am new to R and am not having much luck.

ggplot2 is your go-to.
Try this:
install.packages('ggplot2')
library(ggplot2)
one=c("A","B","A","B")
two=c(1,2,3,4)
three=c(5,7,8,20)
df<-data.frame(one,two,three)
ggplot(df,aes(x=two,y=three,col=one))+geom_line()

Related

Splitting plot pane for different plotting shemes in R

I have a technical question therefore I am not producing a code here.I have two plots. One was created using base R and the other one was created with sp package. I want to see those packages splitted into two in a row to make comparisons.
So what should I do? All the functions that I know so far like "par" and "layout" are for designing plotting pane in base R.
Should I convert one plot into base R too? or vice versa
Note: Both plots are maps one is a thematic map like using color fill of a variable in a map. The other one is also a map using a color scheme for quantitative breaks.

Setting multiple graphs to a same base

I would like to compare the graphs, but my data seem to be not collebrated. How do I get them to the same base? That is I want them all to be "grounded" at the same level.
Example

Cross-Recurrence plots in R (with or without ggplot)

I have different time-series corresponding to different individuals and their location within a building (a categorical variable -- more like a room name).
I would like to study the similarity in movement of different individuals by something like cross-recurrence plots, where the two time-series correspond to the two axes and the actual points correspond to the presence/absence of individuals in the same room.
Has anyone tried doing such plots in R or while using ggplot? Any help would be great!
I haven't used this routine. I used only d2 dimension and Lyapunov exponent for EEG but this package Tisean (RTisean for your case) has a routine ['recurr'] that returns the specific plot.
This link has a nice wrap up of tutorials and links
Edited:
In this link you can find a nice example of application of recurrence plot.
The return variables of function recur(and similar functions of other packages) you can access after putting $ after the dataset (like database)
and you can access them inside in ggplot function and applying the appropriate aes.

R: getting data (instead of plot) back from sm.density.compare

I'm doing a density compare in R using the sm package (sm.density.compare). Is there anyway I can get a mathematical description of the graph or at least a table with number of points rather than a plot back? I would like to plot the resulting graphs in a different application, but need the data to do so.
Thanks a lot for the help,
culicidae

R - Adding series to multiple plots

I have the following plot:
plot.ts(returns)
I have another dataframe ma_sd which contains the rolling SD from moving averages of the above returns. The df is structured exactly like returns. Is there a simple way to add each line to the corresponding plots?
lines(1:N, ma_sd) seemed intuitive, but it does not work.
Thanks
The only way I can see you doing this is to plot them separately. This code is a bit clunky but will allow you full flexibility to be able to specify labels and axis ranges. You can build on this.
par(mfrow=c(3,1),oma=c(5,4,4,2),mar=c(0,0,0,0))
time<-as.data.frame(matrix(c(1:length(returns[,1])),length(returns[,1]),3))
plot(time[,1],returns[,1],type='l',xaxt='n')
points(time[,1],ma_sd[,1],type='l',col='red')
plot(time[,2],returns[,2],type='l',xaxt='n')
points(time[,2],ma_sd[,2],type='l',col='red')
plot(time[,3],returns[,3],type='l')
points(time[,3],ma_sd[,3],type='l',col='red')

Resources