**20**wrote:

Dear colleagues I'm trying to create a list of data frames from an original matrix. Each new data frame should have a new column with a row-sum that will be used to subset the new data frames accordingly. The point is I'm unable to get the desired data frame structure with multiple columns, I just get one vector-like files. I will appreciate your help, thanks in advance. Roberto

cm: matrix with columns B1,B2,B3,F1,F2,F3....S1,S2,S3 and rownames gene1...16432

```
t=c("B","F","L","I","M","S")
cm.f=list()
for (i in 1:6)
{
a= data.frame("OoenG" = rownames(cm), cm[,grep(t[i], colnames(cm))]); cm.f[t[i]] = data.frame(apply(a[,2:4],1,sum));
cm.f[t[i]]=data.frame(a,cm.f[t[i]]);
print(summary(cm.f[[i]] <3))
}
```

Mode NA's logical 16432 Mode NA's logical 16432 Mode NA's .............

warnings() Warning messages: 1: In cm.f[t[i]] <- data.frame(a, cm.f[t[i]]) : number of items to replace is not a multiple of replacement length 2: In Ops.factor(cm.f[[i]], 3) : ‘<’ not meaningful for factors

# just the gene names are included and the original data in "a" is not included.

**2.6k**• written 12 months ago by friasoler •

**20**

Can you provide a small, reproducible example?

However, it looks like you have 2 problems:

1) In a dataframe of X rows, you are trying to add a column with Y elements, where X<>Y

2) Your data.frame has values stored as factors, while you are probably using them as numeric.

2.6kThanks Fabio, here an example of my CM matrix:

20