R extract rows and columns of table

4127 views r

In R, I have a list A of size M by N, and each column has a header. I want to do statistics on the rows and columns.

The first row A[1, n] for n = 1, 2, 3, ..., N consists of integers.

I would like to find the average of A[1,n] in this range. Thus, I let B = A[1, ] and calculate mean(B). However, the values are not numeric. They still contain the headers.

B[1] is a list, but B[1,1] is the proper value. So, I calculate mean(B[1,]), but still it says the values are not numeric.

Also, sum(B) works fine, but not mean(B).

I cant find a way to remove the headers from B. I have a simple table containing data. How can I extract its columns and rows without worrying about headers?

answered question

You mean A is a list of matrices?

I have typeof(A) : "list" and dim(A) : 192 74

What do you have with typeof(A[[1]])?

typeof(A[[1]]) : "integer", I do not understand. If I enter A[[1]] to console I get a list of strings.

I have a table A consisting of integers. How do I find the average of the k column?

You should show us your data (especially the list A). Use dput(A). Note that A[[1]] returns the first element of your list A

1 Answer


would this work?


posted this

Have an answer?


Please login first before posting an answer.