How to create a histogram without bins in base R?

R ProgrammingServer Side ProgrammingProgramming

We can set type argument to s in plot function to create a histogram without bins but first we need to create the histogram and store it in an object. For example, if we have a vector say x then the histogram of x can be stored in an object called p then we can use the command plot(c(p$counts,0),type="s") to create the histogram without bins as shown in the below example.

Example

> x<-rnorm(100)
> p<-hist(x)

Output

Example

> plot(c(p$counts,0),type="s")

Output

raja
Published on 06-Mar-2021 05:08:26
Advertisements