parent
bdcb95410b
commit
43978e4405
|
@ -541,7 +541,7 @@ You'll see an example of this in the next section, as `transpose()` is particula
|
||||||
|
|
||||||
It's called transpose by analogy to matrices. When you subset a transposed matrix, you switch indices: `x[i, j]` is the same as `t(x)[j, i]`. It's the same idea when transposing a list, but the subsetting looks a little different: `x[[i]][[j]]` is equivalent to `transpose(x)[[j]][[i]]`. Similarly, a transpose is its own inverse so `transpose(transpose(x))` is equal to `x`.
|
It's called transpose by analogy to matrices. When you subset a transposed matrix, you switch indices: `x[i, j]` is the same as `t(x)[j, i]`. It's the same idea when transposing a list, but the subsetting looks a little different: `x[[i]][[j]]` is equivalent to `transpose(x)[[j]][[i]]`. Similarly, a transpose is its own inverse so `transpose(transpose(x))` is equal to `x`.
|
||||||
|
|
||||||
Tranpose is also useful when working with JSON apis. Many JSON APIs represent data frames in a row-based format, rather than R's column-based format. `transpose()` makes it easy to switch between the two:
|
Transpose is also useful when working with JSON apis. Many JSON APIs represent data frames in a row-based format, rather than R's column-based format. `transpose()` makes it easy to switch between the two:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
df <- dplyr::data_frame(x = 1:3, y = c("a", "b", "c"))
|
df <- dplyr::data_frame(x = 1:3, y = c("a", "b", "c"))
|
||||||
|
|
Loading…
Reference in New Issue