Search code examples
rdatecountplotaxes

Interchange the axes in R and count number of dates in a list in R


I am trying to use the plot function in R. I would like to have the values which are represented on the X-axis to be on the Y-axis and vice-versa.

Another question I have is I have a list of dates with me. I want to know how many instances of a particular date are there in the list.

How should I go about doing this ?


Solution

  • 1)

     plot(y, x)  # I'm guessing there is something you are not telling us.
    

    In the situation where you are using the default indexing with a single "y" vector the answer would be:

     plot( x=y, y= 1:length(y) )  
        # This was reversed when it was posted as an edit-response to the comment.
    

    2)

     table(dates)[as.Date("YYYY-MM-DD")] # with the obvious substitutions