Given any regression model, created for instance by lm, lme, lmer, or rqs, such
as
z1<-lm(weight~poly(Time,2), data=ChickWeight)
I would like a general way to obtain only those variables used for the model. In the current example, this
"minimal data frame" would consist of the "weight" and "T
To check that a regression object comes from logistic regression, I employ the
following two lines:
stopifnot(glmObject$family$family=="binomial")
stopifnot(glmObject$family$link=="logit")
For instance:
toyfunction<-function(glmObject) {
stopifnot(inherits(glmObject, "
tally *and* to zoom in?
myplot+coord_cartesian(ylim=mylimits) # zooms in
myplot+coord_cartesian(ylim=mylimits) + coord_flip() # flips but does not zoom
myplot + coord_flip()+coord_cartesian(ylim=mylimits) # zooms but does not flip
Jacob Wegelin
Op 20-jul.-2015 20:29 schreef "Jacob Wege
With base graphics, one can use the "ylim" argument to zoom in on a boxplot.
With ggplot2, using "limits" to try to zoom in on a boxplot *changes the box*.
Since the box usually indicates the 25th and 75th percentiles of a quantitative variable,
this is puzzling.
The toy code below demonstrat
On 2015-06-02 Tue 14:20, Jacob Wegelin wrote:
I want to use a specialized function to compute knots on the fly to pass to
splines::bs within a call to nlme::lme.
The specialized function will compute knots from the x-axis variable (the x
argument in a call to splines::bs).
The syntax works
o error:
mylme<- with(toydat,
lme(fixed=why~bs(eks,knots=customKnotsFn(some=eks)),random=~1|ID))
print(mylme$call)
Of course, with the workaround the resulting mylme does not know where the data
came from.
Why should a workaround be necessary? Is there something inherently misguided about
Incidentally,
?scales::percent
brings up exactly the same text as
?scales::percent_format
On 2014-02-27 Thu 14:47, Jacob Wegelin wrote:
But percent_format() does not take the argument, multiply it by 100, and
paste on a percent sign, as we see here:
?scales::percent_format
percent_format
:
Hi:
On Thu, Feb 27, 2014 at 8:49 AM, Jacob Wegelin wrote:
scales::percent appears not to be documented.
?scales::percent_format
where it tells you that it takes its argument, multiplies it by 100
and then attaches a percent sign to it. For most situations, the data
should be relative f
path. Nor does round_any().
percent(0.010101)
[1] "1.01%"
percent
function (x)
{
x <- round_any(x, precision(x)/100)
str_c(comma(x * 100), "%")
}
find("precision")
character(0)
find("round_any")
character(0)
Thanks for any insights
Jacob
I want to put the "plus or minus" symbol into a character variable, so that this can be
turned into a factor and be displayed in the "strip" of a faceted ggplot2 plot.
A very nice solution, thanks to Professor Ripley's post of Nov 16, 2008;
3:13pm, visible at
http://r.789695.n4.nabble.com/Sym
PRETTYNEWDATA$fitlme<-predict(thislme,level=0, newdata=PRETTYNEWDATA)
thislme
}
Jake Wegelin
On Thu, 6 Dec 2012, Duncan Murdoch wrote:
On 06/12/2012 2:28 PM, Jacob Wegelin wrote:
I want to fit a series of lme() regression models that differ only in the
degrees of freedom of a ns() spline.
I want to fit a series of lme() regression models that differ only in the
degrees of freedom of a ns() spline. I want to use a wrapper function to do
this. The models will be of the form
y ~ ns(x, df=splineDF)
where splineDF is passed as an argument to a wrapper function.
This works fine if th
I would like to fit regression models of the form
y ~ ns(x, df=splineDF)
where splineDF is passed as an argument to a wrapper function.
This works fine if the regression function is lm(). But with lme(),
I get two different errors, depending on how I handle splineDF
inside the wrapper function
I would like to fit regression models of the form
y ~ ns(x, df=splineDF)
where splineDF is passed as an argument to a wrapper function.
This works fine if the regression function is lm(). But with lme(),
I get two different errors, depending on how I handle splineDF
inside the wrapper function
On my MacBook Pro (OS 10.6.8), after updating to R version 2.14.0 (2011-10-31)
and reinstalling the Hmisc package, I am unable to load the Hmisc library.
Hmisc was working *before* I updated R.
Any idea what's wrong?
Details below.
install.packages("Hmisc", dependencies=TRUE)
trying URL
'h
In ggplot2, I would like to make a boxplot that has the following properties:
(1) Contrary to default, the meaningful axis should be the horizontal axis.
Lattice does this, for instance, by
library(lattice);bwplot(~mtcars$mpg)
(2) It is *univariate*, i.e., of a single vector, say mtcars$mpg.
Suppose we have
• An lmer{lme4} model, MyModel, computed on dataframe SomeDATA;
• Dataframe NEWDATA, which contains the variables used in
computing MyModel, but different values for these variables.
In NEWDATA I would like to compute (in an automated, quick, easy,
The purpose of this email is to
(1) report an example where fisher.test returns p > 1
(2) ask if there is a reliable way to avoid p>1 with fisher.test.
If one has designed one's code to return an error when it finds a "nonsensical"
probability, of course a value of p>1 can cause havoc.
Examp
ordering a chicken sandwich and then telling the waitress to hold (that is, to
subtract) the meat, lettuce, and mayonnaise.
Thanks for any insights
Jacob Wegelin
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
The example below creates parallel time-series plots of three different y
variables conditioned by a dichotomous factor. In the graphical layout,
• Each y variable inhabits its own row and is plotted on its own
distinct scale.
• Each level of the factor has its own
The syntax below creates parallel time-series plots of three different y
variables conditioned by a dichotomous factor. (Thanks to several people who
answered an earlier post from Thursday,
http://tolstoy.newcastle.edu.au/R/e9/help/10/02/3848.html. The syntax below is
based on their helpful
Often, when exploring a dataset, I'd like to plot several very different Y
variables against the same X variable, in panels stacked one over the other. Is
there an easy way to do this?
I'd like to achieve an elegant look similar to the look achieved by lattice in
conditioned plots--for instan
On Sun, 15 Nov 2009 14:33 -0500, "Jacob Wegelin"
wrote:
>
> Often I perform the same task on a series of variables in a dataframe,
> by looping through a character vector that holds the names and using
> paste(), eval(), and parse() inside the loop.
>
> For ins
Often I perform the same task on a series of variables in a dataframe,
by looping through a character vector that holds the names and using
paste(), eval(), and parse() inside the loop.
For instance:
rm(environmental)
thesevars<-names(environmental)
environmental$ToyReal <-rnorm(nrow(environmen
Often I perform the same task on a series of variables in a dataframe, by
looping through a character vector that holds the names and using paste(),
eval(), and parse() inside the loop.
For instance:
thesevars<-names(environmental)
environmental$ToyOutcome<-rnorm(nrow(environmental))
tableOf
Often it is useful to keep a "codebook" to document the contents of a dataset. (By
"dataset" I mean
a rectangular structure such as a dataframe.)
The codebook has as many rows as the dataset has columns (variables, fields).
The columns (fields)
of the codebook may include:
• va
When we call a lattice function such as xyplot, to what extent does
the "data" designation cause the function to look inside the "data"
for variables?
In the examples below, the "subset" argument understands that
"Variety" is a variable in the data.
But the "scales" argument does not understand t
=T)
whereas dropping levels in the "group" argument does not create the
desired effect
xyplot(yield~nitro, subset=(Block=="I" | Block=="II"), data=Oats,
group=Block [, drop=T], auto.key=T)
Jacob Wegelin
> -Peter Ehlers
>
> Jacob Wegelin wrote:
>
The following code produces a legend ("key") that mentions the unused
levels of Block.
library(MEMSS)
xyplot(yield~nitro, subset=(Block=="I" | Block=="II"), data=Oats,
group=Block, auto.key=T)
and adding "drop.unused.levels=T" does not fix it. And in fact even
the following does not solve the pro
How would I create the following plot using lattice?
symbols( combPsummary$pastRate, combPsummary$finRate,
circles=sqrt(combPsummary$N) )
The idea is to plot finRate vs pastRate using circles whose areas are
proportional to the number of people in each group.
The following attempt does not reall
Was: Re: Adjusting x/y text labels for a bwplot using cex.lab
The purpose of this email is merely to explain how to control, separately,
two different text sizes on the axes in an R plot, in traditional or lattice
graphics. I did not find an explicit exposition of this, with examples, in a
quick
Suppose we wish to achieve the following three aims:
(1) Control the aspect ratio of our plot (i.e., tweak this till it looks
great)
(2) Save the plot as a PDF with zero or minimal white space outside it.
(3) Preserve this in code, so that in the future the exact same plot can be
reproduced by si
Is there a simple way to specify a theme or trellis (lattice) parameters so
that, in a multipanel (conditioned) plot, there is no color and in the
strips there is no shading? This is the effect achieved on page 124 of
Deepayan Sarkar's "Lattice" (figure 7.2).
I managed to trick lattice into making
On Wed, 5 Aug 2009, Deepayan Sarkar wrote:
> On 8/5/09, Jacob Wegelin wrote:
>> I would like to use lattice graphics to plot multiple functions (or
groups
>> or subpopulations) on the same plot region, using different line types
"lty"
>> or colors "col"
On Wed, Aug 5, 2009 at 1:30 PM, Jacob Wegelin wrote:
> I would like to use lattice graphics to plot multiple functions (or groups
> or subpopulations) on the same plot region, using different line types "lty"
> or colors "col" to distinguish the functions (or groups)
I would like to use lattice graphics to plot multiple functions (or groups
or subpopulations) on the same plot region, using different line types "lty"
or colors "col" to distinguish the functions (or groups).
In traditional graphics, this seems straightforward: First plot all the data
using 'type
t the beginning of your
> session should do it?
>
> Jacob Wegelin wrote:
>
>>
>> Consider all the text that one sees on the console during an R session.
>>
>> Is there a way, within R, to make all this text--both the "output" and the
>> "messages"
4558University of Illinois
> fax: 217-244-6678Urbana, IL 61801
>
>
>
>
> On Aug 3, 2009, at 3:01 PM, Jacob Wegelin wrote:
>
> Consider all the text that one sees on the console during an R session.
>>
>> Is there a way, withi
Consider all the text that one sees on the console during an R session.
Is there a way, within R, that all this text--i.e., both the "output" and
the "messages"--can be automatically copied to a single file, in addition to
its being visible on the console?
If I remember to save the console to a f
Consider all the text that one sees on the console during an R session.
Is there a way, within R, to make all this text--both the "output" and the
"messages"--automatically get copied to a single text file, in addition to seeing it on
the console?
If I remember to save the console to a file a
Suppose we have some glm object such as:
myglm <- glm( y ~ x, data=DAT)
Is there an elegant way--or the "right way" within the R way of thinking--to
obtain the names of the response variable, the predictor variables, and the
dataset, as character strings?
For instance, suppose the "right way" wa
,
>
> Bert Gunter
> Genentech
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On
> Behalf Of Jacob Wegelin
> Sent: Thursday, July 17, 2008 1:58 PM
> To: [EMAIL PROTECTED]
> Subject: [R] nested calls, variable scope
>
> Below i
I used read.dta() to read in a Stata 9 dataset to R. The "Sex01" variable
takes on two values in Stata: 0 and 1, and it is labeled "M" and "F"
respectively, analogous to an R factor. Thus, read.dta reads it in as a
factor.
Now, I wanted to see what this variable *really* is, in R. For instance,
so
Below is an example of a problem I encounter repeatedly when I write
functions. A call works at the command line, but it does not work inside a
function, even when I have made sure that all required variables are
available within the function. The only way I know to solve it is to make
the require
Below is an example of a problem I encounter repeatedly when I write functions.
A call works at the command line, but it does not work inside a function, even
when I have made sure that all required variables are available within the
function. The only way I know to solve it is to make the re
45 matches
Mail list logo