algui91 -4 years ago 93

R Question

I am working with the hand-written zip codes dataset. I have loaded the dataset like this:

`digits <- read.table("./zip.train",`

quote = "",

comment.char = "",

stringsAsFactors = F)

Then I get only the ones:

`ones <- digits[digits$V1 == 1, -1]`

Right now, in

`ones`

`ones`

`matrix`

How to create a list of matrix in R

But I tried with my data and did not work.

At first I tried

`ones <- apply(ones, 1, matrix, nrow = 16, ncol = 16)`

`lapply`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

though there are probably simple ways, you can try with `lapply`

:

```
ones_matrix <- lapply(1:nrow(ones), function(i){matrix(ones[i, ], nrow=16)})
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**

Latest added