- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to display x-bar in base R plot?
To display x-bar in base R plot, we can use text function and define the bar with bar function inside expression function.
For example, if we have a vector called x that contains first ten numbers (1 to 10) then we can display it’s mean inside the base R plot by using the command given below −
text(0.97,5.5,expression(bar("x")))
Check out the examples given below to understand how it works.
Example 1
Use the code given below to display x-bar in base R plot −
plot(mean(1:100)) text(0.97,50.5,expression(bar("x")))
Output
If you execute the above given snippet, it generates the following Output −
Example 2
Use the code given below to display x-bar in base R plot −
plot(mean(rnorm(10000,5,2))) text(0.97,5.05,expression(bar("x")))
Output
If you execute the above given snippet, it generates the following Output −
Example 3
Use the code given below to display x-bar in base R plot −
plot(mean(rpois(10000,10))) text(0.97,10.05,expression(bar("x")))
Output
If you execute the above given snippet, it generates the following Output −
- Related Articles
- How to display X-axis labels inside the plot in base R?
- How to display superscript for X-axis title in base R plot?
- How to display X-axis labels with dash in base R plot?
- How to create empty bar plot in base R?
- How to display fraction in base R plot?
- How to display raise to the power on X-axis in base R plot?
- How to display infinity symbol in base R plot?
- How to manually set the color of each bar in base R bar plot?
- How to display base R plot axes titles in italics?
- How to display text in base R plot with outline?
- How to display mean with underline in base R plot?
- How to display square root sign in base R plot?
- How to create horizontal lines for each bar in a bar plot of base R?
- How to display text in base R plot with 180 degrees rotation?
- How to display star/asterisk sign (*) inside a base R plot?
