similar to: for in r-devel

Displaying 20 results from an estimated 5000 matches similar to: "for in r-devel"

2009 Oct 13
1
for loop over S4
Hello, Consider this : > setClass("track", representation(x="numeric", y="numeric")) [1] "track" > o <- new( "track", x = 1, y = 2 ) > for( i in o ){ + cat( "hello\n") + } Error: invalid type/length (S4/1) in vector allocation This happens at those lines of do_for: n = LENGTH(val); PROTECT_WITH_INDEX(v =
2019 Oct 11
1
New matrix function
The link you posted used the same inputs as in my example. If that is not what you meant maybe a different example is needed. Regards. On Fri, Oct 11, 2019 at 2:39 PM Pages, Herve <hpages at fredhutch.org> wrote: > > Has someone looked into the image processing area for this? That sounds > a little bit too high-level for base R to me (and I would be surprised > if any mainstream
2023 Nov 14
1
data.frame weirdness
Also why should that difference result in different behavior? On Tue, Nov 14, 2023 at 9:38?AM Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > In that case identical should be FALSE but it is TRUE > > identical(a1, a2) > ## [1] TRUE > > > On Tue, Nov 14, 2023 at 8:58?AM Deepayan Sarkar > <deepayan.sarkar at gmail.com> wrote: > > > >
2023 Nov 14
1
data.frame weirdness
On Tue, 14 Nov 2023 at 09:41, Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > Also why should that difference result in different behavior? That's justifiable, I think; consider: > d1 = data.frame(a = 1:4) > d2 = d3 = data.frame(b = 1:2) > row.names(d3) = c("a", "b") > data.frame(d1, d2) a b 1 1 1 2 2 2 3 3 1 4 4 2 > data.frame(d1,
2023 Nov 14
1
data.frame weirdness
In that case identical should be FALSE but it is TRUE identical(a1, a2) ## [1] TRUE On Tue, Nov 14, 2023 at 8:58?AM Deepayan Sarkar <deepayan.sarkar at gmail.com> wrote: > > They differ in whether the row names are "automatic": > > > .row_names_info(a1) > [1] -3 > > .row_names_info(a2) > [1] 3 > > Best, > -Deepayan > > On Tue, 14 Nov
2019 Oct 11
1
New matrix function
Also note that the functionality discussed could be regarded as a generalization of matrix multiplication where * and + are general functions and in this case we have * replaced by == and + replaced by &. On Fri, Oct 11, 2019 at 10:46 AM Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > Using the example in the link here are two one-liners: > > A <-
2016 Jun 27
1
stack problem
One would normally want the original order that so that one can stack a list, operate on the result and then unstack it back with the unstacked result having the same ordering as the original. LL <- list(z = 1:3, a = list()) # since we can't do s <- stack(LL,. drop = FALSE) do this instead: s <- transform(stack(LL), ind = factor(as.character(ind), levels = names(LL))) unstack(s)
2024 Jul 21
1
Using the pipe, |>, syntax with "names<-"
If you object to names(x)[2]<- ... then use replace: z |> list(x = _) |> within(replace(names(x), 2, "foo")) |> _$x On Sun, Jul 21, 2024 at 11:10?AM Bert Gunter <bgunter.4567 at gmail.com> wrote: > > hmmm... > But note that you still used the nested assignment, names()[2] <- > "foo", to circumvent R's pipe limitations, which is exactly
2016 Jun 27
2
stack problem
stack() seems to drop empty levels. Perhaps there could be a drop=FALSE argument if one wanted all the original levels. In the example below, we may wish to retain level "b" in s$ind even though component LL$b has length 0. > LL <- list(a = 1:3, b = list()) > s <- stack(LL) > str(s) 'data.frame': 3 obs. of 2 variables: $ values: int 1 2 3 $ ind : Factor
2024 Sep 08
1
Inconsistency between row and nrow
The fact that it is consistent with the documentation is not the point. The point is that the design itself is inconsistent. On Sun, Sep 8, 2024 at 8:27?AM Marc Schwartz <marc_schwartz at me.com> wrote: > > Hi Gabor, > > In strictly reading the help files for both nrow() and row(), the 'x' argument in the former case is "a vector, array, data frame, or
2018 Jan 26
0
Portable R in zip file for Windows
Can you clarify what the nature of the security restriction is? If you can't run the R installer then how it is that you could run R? That would still involve running an external exe even if it came in a zip file. Could it be that the restriction is not on running exe files but on downloading them? If that is it then there are obvious workarounds (rename it not to have an exe externsion or
2008 May 13
0
[LLVMdev] Iterator protocols
On May 12, 2008, at 6:49 PM, Talin wrote: > So the question is, what's the trade-off. In most languages that > support > exceptions, you tend to think of exceptions as expensive operations > that > should only be thrown if something truly "exceptional" happens. OTOH, > the Java case is also made worse by the fact that a large part of the > time you'll be
2024 Jul 21
1
Extract
Fixing col.names=paste0("S", 1:5) assumes that there will be 5 columns and we may not want to do that. If there are only 3 fields in string, at the most, we may wish to generate only 3 columns. On Sun, Jul 21, 2024 at 2:20?PM Bert Gunter <bgunter.4567 at gmail.com> wrote: > > Nice! -- Let read.table do the work of handling the NA's. > However, even simpler is to use
2024 Jul 22
1
Extract
Thanks. I found this to be quite informative and a nice example of how useful R-Help can be as a resource for R users. Best, Bert On Mon, Jul 22, 2024 at 4:50?AM Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > Base R. Regarding code improvements: > > 1. Personally I find (\(...) ...)() notation hard to read (although by > placing (\(x), the body and )() on 3
2015 May 22
1
returnValue()
In R devel rev.66393 (2014-08-15) it was possible to do this: trace(optim, exit = quote(str(returnValue()))) but returnValue() does not seem to be available any more. The above was useful to get the output of a function when it was called deep within another function that I have no control over. Has this been replaced by some other equivalent function? P.S. This demonstrates that it no
2018 Sep 23
1
Recall
This works: my.compose <- function(f, ...) { if (missing(f)) identity else function(x) f(my.compose(...)(x)) } my.compose(sin, cos, tan)(pi/4) ## [1] 0.5143953 sin(cos(tan(pi/4))) ## [1] 0.5143953 But replacing my.compose with Recall in the else causes it to fail: my.compose2 <- function(f, ...) { if (missing(f)) identity else function(x) f(Recall(...)(x))
2023 Nov 14
1
data.frame weirdness
They differ in whether the row names are "automatic": > .row_names_info(a1) [1] -3 > .row_names_info(a2) [1] 3 Best, -Deepayan On Tue, 14 Nov 2023 at 08:23, Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > What is going on here? In the lines ending in #### the inputs and outputs > are identical yet one gives a warning and the other does not. > >
2024 Jul 21
1
Extract
As always, good point. Here's a piped version of your code for those who are pipe afficianados. As I'm not very skilled with pipes, it might certainly be improved. dat <- dat$string |> read.table( text = _, fill = TRUE, header = FALSE, na.strings = "") |> (\(x)'names<-'(x,paste0("s", seq_along(x))))() |>
2018 Jan 26
2
Portable R in zip file for Windows
Pretty good question Gabor. I can execute R once it is installed (if someone with rights installs it before) but not the installer. I can download the installer (with some pain). I know that some installers are actually compressed files in disguise, but I think this is not the case with R, right? I will study the exact nature of the restriction, and get back to you. Nevertheless, having a
2008 May 13
6
[LLVMdev] Iterator protocols
This is related to the general question of efficiency of unwinds. I'm mulling over whether to use the Java-style or Python-style iterator protocol for my language. The Python style is to have a special exception (StopIteration) that is thrown when the end of the sequence is reached. The Java style is to have a separate "hasNext" method on the iterator object that says whether or