Displaying 20 results from an estimated 6000 matches similar to: "Lattice: shifting strips to left of axes"
2007 Jun 22
1
Lattice: hiding only some strips
I am using R 2.4.0 and lattice to produce some xyplots conditioned on a
factor and a shingle. The shingle merely chops up the data along the
x-axis, so it is easy to identify which part of the shingle a panel is
in by looking at the x-axis markings. I only want to have a strip at the
top for the factor.
Is this possible? I looked into calculateGridLayout() and it seems to me
that there
2010 Mar 31
1
strip.custom with strip on left for three conditioning variables
I want to use a strip.custom as with useOuterStrips for three conditioning
variables.
useOuterStrips restricts this to only two conditioning variables, and I
cannot figure out
how to write strip.custom properly to do this.
library(lattice)
mtcars$HP <- equal.count(mtcars$hp)
#with two factors
x2<-xyplot(mpg ~ disp | HP + factor(cyl), mtcars)
useOuterStrips(x2)
#with three factors
2007 Dec 01
2
Sweave: Variables in code chunk headers
I would like to be able to do something like this:
<<echo=F,fig=T,width=mywidth>>=
...
@
with mywidth set in a previous code chunk. Is there a way to do this in
Sweave?
(Sorry for two questions in a row, I have been saving these up.)
--
Michael
2007 Dec 01
2
Sweave: Variables in code chunk headers
I would like to be able to do something like this:
<<echo=F,fig=T,width=mywidth>>=
...
@
with mywidth set in a previous code chunk. Is there a way to do this in
Sweave?
(Sorry for two questions in a row, I have been saving these up.)
--
Michael
2007 Oct 01
4
how to plot a graph with different pch
I am trying to plot a graph but the points on the graph should be
different symbols and colors. It should represent what is in the legend.
I tried using the points command but this does not work. Is there
another command in R that would allow me to use different symbols and
colors for the points?
Thank you kindly.
data(mtcars)
plot(mtcars$wt,mtcars$mpg,xlab= "Weight(lbs/1000)",
2013 Apr 17
2
remove higher order interaction terms
Dear all,
Consider the model below:
> x <- lm(mpg ~ cyl * disp * hp * drat, mtcars)
> summary(x)
Call:
lm(formula = mpg ~ cyl * disp * hp * drat, data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-3.5725 -0.6603 0.0108 1.1017 2.6956
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.070e+03 3.856e+02 2.776 0.01350 *
cyl
2012 Mar 15
2
Ggplot barchart drops factor levels: how to show them with zero counts?
Hello,
When plotting a barchart with ggplot it drops the levels of the factor for
which no counts are available.
For example:
library(ggplot)
mtcars$cyl<-factor(mtcars$cyl)
ggplot(mtcars[!mtcars$cyl==4,], aes(cyl))+geom_bar()
levels(mtcars[!mtcars$cyl==4,])
This shows my problem. Because no counts are available for factorlevel '4',
the label 4 dissapears from the plot. However, I
2010 Aug 04
3
retrieve name of an object?
Dear all
Is there an easier way to retrieve the name of an object? For example,
> tmp <- 1:10
> as.character(quote(tmp))
[1] "tmp"
> as.character(quote(mtcars$cyl))
[1] "$" "mtcars" "cyl"
> as.character(quote(mtcars$cyl))[3]
[1] "cyl"
The last call more than anything seems a hack. Is there a better way?
Thank you
Liviu
2020 Apr 16
2
suggestion: "." in [lsv]apply()
I'm sure this exists elsewhere, but, as a trade-off, could you achieve
what you want with a separate helper function F(expr) that constructs
the function you want to pass to [lsv]apply()? Something that would
allow you to write:
sapply(split(mtcars, mtcars$cyl), F(summary(lm(mpg ~ wt,.))$r.squared))
Such an F() function would apply elsewhere too.
/Henrik
On Thu, Apr 16, 2020 at 9:30 AM
2020 Apr 16
6
suggestion: "." in [lsv]apply()
Hi,
I would like to make a suggestion for a small syntactic modification of
FUN argument in the family of functions [lsv]apply(). The idea is to
allow one-liner expressions without typing "function(item) {...}" to
surround them. The argument to the anonymous function is simply referred
as ".". Let take an example. With this new feature, the following call
2013 Jan 20
2
Lattice levelplot- remove unused levels per panel
Hi,
I am using levelplot, and would like remove from each panel (condition) its
unused x levels.
e.g.
Remove from panel vs=1 the cyl level=8.
data(mtcars)
levelplot(mpg~factor(cyl)*factor(gear)|factor(vs))
Thanks for your help,
Ronny
--
View this message in context: http://r.789695.n4.nabble.com/Lattice-levelplot-remove-unused-levels-per-panel-tp4656087.html
Sent from the R help mailing
2020 Apr 17
2
suggestion: "." in [lsv]apply()
Thanks Simon,
Now, I see better your argument.
Le 16/04/2020 ? 22:48, Simon Urbanek a ?crit?:
> ... I'm not arguing against the principle, I'm arguing about your
> particular proposal as it is inconsistent and not general.
This sounds promising for me. May be in a (new?) future, R core will
come with a correct proposal for this principle?
Meanwhile, to avoid substitute(),
2020 Apr 16
2
suggestion: "." in [lsv]apply()
Simon,
Thanks for replying. In what follows I won't try to argue (I understood
that you find this a bad idea) but I would like to make clearer some of
your point for me (and may be for others).
Le 16/04/2020 ? 16:48, Simon Urbanek a ?crit?:
> Serguei,
>> On 17/04/2020, at 2:24 AM, Sokol Serguei <sokol at insa-toulouse.fr>
>> wrote: Hi, I would like to make a
2007 May 12
2
Implicit vs explicit printing and the call stack
Hi everyone,
I've run into a bit of strange problem with implicit vs explicit
printing and the call stack. I've included an example at the bottom of
this email. The basic problem is that I have an S3 object with a
print method. When the object is implicitly printed (ie. typed
directly into the console) the function arguments in the call stack
are exploded out to their actual values,
2009 Apr 28
1
latticeExtra: useOuterStrips and axis.line$lwd
Hi,
I'm working on some lattice wireframe figures that have two conditioning
factors, and I want the strips labelled on the top and left of the
entire plot, rather than above each individual panel. useOuterStrips()
does this, but it draws internal axis lines, even after I explicitly set
axis.line to 0. Is there a way to use useOuterStrips but without axis
boxes?
I've included a short
2020 Apr 20
1
suggestion: "." in [lsv]apply()
Le 19/04/2020 ? 20:46, Gabor Grothendieck a ?crit?:
> You can get pretty close to that already using fn$ in the gsubfn package:
>> library(gsubfn) fn$sapply(split(mtcars, mtcars$cyl), x ~
>> summary(lm(mpg ~ wt, x))$r.squared)
> 4 6 8 0.5086326 0.4645102 0.4229655
Right, I thought about similar syntax but this implementation has
similar flaws pointed by Simon, i.e. it reduces
2011 Aug 17
1
extract variables from model formula
Hi All,
I am writing a function to predict values based on a model. It works
fine as long as the formula just uses regular variable names. I am
having a problem when the variables are wrapped with a function call.
For example:
m <- lm(mpg ~ factor(cyl), data = mtcars)
## I get the column names using
as.character(attr(terms(m), "variables"))[-1L]
## which gives the same column
2011 Aug 19
2
display only the top-right half of a correlation matrix?
Dear all
Is there an easy way to display only one half (top-right or
bottom-left) of a correlation matrix?
> require(Hmisc)
> rcorr(as.matrix(mtcars[ , 1:4]))
mpg cyl disp hp
mpg 1.00 -0.85 -0.85 -0.78
cyl -0.85 1.00 0.90 0.83
disp -0.85 0.90 1.00 0.79
hp -0.78 0.83 0.79 1.00
n= 32
P
mpg cyl disp hp
mpg 0 0 0
cyl 0 0 0
disp 0 0
2010 Nov 30
3
pca analysis: extract rotated scores?
Dear all
I'm unable to find an example of extracting the rotated scores of a
principal components analysis. I can do this easily for the un-rotated
version.
data(mtcars)
.PC <- princomp(~am+carb+cyl+disp+drat+gear+hp+mpg, cor=TRUE, data=mtcars)
unclass(loadings(.PC)) # component loadings
summary(.PC) # proportions of variance
mtcars$PC1 <- .PC$scores[,1] # extract un-rotated scores of
2016 Apr 14
0
Bug in by() function which works for some FUN argument and does not work for others
I think you are not using the best function for what your intentions are.
Try:
> by(data=mtcars, INDICES=list(as.factor(mtcars$am)), FUN=colMeans)
: 0
mpg cyl disp hp drat wt
qsec vs
17.1473684 6.9473684 290.3789474 160.2631579 3.2863158 3.7688947
18.1831579 0.3684211
am gear carb
0.0000000