How to add rownames without dimensions in R
•
Java
> Cases <- c(4,46,98,115,88,34)
> Cases <- c(4,46,98,115,88,34) > Cases [1] 4 46 98 115 88 34 > str(Cases) num [1:6] 4 46 98 115 88 34
I want to name the row "total. Cases", and I try to set the error of rownames without dimensions Look at the expected output as follows
total.cases 4 46 98 115 88 34
Solution
Your problem is that the case you define is an atomic vector There is no concept of rows or columns
I think you might want a list
Cases <- list(total.cases = c(4,34)) Cases ## $total.cases ## [1] 4 46 98 115 88 34 str(Cases) ## List of 1 ## $total.cases: num [1:6] 4 46 98 115 88 34
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码