I'm trying to create an xyplot from the following sample of my dataset: dput(head(trainsamp,25)) structure(list(group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Endurance", "Strength", "Concurrent"), class = "factor"), time...

I'm trying to create a custom LOESS panel function for my plot. Basically what it should do is the same as a simple panel.loess or type = "smooth". The reason is that later on I want to make it a bit more complicated with things that cannot easily achieved with...

I would like to plot a time series (meaning line graph with x axis as time) and specify a plotting character to use. None of the following has worked a1 = as.xts(ts(c(5,3,7,2,4,8,3), start=c(1980,1), freq=4)) library('lattice') xyplot(a1, col="red", pch=2) xyplot(a1, col="red", par.settings = list(superpose.symbol = list(col = 1, pch = 2)),)...

I have the following data frame ds <- data.frame(iso2c=as.factor(c(rep("AR",3),rep("BR",3),rep("DE",3),rep("US",3))), region= as.factor(c(rep("LATAM",6),rep("DEVELOPED",6))), year= rep(c(1979,1989,1999),4), value= c( 47.0 , 28.6, 20.8, 100.0, 64.2, 35.4, 16.0 , 9.0, 5.5, 15.6, 11.6, 8.6)) ) and would like to plot the data in a dotplot, as follows, library(lattice) dotplot(iso2c~value | region, data=ds, groups=year,pch=19,col="dark blue",cex=1.3,ylab="country",,layout=c(1,2)) Problem...

I am creating lattice figures and annotating them with the grid package. To set coordinates for my figures, I use unit() and related functions from the grid package. It often helps to add units together, and this is typically no problem. But I find that a strange problem arises when...

Say I want to create an ordinary xyplot without explicitly specifying axis limits, then how are axis limits calculated? The following line of code produces a simple scatter plot. However, axis limits do not exactly range from 1 to 10, but are slightly expanded to the left and right and...

This question is very much related to the question and answers received here, where @Mr. Flick helped me with a question I had regarding the xyplot in the lattice package. But seeing that I'm now trouble-shooting some code I thought I'd ask to the "broader public" for some help. I've...

