Displaying 20 results from an estimated 20000 matches similar to: "Data frame with 0 rows."
2008 May 16
1
Making slope coefficients ``relative to 0''.
I am interested in whether the slopes in a linear model are different
from 0.
I.e. I would like to obtain the slope estimates, and their standard
errors,
``relative to 0'' for each group, rather than relative to some baseline.
Explicitly I would like to write/represent the model as
y = a_i + b_i*x + E
i = 1, ..., K, where x is a continuous variate and i indexes groups
(levels of a
2024 Sep 28
1
Is there a sexy way ...?
Hi Rolf,
this topic is probably already saturated, but here is a tidyverse solution:
```
library(purrr)
x <- list(
? `1` = c(7, 13, 1, 4, 10),
? `2` = c(2, 5,? 14, 8, 11),
? `3` = c(6, 9, 15, 12, 3)
)
x |>
? pmap(~ c(..1, ..2, ..3)) |>
? reduce(c)
#> [1]? 7? 2? 6 13? 5? 9? 1 14 15? 4? 8 12 10 11? 3
```
Here, we map over the elements of the list in parallel (hence pmap),
2006 Mar 23
3
Intercepts in linear models.
A colleague asked me if there is a way to specify with a
***variable*** (say ``cflag'') whether there is an intercept in a
linear model.
She had in mind something like
lm(y ~ x - cflag)
where cflag could be 0 or 1; if it's 0 an intercept should
be fitted, if it's 1 then no intercept.
This doesn't work ``of course''. The cflag just gets treated
as another predictor
2024 Sep 28
1
Is there a sexy way ...?
Sorry to append, but I just realised that of course
```
x |>
? pmap(c) |>
? reduce(c) |>
? unname()
```
also works and is a general solution in case your list has more than
three elements. Here, we map in parallel over all elements of the list,
always combining the current set of elements into a vector, and then
reduce the resulting list into a vector by combining the elements
2007 Oct 03
3
Factor levels.
I have factors with levels ``Unit", "Achieved", and "Scholarship"; I
wish to replace these with
"U", "A", and "S".
So I do
fff <- factor(fff,labels=c("U","A","S"))
This works as long as all of the levels are actually present in the
factor. But if ``Scholarship'' is absent
(as if often is) then
2024 Sep 28
1
Is there a sexy way ...?
I see a book coming:
"666 ways to do the same thing in R ranked by sexiness."
Kidding aside, if you look under the covers of some of the functions we are using, we may find we are taking steps back as some of them use others and perhaps more functionality than we need.
But for a new reader , looking at many approaches may open up other ways and ideas and see the problem space as quite
2024 Sep 28
2
Is there a sexy way ...?
Avi
I fear this was all a huge social experiment.
Testing if a post titled "sexy way" would increase engagement...
On Sat, 28 Sep 2024, 07:21 , <avi.e.gross at gmail.com> wrote:
> I see a book coming:
> "666 ways to do the same thing in R ranked by sexiness."
>
> Kidding aside, if you look under the covers of some of the functions we
> are
2012 Oct 05
1
Format of numbers in plotmath expressions.
I want to do something like:
TH <- sprintf("%1.1f",c(0.3,0.5,0.7,0.9,1))
plot(1:10)
legend("bottomright",pch=1:5,legend=parse(text=paste("theta ==",TH)))
Notice that the final "1" comes out in the legend as just plain "1" and NOT
as "1.0" although TH is
[1] "0.3" "0.5" "0.7" "0.9"
2024 Sep 27
7
Is there a sexy way ...?
I have (toy example):
x <- list(`1` = c(7, 13, 1, 4, 10),
`2` = c(2, 5, 14, 8, 11),
`3` = c(6, 9, 15, 12, 3))
and
f <- factor(rep(1:3,5))
I want to create a vector v of length 15 such that the entries of v,
corresponding to level l of f are the entries of x[[l]]. I.e. I want
v to equal
c(7, 2, 6, 13, 5, 9, 1, 14, 15, 4, 8, 12, 10, 11, 3)
I can create v
2024 Sep 29
1
Is there a sexy way ...?
Admit it, Rolf. Haven't you wondered if S, in a more private way, is sexier than R?
OK, kidding aside, we have talked this to death.
Just FYI, the conversation was stimulating for some of us and I have continued on my own and located functions I see as useful in the stringi and stringr packages to make my silly version ever less silly! LOL!
-----Original Message-----
From: Rolf Turner
2005 Jun 06
1
Missing values in argument of .Fortran.
I wish to pass a vector ``y'', some of whose entries are NAs to a
fortran subroutine which I am dynamically loading and calling by
means of .Fortran(). The subroutine runs through the vector entry by
entry; obviously I want to have it do one thing if y[i] is present
and a different thing if it is missing.
The way I am thinking of proceeding is along the xlines of:
ymiss <- is.na(y)
2012 Oct 30
5
Swap rows and columns in a matrix
Dear R users,
I want a help to write an algorithm for swapping rows and columns in a matrix
thanks in advance
[[alternative HTML version deleted]]
2024 Sep 27
1
Is there a sexy way ...?
>>>>> Chris Evans via R-help
>>>>> on Fri, 27 Sep 2024 12:20:47 +0200 writes:
> Oh glorious!? Thanks Duncan.
> Fortune cookie nomination!
I don't disagree with the nomination -- thank you, Duncan!
However, please note that I'm sure Rolf's was challenged /
question was ment to work correctly for all factors `f` with
levels
2024 Sep 28
1
Is there a sexy way ...?
Rold,
We need to be clear on what makes an answer sexy! LOL!
I decided it was sexy to do it in a way that nobody (normal) would and had
not suggested yet.
Here is an original version I will explain in a minute. Or, maybe best a bit
before. Hee is the unformatted result whicvh is a tad hard to read but will
be made readable soon:
x <- list(`1` = c(7, 13, 1, 4, 10),
`2` = c(2, 5,
2012 May 19
1
Names of Greek letters stored as character strings; plotmath.
I had such good luck with my previous question to r-help, (a few minutes
ago) that I thought I would try again with the following query:
> Suppose I have
>
> xNm <- "gamma"
>
> I would like to be able to do
>
> plot(1:10,xlab = <something involving xNm">)
>
> and get the x axis label to be the Greek letter gamma
> (rather than the
2008 Oct 24
4
Mail server problem?
I keep getting repeated copies of ``R-help post acknowledgements'' in
respect
of a couple of postings that I made to the list this morning (my time).
I only posted each posting *once*. I hope that others are not getting
repeated copies of my postings .... I mean I *know* my postings are so
wonderful they merit re-reading, but one does not need another copy
in order
to re-read! :-)
2024 Sep 28
2
Is there a sexy way ...?
"Sexy code" may get a job done and demonstrate the code's knowledge of a programming language, but it often does this at the expense of clear, easy to document (i.e. annotate what the code does), easy to read, and easy to understand code. I fear that this is what this thread has developed "sexy" but not easily understandable code. While I send kudos to all of you, remember
2024 Sep 29
1
Is there a sexy way ...?
On Sat, 28 Sep 2024 10:26:31 +0100
CALUM POLWART <polc1410 at gmail.com> wrote:
> Avi
>
> I fear this was all a huge social experiment.
>
> Testing if a post titled "sexy way" would increase engagement...
<SNIP>
I conjecture that this conjecture was tongue-in-cheek. Be that as it
were ??, let me assure everyone that such was not my intention. The
usage
2008 Jun 06
3
Existence of formal arguments.
I just discovered what seems to me to be a slight funny in respect
of formal argument names. If I define a function
foo <- function(a,b){ ... whatever ...}
then ``inside'' foo() the exists() function will return TRUE
from ``exists("a") whether an object named ``a'' exists or not.
But get("a") will yield an error ``object "a" not found''
2009 Sep 27
2
Determining name of calling function.
I have vague recollections of seeing this question discussed on r-help
previously, but I can't find the relevant postings.
I want to determine (from within a given function) the name of the
function
calling that given function.
E.g. if I have a function foo() which calls a function bar(), and also
a function clyde() which calls bar(), I want to have, in the code of
bar(),
an instruction