-1

I want to calculate number of movies in each category in base . Sample data is below :-

head(movies);
Rating Runtime Movieid
     R       50      1
    PG      100      2
     R       20      3
     G       10      4
    PG       16      5


plot(x=movies$V1,xlab="Rating",ylab=" of movies")

I get the graph using the above command.But i want to know how R plots the graph automatically on Y axis?

Fangming
  • 24,551
  • 6
  • 100
  • 90
Dravid
  • 11
  • 1
  • 1
    Please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example): input, expected output. – Prradep Jul 16 '17 at 11:25
  • 1
    Title and question in the description do not seem to be same? – Prradep Jul 16 '17 at 11:33
  • Hello @Prradep Rating Runtime Movieid R 50 1 PG 100 2 R 20 3 G 10 4 PG 16 5 This is the sample data.I want to calculate number of movies in each category – Dravid Jul 16 '17 at 11:42

1 Answers1

0

try with table() function. For example:

data(iris)
table(iris$Species)

Hope that help ;)

B.Gees
  • 1,125
  • 2
  • 11
  • 28
  • Sorry i didn't get you .Plus i have chnaged my sample data for simplification. – Dravid Jul 16 '17 at 11:48
  • i got the necessary result by using below command plot(x=movies$V1,xlab="Rating",ylab=" of movies") But i want to know how R calculates the Y axis? – Dravid Jul 16 '17 at 11:50
  • To know how `R` calculates anything, the best source is, well, the source code. In your case it seems you're after function `plot.table` in file src/library/graphics/R/plot.R – Rui Barradas Jul 16 '17 at 12:02