I use this kind of function (from iris data set) model_test <- lm(Sepal.Length ~( Petal.Length + Sepal.Width + Petal.Width +Species)^2, data=iris) gg<-expand.grid(Petal.Length=0:6,Species=levels(Species)) vv<-expand.grid(Sepal.Width=0:4,Petal.Width=1:4) pd<-do.call(rbind,Map(function(Petal.Length,Species,Sepal.Width,Petal.Width){ nd <- cbind(vv, Petal.Length=Petal.Length,Species=Species, Sepal.Width=Sepal.Width, Petal.Width=Petal.Width) cbind(nd, pred=predict(model_test, nd, type="response"))},...

Say we have some data like this: dta <- data.frame( group = rep(letters[1:8], each=1000), x = runif(8000), y=runif(8000) ) I would like to produce a Lattice plot containing y ~ x for each group. But, with groups a-d on the first row, and e-h on the second row. i.e., I...

I've checked quite extensively through the forum and on the web but I couldn't find anyone that already presented my case, so here you are the question: my goal: how can I extend the example presented here in case I have more than one conditioning factor? I've tried several ways...

I have the following data frame ds <- data.frame(iso2c=as.factor(c(rep("AR",3),rep("BR",3),rep("DE",3),rep("US",3))), region= as.factor(c(rep("LATAM",6),rep("DEVELOPED",6))), year= rep(c(1979,1989,1999),4), value= c( 47.0 , 28.6, 20.8, 100.0, 64.2, 35.4, 16.0 , 9.0, 5.5, 15.6, 11.6, 8.6)) ) and would like to plot the data in a dotplot, as follows, library(lattice) dotplot(iso2c~value, data=ds, groups=year,pch=19,col="dark blue",cex=1.3,ylab="country") I would like...

I'm trying to control the color of data points in a custom Lattice function. The idea is the response may be a function of one or two factors. The coloring of the data points should be determined by fac1. Here is the function: compareCats <- function(formula = NULL, data =...

I have a question concerning some graphical options of wireframe. How can I make the xlab and the ylab parallel to the cube - they look horrible in my plots, see for my other post Faceted Lattice Plots in R. i.e. wireframes: How remove stripes and add 1- Line subtitles...

I am struggling with some plots in R. At the moment I am running R version: R version 3.2.0 (2015-04-16) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 7 (build 7601) Service Pack 1 I really hope someone can give me some advise on how to set my x-axis to meet the...

I would need lattice implementation of this example; set.seed(12) df <- data.frame(y=seq(0,1,0.1),x=rnorm(11,1,1)) # use different scale (y covariate) as used for plotting df$Num <- seq(0.5,1,0.05) plot(df$x, yaxt="n") axis(2, df$x[3], df$Num[3]) So how to display different figures as used for the graph. or df$L <- letters[1:nrow(df)] plot(df$x, yaxt="n") axis(2, df$x[3], df$L[3])...

Here is my attempted code. attach(mtcars) levelplot(mpg ~ wt * hp|gear, data = mtcars,labels=FALSE ,scales=list(relation="free")) The result is this plot. I wish to know how to (1) add local z colorbar for each levelplots and (2) how to make each levelplot's title shows as gear 4, gear 3 and gear...

Generated two datasets as below: H<-data.frame(replicate(10,sample(0:20,10,rep=TRUE))) G<-data.frame(replicate(10,sample(0:20,10,rep=TRUE))) H[c(2,3,7,9),9]<-NA G[c(1,5,7,8),9]<-NA H$diff<-H$X10-H$X9 G$diff<-G$X10-G$X9 H$perc<-round((H$diff/H$X10)*100,1) G$perc<-round((G$diff/G$X10)*100,1) Created a plot using: library(lattice) xyplot(X8+X9+X10~X1,H,type=c('p','l','g'), col = c('yellow', 'green', 'blue','red'), ylab='Count',layout=c(3, 1), xlab=paste("H",'difference',min(pmin(H$perc, na.rm =...

Imagine we have this data: dat <- structure(list(variable = c("a1", "a1", "a1", "a1", "a1", "a1", "a2", "a2", "a2", "a2", "a2", "a2", "a3", "a3", "a3", "a3", "a3", "a3", "a4", "a4", "a4", "a4", "a4", "a4"), value = c(9.17804065427195, -0.477515191225569, 0.189943035684685, -6.06095979017212, -10.4173631972868, -6.119330192816, -14.3820530117637, 13.9823789620469, 15.6437973890843, 0.754856919261315, -0.887052526388938, 7.4096244573169, 0.61043977214679, 28.4639357142541, 15.4511442682744,...

I plotted a histogram using Lattice histogram(~Time |factor(Bila), data=flexi2, xlim= c(5, 15), ylim=c(0, 57), scales=list(x=list(at=seq(5,15,1))), xlab="Time", subset=(Bila%in% c(""))) The bins I get do not match the exact hours, whereas I would like the bin to start at the exact hour, for example, 6,7 etc. I use lattice since I want...

Some time ago I solved to put labels as percentages in stacked bar charts created with the likert function from the HH package, that uses lattice. My data was answers to a Likert-type scale with an even number of levels and the code works as I expected. +---+-------------------+-------------------+-------------------+----------------+----------------+----------------+--------------------+ | |...

How can I force wireframe panels to produce single plots instead of one panel plot/grid plot? The reason is that if I have to produce a Sweave/ Pdf File the original wireframe plot, which R produces and which you can see in my other post Faceted Lattice Plots in R....

I have created some stacked bar charts with the likert function from the HH package, that uses lattice. Now I want to add labels represented as percentages inside to each segment of the charts, or, better, only to that segments that have a sufficient width for that. How to do...

I am trying to generate mean values by group for each of numerous variables (species) and then plot each of these separately. I have tried list and data table formats. The base plot function works in a for loop: library(data.table) for (i in 3:5) { # generate a list of...

I'm working to produce a facet/lattice plot of choropleth maps that each show a how different model runs affect one variable being mapped across a number of polygons. The problem is that the output graphic produces strange lines that run between the polygons in each plot (see the graphic below)....

I'm trying to create a figure in R with the lattice package. The code I've written up to now is below: myColours <- brewer.pal(12,"Set3") my.settings <- list(superpose.symbol=list(col=myColours, border="transparent")) png("test_fig.png", width=8.9, height=7, units="cm",res=300) xyplot(sim.values~obs.values, groups=factor(mean.df$month,levels=mixedsort(as.character(unique(mean.df$month)))),data=mean.df, ylim=range(mean.df$obs.values), xlim=range(mean.df$obs.values), xlab=list(label="Obs mean daily rainfall [mm]",cex=0.7),...

I'm struggling to combine in a meaningful way d_ply and xyplot over a big database of sales, to plot two panels per week (one with a chart of the average price and one with cumulated quantities). My action plan is to prepare the dataframe, subsetting it and use the subset...

I came across this article on Nature Methods which provided a very nice heatmap: http://www.nature.com/nmeth/journal/v12/n4/full/nmeth.3311.html Different from other heat map is each rectangle is divided by a diagonal line, with 1 part represent the literature data and the other in-house data. I think this is a very nice way to...

I have a microarray dataset on which I performed a limma lmFit() test. If you haven't heard of it before, it's a powerful linear model package that tests differential gene expressions for >20k genes. You can extract the slope and intercept from the model for each one of these genes....

I would like to add text labels (e.g. a, b, c, d) to different panels in a lattice multi panel plot. I would like the text to appear at the same point (i.e. in the top left corner) in each plot, however I can't seem to do this when the...

I am trying to made a kind of xyplot with a line from the bottom till the value. The problem is that I don't know how to adjust the color of the line. time<- rnorm(50,5,2) death.count<- rnorm(50,-0.25,0.25) Inoc.size<-rep(c("A","B"),times=25) data<-data.frame( time,death.count, Inoc.size) xyplot(death.count~time, data, groups=Inoc.size, ylim=c(0,-0.5), xlab = list("Time - h",...