t: Dienstag, 29. Oktober 2013 21:47
To: Thaler,Thorn,LAUSANNE,Applied Mathematics; R-Help Mailing List
(r-help@r-project.org)
Subject: Re: [R] Automatically Remove Aliased Terms from a Model
Hi Thorn,
it is not entirely clear (at least for me) what you want to accomplish.
an easy and fail safe way
Dear all,
I am trying to implement a function which removes aliased terms from a model.
The challenge I am facing is that with "alias" I get the aliased coefficients
of the model, which I have to translate into the terms from the model formula.
What I have tried so far:
--8<---
Dear all,
I was wondering whether (or better: how) I can use R to read recursively a
directory to get all the sub-folders and files located in the root folder and
put it into a tree like structure where the leaves are files and intermediate
nodes are the directories? The idea is that I'd like t
Dear all,
Is there a possibility to remove a geom from a ggplot? Background suppose I
have a function which returns a ggplot object after some data re-formatting and
aggregation. While this ggplot object is fine in 90% of the cases it turns out
that for some cases I want to suppress one of the
Dear all,
I want to use gsub to change a vector of strings. Basically, I want to replace
any dot by a space, remove the possibly appended ".f" and I want to capitalize
each word. I did that by chaining multiple gsubs together, but I was wondering
(for the sake of learning - maybe the current ve
Dear all,
Assume that I have the following data structure:
d <- expand.grid(subj=1:5, time=1:3, treatment=LETTERS[1:3])
d$value <- 10 ^ (as.numeric(d$treatment) + 1) + 10 * d$subj + d$time
d$value2 <- 10 + d$value
where d$treatment == "C" stands for my control group. What I want to achieve
s the root
cause?
Thanks for your help!
KR,
-Thorn
> -Original Message-
> From: arun [mailto:smartpink...@yahoo.com]
> Sent: Mittwoch, 31. Oktober 2012 13:15
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics
> Cc: R help
> Subject: Re: [R] aggregate.formula: formula fro
Dear all,
I want to use aggregate.formula to conveniently summarize a data.frame. I have
quiet some variables in the data.frame and thus I don't want to write all these
names by hand, but instead create them on the fly. This approach has the
advantage that if there will be even more columns in
Dear all,
I produced the following graph with ggplot which is almost fine, yet I don't
like that the legend for "Means" and "Observations" includes a line, though no
line is used in the plot for those two (the line for "Overall Mean" on the
other hand is wanted):
library(ggplot2)
ddf <- data.f
jrkrid...@inbox.com]
> Sent: Montag, 2. Juli 2012 15:58
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics
> Subject: RE: [R] ggplot: dodge positions
>
> Let's hope it makes it. Just in case my version is okay let me give
> you my sessionInfo in case we have some subtle difference in
t: Montag, 2. Juli 2012 15:21
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics; r-help@r-project.org
> Subject: RE: [R] ggplot: dodge positions
>
> I don't think I was clear. Sorry. What I was refering to was the
>
> ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() +
> ge
tions on the x-axis for geom_boxplot determined? Any
ideas?
Thanks for the help, anyways.
KR,
-Thorn
> -Original Message-
> From: John Kane [mailto:jrkrid...@inbox.com]
> Sent: Montag, 2. Juli 2012 15:04
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics; r-help@r-project.o
rradas [mailto:ruipbarra...@sapo.pt]
> Sent: Montag, 2. Juli 2012 12:20
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics
> Cc: r-help@r-project.org
> Subject: Re: [R] ggplot: dodge positions
>
> Hello,
>
> Though I'm not the most fluent user of ggplot, I've seen no prob
Dear all,
I want to get a series of boxplots (grouped by two factors) and I want to
overlay the original observations and the following code does almost what I
want:
library(ggplot)
ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y = runif(120,0,10),
grp = factor(rep(rep(1:3, 10), 4)))
Dear all,
Sometimes I have the situation where a function takes a data.frame and
an additional argument describing come columns. For greater flexibility
I want to allow for either column names or column indices. What I
usually do then is something like the following:
-8<-
> Does
>
> xyplot(y ~ seq_along(y), xlab = "Index")
>
> do what you want?
Not exactly, because it does not work once multipanel conditioning comes
into play:
xyplot(y~seq_along(y)|factor(rep(1:2, each=5)), xlab = "Index")
The points in the right panel are plotted from 6:10 while the points
Dear all,
How can I make an index plot with lattice, that is plotting a vector
simply against its particular index in the vector, i.e. something
similar to
y <- rnorm(10)
plot(y)
I don't want to specify the x's manually, as this could become
cumbersome when having multiple panels.
I tried some
Dear Peter,
Thanks for your concise answer, it works perfectly.
By the way, I fully agree that "data" or "df" are not good names for
data.frames and I am/was aware of that and I usually avoid those names
(not consequently though I've to admit, it is too tempting ;). However,
if one uses those ev
Dear all,
Quite often I have the situation that I've multiple response variables
and I create Linear Models for them in a function. The following code
illustrates my usual approach:
---8<---
set.seed(123)
dat <- data.frame(x = rep(rep(1:3, each = 3), 4), y = rep(1:3, 12))
Hi all,
I find myself sometimes in the situation where I lapply over a list and
in the particular function I'd like to use the name and or position of
the respective list item. What I usually do is to use mapply on the list
and the names of the list / a position list:
o <- list(A=1:3, B=1:2, C=1)
perm <- sample(values)
}
tmp <- perm[as.numeric(as.factor(x))]
dim(tmp) <- dim(x)
list(x = x, perm.x = tmp, perm = perm)
}
Thanks.
> -Original Message-
> From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl]
> Sent: mardi 8 mars 2011 16:21
> To: Thaler,Thor
Hi all,
Suppose we have the following matrix
m <- matrix(c(1,2,3,2,1,3,3,1,2), ncol = 3, byrow=T)
where in each row each number occurs only once.
I'd like to define a permutation, e.g. 1 -> 2, 2 -> 1, 3 -> 3 and apply
it to the matrix. Thus, the following matrix should result:
m.perm <- matrix
ssage-
> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
> Sent: mardi 8 mars 2011 10:43
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics
> Cc: r-help@r-project.org
> Subject: Re: [R] Read data.frame from clipboard
>
> You haven't told us your OS. But assumin
Hi everybody,
I find myself quite often in the situation that I want to copy data from
Excel to R on the fly. If the source consists only of a single column, I
usually do something like
x <- as.numeric(readClipboard())
If I have a matrix, I usually export this matrix to a csv file fir
Dear all,
In a function I paste a string and convert it to a formula which I pass
to lm[e]. The idea is to write a function which takes the name of the
response variable and the explanatory variable and the data frame as an
argument and calculates an lm[e]. (see example below)
This works fine, bu
> Well, it's actually lattice:::extend.limits(range(x)), but
> extendrange() does basically the same thing, and is available to the
> user (i.e., exported), albeit from a different package.
Thanks again Deepayan for the insight.
A followup question though-- in another setting I'd like to have
re
> No (in fact that wouldn't work anyway), you can simply do
>
> xyplot(y~x|z, xlim = rev(extendrange(x)))
>
> The point is that in this case you have to explicitly specify a
> pre-computed limit, and cannot rely on the prepanel function to give
> you a nice default.
Thanks that does the trick. B
Hi everybody,
I want an x-axis which has xlim=c(max, min) rather than xlim=c(min, max)
in order to reflect the type of the process (cooling):
library(lattice)
myprepanel <- function(x,y,...) list(xlim=rev(range(x)))
x <- rep(1:10, 100)
z <- factor(sample(10, 1000, T))
y <- rnorm(1000, x, as.numer
Perfectly, works as expected. Regarding the other questions, can anybody point
me to the right direction?
BR Thorn
From: RICHARD M. HEIBERGER [mailto:r...@temple.edu]
Sent: lundi 23 août 2010 18:36
To: Thaler,Thorn,LAUSANNE,Applied Mathematics
Cc: r-help@r-project.org
Subject: Re: [R
Hi all,
In R it is possible to sum tables:
> (a <- table(rep(1:3, sample(10,3
1 2 3
2 5 7
> a+a
1 2 3
4 10 14
Now suppose that I have a list of tables, where each table counts the
same things
> k <- list(a,a,a)
How can I sum all tables in k?
> do.call(sum, k)
[1] 42
does not
Thanks, that does the trick. Again a new command learned. Thanks.
However, any hints regarding the rownames issue?
BR Thorn
> -Original Message-
> From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl]
> Sent: lundi 9 août 2010 11:07
> To: Thaler,Thorn,LAUSANNE,Applied
Hi all,
Suppose that I've two data frames, a and b say, both containing a column
'id'. While data frame 'a' contains multiple rows sharing the same id,
data frame 'b' contains just one entry per id (i.e. a 1 to n
relationship). For the ease of modeling I now want to generate a new
data frame c, wh
Works as expected, THX a lot.
BR thorn
> -Original Message-
> From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl]
> Sent: mardi 20 juillet 2010 11:41
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics
> Cc: r-help@r-project.org
> Subject: Re: [R] apply: retur
Hi everybody,
Suppose we have the following data structure:
ddf <-data.frame(a=rep(1:4,3), b=rep(paste("p", 1:3, sep=""), each=4),
c=c(1,0,0,1,1,1,0,1,1,1,1,1))
I want now to make a contingency table for each pair of values of p,
i.e. a contingency table for each of the pairs (p1,p2), (p1,p3) an
Dear all,
I have a very rudimental function which takes a vector of terms and returns a
list of all possible models which can be made using the given terms. For
example for the set c("1", "x", "y", "x:y") I'd get:
~ 1
~ x
~ y
~ x:y
~ 1 + x
~ 1 + y
~ 1 + x:y
~ x + y
~ x + x:y
~ y + x:y
~ 1 + x +
> Try this variation of my.transform that I had posted here:
> http://tolstoy.newcastle.edu.au/R/e2/help/07/09/24707.html
>
> List <- function(..., L = list()) {
>f <- function(){}
>formals(f) <- eval(substitute(as.pairlist(c(alist(...), L
>body(f) <- substitute(modifyL
lgary.ca]
Sent: lundi 21 juin 2010 11:47
To: Thaler,Thorn,LAUSANNE,Applied Mathematics
Cc: r-help@r-project.org
Subject: Re: [R] list() assigning the same value to two items
On 2010-06-21 3:30, Thaler, Thorn, LAUSANNE, Applied Mathematics wrote:
> Hi everybody,
>
> I'd like to have a
Hi everybody,
I'd like to have a list with two elements, where both elements have the same
value:
z <- list(a=1, b=1)
If it happens, that I've to change the value, I've to assure that I change
both. This is error prone. Hence, a better way to achieve this is to define:
tmp <- 1
z <- list(a=tm
38 matches
Mail list logo