Help interpreting dimnames()[[1]][1]

I am working with the following command:

VlnPlot(, features = dimnames(conserved.markers.0)[[1]][1],pt.size=0)

I will need to adapt this command appropriately to generate the same type of violin plots for multiple objects. I don't quite understand the format of the dimnames(conserved.markers.0)[[1]][1] portion however. I know that the [[1]] part indicates to use the first row of the conserved.markers.0 object, but I'm not sure what the second 1 in brackets references.

Can someone please help me to understand? Thanks!

dimnames() returns a list. The indexing of [[1]] returns the first element of the list. That first element is a vector. Appending [1] to the first element of the list returns the first element of the vector that is the first element of the list. Here is an example. dimnames(MAT) returns a list. The first element of that list is the vector c("A","B","C"). The first element of that vector is "A".

MAT <- matrix(1:9,nrow=3,dimnames = list(c("A","B","C"),c("Q","W","E")))
  Q W E
A 1 4 7
B 2 5 8
C 3 6 9
[1] "A" "B" "C"

[1] "Q" "W" "E"

[1] "A"

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.