similar to: Inconsistency between row and nrow

Displaying 20 results from an estimated 20000 matches similar to: "Inconsistency between row and nrow"

2024 Sep 08
2
Inconsistency between row and nrow
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 NULL.", whereas in the latter case it is "a matrix-like object, that is one with a two-dimensional dim.". Thus, I would expect row() to fail on a >= 3-dimensional array, as your example shows. In reading the help file for
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
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
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
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)
2018 Jul 24
2
oddity in transform
The idea is that one wants to write the line of code below in a general way which works the same whether you specify ix as one column or multiple columns but the naming entirely changes when you do this and BOD[, 1] and transform(BOD, X=..., Y=...) or other hard coding solutions still require writing multiple cases. ix <- 1:2 transform(BOD, X = BOD[ix] * seq(6)) On Tue, Jul 24, 2018 at
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
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
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
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
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 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))))() |>
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 22
3
Extract
Base R. Regarding code improvements: 1. Personally I find (\(...) ...)() notation hard to read (although by placing (\(x), the body and )() on 3 separate lines it can be improved somewhat). Instead let us use a named function. The name of the function can also serve to self document the code. 2. The use of dat both at the start of the pipeline and then again within a later step of the pipeline
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
2018 Jul 23
2
oddity in transform
Note the inconsistency in the names in these two examples. X.Time in the first case and Time.1 in the second case. > transform(BOD, X = BOD[1:2] * seq(6)) Time demand X.Time X.demand 1 1 8.3 1 8.3 2 2 10.3 4 20.6 3 3 19.0 9 57.0 4 4 16.0 16 64.0 5 5 15.6 25 78.0 6 7 19.8 42 118.8 >
2016 Mar 18
1
for in r-devel
Regarding, this news item for r-devel: ?for()? loops are generalized to iterate over any object with ?[[? and ?length()? methods. Thanks to Herv? Pag?s for the idea and the patch. Below dd is an object for which [[ and length work but the result is still numeric rather than Date class in "R Under development (unstable) (2016-03-15 r70334)" as observed in the comments to:
2018 Jul 29
2
odd behavior of names
The first component name has backticks around it and the second does not. Though not wrong, it seems inconsistent. list(a = 1, b = 2) ## $`a` ## [1] 1 ## ## $b ## [1] 2 R.version.string ## [1] "R version 3.5.1 Patched (2018-07-02 r74950)" -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com