<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tips on Stats and R</title>
    <link>https://statsandr.com/tags/tips/</link>
    <description>Recent content in Tips on Stats and R</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 24 Mar 2023 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://statsandr.com/tags/tips/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>10 potential career options with a degree in statistics</title>
      <link>https://statsandr.com/blog/10-potential-career-options-with-a-degree-in-statistics/</link>
      <pubDate>Fri, 24 Mar 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/10-potential-career-options-with-a-degree-in-statistics/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#what-types-of-jobs-are-available&#34; id=&#34;toc-what-types-of-jobs-are-available&#34;&gt;What types of jobs are available?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#statistician&#34; id=&#34;toc-statistician&#34;&gt;Statistician&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data-scientist-databusiness-analyst-data-engineer-or-machine-learning-engineer&#34; id=&#34;toc-data-scientist-databusiness-analyst-data-engineer-or-machine-learning-engineer&#34;&gt;Data scientist, data/business analyst, data engineer or machine learning engineer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#actuary-or-actuarial-analyst&#34; id=&#34;toc-actuary-or-actuarial-analyst&#34;&gt;Actuary or actuarial analyst&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#financial-risk-analyst-investment-analyst-financial-trader-financial-manager-or-quantitative-analyst&#34; id=&#34;toc-financial-risk-analyst-investment-analyst-financial-trader-financial-manager-or-quantitative-analyst&#34;&gt;Financial (risk) analyst, investment analyst, financial trader, financial manager or quantitative analyst&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#business-intelligence-analyst&#34; id=&#34;toc-business-intelligence-analyst&#34;&gt;Business intelligence analyst&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#operational-researcher-or-quality-control-analyst&#34; id=&#34;toc-operational-researcher-or-quality-control-analyst&#34;&gt;Operational researcher or quality control analyst&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#market-or-survey-researcher&#34; id=&#34;toc-market-or-survey-researcher&#34;&gt;Market or survey researcher&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#economist-or-econometrician&#34; id=&#34;toc-economist-or-econometrician&#34;&gt;Economist or econometrician&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#freelance-consultant&#34; id=&#34;toc-freelance-consultant&#34;&gt;(Freelance) consultant&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#teacher&#34; id=&#34;toc-teacher&#34;&gt;Teacher&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#phd-student&#34; id=&#34;toc-phd-student&#34;&gt;PhD student&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/career-options-with-degree-in-statistics.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This post has been written in collaboration with Daniel Williams.&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;A reader recently contacted me because he was hesitating between starting his studies in statistics or economics. I studied economics and I am now doing a &lt;a href=&#34;https://antoinesoetewey.com/research/&#34;&gt;PhD in statistics&lt;/a&gt;, so he reached out to me to know what I thought about these two fields, and in particular, what were my feelings about the career opportunities available with these two degrees.&lt;/p&gt;
&lt;p&gt;Before considering pursuing a graduate degree, it is important to have a clear understanding of the skills you will develop and the career opportunities that will become available to you.&lt;/p&gt;
&lt;p&gt;I leave it to those who have studied economics and work in this field to discuss career opportunities with a degree in economics. In this post, I will focus on the career options that are available for people with a degree in statistics.&lt;/p&gt;
&lt;p&gt;Bear in mind that there are many professional opportunities with a degree in statistics. Indeed, statistical expertise is highly sought after in a wide range of computing and data analysis job roles; as soon as there are data, statistical expertise is required. Moreover, there are almost as many different jobs as people. Therefore, the list of jobs below is non-exhaustive and you may &lt;a href=&#34;https://jooble.org/&#34; target=&#34;_blank&#34;&gt;get a job&lt;/a&gt; that is not mentioned in this list. However, I hope it will still give you an overview of what you can expect after your studies.&lt;/p&gt;
&lt;p&gt;If you believe I missed one—if you studied statistics and your job is not mentioned here for example, feel free to leave a comment at the end of the post.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-types-of-jobs-are-available&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What types of jobs are available?&lt;/h1&gt;
&lt;p&gt;If you are skilled in &lt;a href=&#34;https://statsandr.com/tags/statistics/&#34;&gt;statistics&lt;/a&gt; and &lt;a href=&#34;https://statsandr.com/tags/r/&#34;&gt;R programming&lt;/a&gt;, there are a plethora of job opportunities available to you.&lt;/p&gt;
&lt;p&gt;Some of the roles you can pursue include:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Statistician: Collect, analyze and interpret data in a wide range of fields, including economics, finance, marketing, social and medical sciences.&lt;/li&gt;
&lt;li&gt;Data scientist, data/business analyst, data engineer or machine learning engineer: Collect, analyze and interpret large and complex data sets using statistical and machine learning techniques to gain insights and inform decision-making to business and organizations. Mastering these techniques is key to the role, and in industry, turning statistical models into production-ready solutions often requires collaboration with a professional &lt;a href=&#34;https://www.uptech.team/services/machine-learning-development-services&#34;&gt;machine learning development company&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Actuary or actuarial analyst: Use statistical modeling to assess risk and uncertainty, and to create financial projections for insurance and investment companies.&lt;/li&gt;
&lt;li&gt;Financial (risk) analyst, investment analyst, financial trader, financial manager or quantitative analyst: Use statistical and mathematical modeling to analyze financial and market data, identify and evaluate risks for investment and trading decisions.&lt;/li&gt;
&lt;li&gt;Business intelligence analyst: Use data analysis and visualization tools to create reports and dashboards that help businesses make informed decisions.&lt;/li&gt;
&lt;li&gt;Operational researcher or quality control analyst: Use mathematical and statistical techniques to monitor and optimize the quality of products and processes in manufacturing.&lt;/li&gt;
&lt;li&gt;Market or survey researcher: Conduct research and surveys, gather and analyze data to help businesses develop and improve their marketing strategies.&lt;/li&gt;
&lt;li&gt;Economist or econometrician: Use statistical methods to analyze (socio)economic data and develop economic models to inform policy and decision-making.&lt;/li&gt;
&lt;li&gt;Teacher: Facilitate learning and provide guidance to students in order to help them acquire knowledge, skills, and values that will prepare them for their future.&lt;/li&gt;
&lt;li&gt;(Freelance) consultant: Provide statistical consulting services to clients, helping them solve problems using a combination of statistical methods and business expertise.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the following sections, we delve deeper into the aforementioned job roles and outline the qualifications expected of prospective candidates.&lt;/p&gt;
&lt;div id=&#34;statistician&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Statistician&lt;/h2&gt;
&lt;p&gt;As a graduate in statistics, you have the potential to land a coveted statistician’s job in a reputable private company or public agency. These types of roles typically involve analyzing and assessing data, and utilizing various tools and software to manage data effectively.&lt;/p&gt;
&lt;p&gt;With data proliferation and more and more companies/organizations that rely heavily on data analysis, your skills will be valuable in a broad range of fields and industries. Being a statistician means that you could work for instance as an:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;environmental statistician: analyze data related to environmental issues, such as climate change and pollution, to inform policy and decision-making,&lt;/li&gt;
&lt;li&gt;sports statistician: analyze data related to sports performance, such as player statistics and game outcomes, to inform coaching and strategy decisions,&lt;/li&gt;
&lt;li&gt;government statistician: collect, analyze and interpret data for government agencies and public departments to guide policymakers in their decisions,&lt;/li&gt;
&lt;li&gt;biostatistician: use statistical methods and data analysis techniques to study and interpret medical and (public) health-related data,&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Statistical expertise is required wherever there is data, so feel free to specialize in the field or industry you care about most!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data-scientist-databusiness-analyst-data-engineer-or-machine-learning-engineer&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data scientist, data/business analyst, data engineer or machine learning engineer&lt;/h2&gt;
&lt;p&gt;As a relatively new job role in various organizations, data scientists and data analysts are experts in manipulating, analyzing and interpreting data. These roles typically require the analysis of large datasets using statistical methods to assist organizations in making more informed business decisions. These professionals dive into unstructured information to uncover valuable insights for businesses, ultimately increasing their revenue.&lt;/p&gt;
&lt;p&gt;To pursue this career, one would usually require a graduate degree in science, statistics, or mathematics, as well as training in data mining. It is also expected that you are familiar with one or several programming languages such as R, Python or SAS.&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Statistics graduates can also pursue their career as machine learning engineers. Job roles in this field typically involve conducting experiments and implementing machine learning algorithms. Consequently, many organizations hire these professionals to create a wide range of AI products. To do so, they must possess strong programming and statistical skills. Data science and software engineering knowledge are also beneficial.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;actuary-or-actuarial-analyst&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Actuary or actuarial analyst&lt;/h2&gt;
&lt;p&gt;Actuaries usually apply statistical modeling tools on data related to retirement, financial/insurance products, accidents or mortality. As an actuary, one would be responsible for analyzing financial costs and risks. It means examining uncertainties associated with investments and other financial products and making predictions about the risks involved in a particular venture.&lt;/p&gt;
&lt;p&gt;Actuaries are also in charge of writing insurance proposals, determining policy terms, and calculating premiums for different products, among other responsibilities. You may also play a vital role in deciding whether to accept or reject insurance applications by evaluating their risks. You will draw upon your statistical, actuarial, and background information to accomplish these tasks.&lt;/p&gt;
&lt;p&gt;Typically, actuaries have a range of financial companies as clients, and they must identify potential risks and recommend compensation strategies accordingly. It means that their work is closely related to insurance products, as they must assess the likelihood of certain events occurring and the resulting financial impact.&lt;/p&gt;
&lt;p&gt;Typically, those who pursue this role hold a degree in actuarial science, mathematics or statistics, and are trained in statistical analysis tools and software. Note that each country has its own specific accreditation related to this profession.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;financial-risk-analyst-investment-analyst-financial-trader-financial-manager-or-quantitative-analyst&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Financial (risk) analyst, investment analyst, financial trader, financial manager or quantitative analyst&lt;/h2&gt;
&lt;p&gt;As a financial analyst, one is required to gather data from various sources, organize and analyze historical results, and make projections and forecasts. Furthermore, in addition to analyzing data, their role often involves reporting financial results to the board of directors/management to help them in setting the overall strategy and direction of the company.&lt;/p&gt;
&lt;p&gt;Investment analysts are experts in evaluating different financial assets such as stocks, securities, and bonds. They do not stop there, though. They also conduct research and make crucial decisions about purchasing business financials.&lt;/p&gt;
&lt;p&gt;As a financial trader, you will have a keen understanding of financial markets and the ability to execute trades (i.e., buy or sell shares, bonds, and other assets) on behalf of clients. Note that there are also various sub-roles to explore within this job segment.&lt;/p&gt;
&lt;p&gt;Financial managers combine their passion for finance with their love of numbers and statistics. Financial managers are experts at creating and interpreting complex financial reports, providing invaluable insights into a company’s financial health. They can also advise management on investment strategies and assist with vital financial decisions. With their keen analytical skills, financial managers keep a watchful eye on daily financial activities and help ensure a company’s long-term success.&lt;/p&gt;
&lt;p&gt;These skills are in high demand in financial organizations, such as banks, actuarial firms, insurance companies (commercial insurance, reinsurance, general insurance, life insurance, car insurance, etc.), and other similar establishments.&lt;/p&gt;
&lt;p&gt;The educational background of these professionals is diverse. Graduates in finance, mathematics, and statistics all bring unique perspectives to the table.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;business-intelligence-analyst&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Business intelligence analyst&lt;/h2&gt;
&lt;p&gt;A business intelligence (BI) analyst is responsible for collecting, organizing, analyzing, and presenting large amounts of data from various sources such as databases, spreadsheets, and software applications. They use various tools and techniques to identify trends, patterns, and relationships in the data to create reports, dashboards, and visualizations to communicate their findings to stakeholders. They may also be responsible for monitoring business performance metrics and KPIs, identifying areas for improvement, and making recommendations to optimize business operations.&lt;/p&gt;
&lt;p&gt;Additionally, BI analysts may also be involved in the development and implementation of data-driven software applications, such as business intelligence platforms and data warehouses, to improve data accessibility, accuracy, and efficiency. Overall, the role of a BI analyst is crucial in filling the gap between business analysts and the IT team.&lt;/p&gt;
&lt;p&gt;The most common software tools and platforms used by BI analysts are, at the time of writing this post, &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;R Shiny&lt;/a&gt;, Microsoft Power BI, Tableau, QlikView and SAS BI.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;operational-researcher-or-quality-control-analyst&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Operational researcher or quality control analyst&lt;/h2&gt;
&lt;p&gt;Operational researchers are responsible for using mathematical and analytical methods to solve complex problems and optimize business operations. They collect and analyze data, develop models and algorithms, test and validate them, and make recommendations for improvements.&lt;/p&gt;
&lt;p&gt;On the other hand, quality control analysts are responsible for ensuring that products or services meet the required standards of quality. They monitor and analyze product or service performance, identify areas for improvement, and develop strategies for maintaining or improving quality. They may also work with production teams to develop and implement quality control processes and procedures.&lt;/p&gt;
&lt;p&gt;While operational researchers focus on optimizing processes and systems, quality control analysts focus on ensuring that the end product or service meets the required quality standards. Both roles require analytical skills and the ability to work with data, but operational researchers focus more on mathematical modeling and optimization, while quality control analysts focus more on monitoring and improving quality.&lt;/p&gt;
&lt;p&gt;Individuals who pursue job roles of this nature typically possess strong mathematical abilities, often having graduated with degrees in statistics or mathematics. They are trained to analyze vast amounts of data and are well-versed in various analytical tools, such as simulation, mathematical modeling, and data science.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;market-or-survey-researcher&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Market or survey researcher&lt;/h2&gt;
&lt;p&gt;Market or survey researchers are professionals who specialize in conducting research to gather information about consumer behavior and preferences, market trends, and competitive landscapes. They use various research methods and techniques to collect and analyze data, and provide insights and recommendations to businesses and organizations.&lt;/p&gt;
&lt;p&gt;Market research professionals typically work with marketing agencies on various projects for clients across different sectors. In addition to a degree in statistics, knowledge in marketing and familiarity with the industry is beneficial.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;economist-or-econometrician&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Economist or econometrician&lt;/h2&gt;
&lt;p&gt;Economists and econometricians study and analyze economic systems, markets, and policies using quantitative methods and models. They collect and analyze data, develop economic models, conduct economic analysis, provide recommendations to policymakers and organizations, and communicate their findings to a variety of audiences. Their role is to inform economic policies and decisions in both public and private sectors.&lt;/p&gt;
&lt;p&gt;If you have a background in statistics in addition to knowledge in economics, there is a whole world of vocational opportunities in economics just waiting for you. Indeed, armed with the ability to appropriately analyze data (thanks to your background in statistics) and the ability to understand (socio)economic issues and financial data, you will be a hot commodity as an advisor to governments and businesses on all economic decisions.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;freelance-consultant&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;(Freelance) consultant&lt;/h2&gt;
&lt;p&gt;From a general point of view, a consultant (or freelance consultant) is a professional who provides expert advice and guidance to organizations or individuals on a contractual basis. They analyze problems, develop solutions, and provide recommendations to clients in a specific field or industry.&lt;/p&gt;
&lt;p&gt;A consultant specializing in statistics provides expert advice and guidance to organizations or individuals on statistical analysis, data management, and modeling. They use statistical tools and techniques to analyze and interpret complex data, and provide insights and recommendations based on their analyses. The role of a statistical consultant may include identifying research questions, designing studies, collecting and managing data, analyzing data using appropriate statistical methods, interpreting results, and presenting findings to clients. They may also assist clients with the implementation of statistical methods and tools, provide training on statistical software and techniques, and develop custom statistical models for specific applications.&lt;/p&gt;
&lt;p&gt;As a side note, note that many consultants in statistics provide their service as data visualization consultants. These consultants are responsible for helping clients to effectively communicate complex data through the creation of clear and visually appealing graphics, charts, and other forms of visual representation that can aid in decision-making and enhance understanding.&lt;/p&gt;
&lt;p&gt;You can either be a consultant in a consulting firm, or a freelance consultant. If you choose to be a freelance consultant, you can more easily select the projects you want to work on and the industry you want to focus on, but you will also need to take care of all the administrative tasks such as finding and building relationships with clients, do your bookkeeping, etc.&lt;/p&gt;
&lt;p&gt;If you are not ready to be a full-time freelance consultant but would like to experience a taste of it, you can always keep your primary job and accept a couple of side projects. This is known as a side hustle. This way, you will gradually build your portfolio and create relationships with clients, all that with the advantage of keeping a safe source of income. This is what I am doing with &lt;a href=&#34;https://datanalyze.be/&#34;&gt;datanalyze.be&lt;/a&gt;, and I recommend it to anyone who is considering the option of being a freelance in the future.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;teacher&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Teacher&lt;/h2&gt;
&lt;p&gt;If you care about education, you like to transmit your knowledge and explain complex things in a simple manner, you may be interested in being a teacher in high school or a university professor. With a degree in statistics, you may be eligible to teach different subjects such as mathematics, statistics, physics, or science in general. Your ultimate goal is to educate and inspire students to develop an understanding and appreciation of these subjects (which are often not well appreciated by students), as well as to develop critical thinking skills, problem-solving abilities, and scientific literacy.&lt;/p&gt;
&lt;p&gt;Like actuaries, note that each country has its own specific accreditation related to this profession.&lt;/p&gt;
&lt;p&gt;To know whether this job suits you, you can start by being a private tutor. This way, you will experience what the job is like and you will be more able to tell whether it is the direction you want to take.&lt;/p&gt;
&lt;p&gt;To become a university professor, note that a PhD (and even sometimes a postdoc) is usually required. This brings me to the last career option I would like to mention: a PhD.&lt;/p&gt;
&lt;p&gt;I do not include a PhD in the list of the 10 potential career options because it is more seen as an additional degree rather than a job, and even for those who see it as a job, it is a temporary one. However, I would still like to mention it because it is worth considering with a degree in statistics (I am of course biased, but my biased opinion may be of interest to some readers).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;phd-student&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;PhD student&lt;/h2&gt;
&lt;p&gt;For those who enjoy academic research, pursuing a career as a researcher after taking a statistics degree may be a worthwhile consideration. Typically, pursuing a PhD in statistics involves working in close collaboration with one or two university professors (your supervisors) on a specific topic.&lt;/p&gt;
&lt;p&gt;I cannot speak for all PhD students, but I can speak from my experience. It involves conducting original research in statistical theory and methodology, developing new statistical models and methods, and applying statistical techniques to solve real-world problems or to advance knowledge in a specific field. My research focuses on applying biostatistical procedures to cancer patients, so it is a rather applied PhD, but many of my colleagues work on a more theoretical subject.&lt;/p&gt;
&lt;p&gt;We also sometimes participate in academic conferences, present our research findings, and collaborate with other researchers in our field of research.&lt;/p&gt;
&lt;p&gt;After completing our PhD, we can continue to evolve in academia (and become a university professor for instance), or decide to work in a private or public research organization. Because professionals with a PhD in statistics become experts in statistical theory and methodology, commercial and public organizations often seek such profiles.&lt;/p&gt;
&lt;p&gt;The length of a PhD depends on the country and the type of contract. If you are interested to know more, feel free to contact me, I might be able to help you (at least with how it goes in Belgium). Otherwise, the program director at your university will definitely be able to answer the questions you may have.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;As you have seen, with a degree in statistics and knowledge in programming, you will be able to pursue positions at various companies or organizations. You can also always enhance your qualifications with additional courses if you feel that you miss some skills that are required for the job you want to apply to.&lt;/p&gt;
&lt;p&gt;Statisticians are in demand in government departments across many regions and sectors. Actuarial firms, banks, investment firms, and market research organizations are also great potential employers.
The demand for statistical and analytical skills is on the rise across various fields. Job seekers with these skills are particularly needed. However, it is becoming increasingly common for these positions to require specialized education and training. For example, if you have a degree in statistics, pursuing a finance specialization could open doors to opportunities in banking, investment, accountancy, or insurance firms. Last but not least, those passionate about solving complex problems may find roles as researchers (within or outside academia) appealing.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article helped you to get an overview of the career options you have with a degree in statistics.&lt;/p&gt;
&lt;p&gt;If you are looking for a job, I wish you the best of luck in finding your dream job! Remember that you will find a variety of job openings in academic, research-oriented, and analytical fields on online and offline job boards. Moreover, do not underestimate the power of friends, colleagues and family: make sure to network with people in your field to increase the chance of getting a job.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;There are many programming languages for data analysis, and it will certainly continue to evolve in the future. The most common ones at the time of writing this post are: R, Python, SAS, Jamovi, SPSS, JMP, Stata and Matlab. Depending on the role and the organization, more or less programming skills will be required.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Top 10 errors in R and how to fix them</title>
      <link>https://statsandr.com/blog/top-10-errors-in-r/</link>
      <pubDate>Tue, 07 Feb 2023 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/top-10-errors-in-r/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#unmatched-parentheses-curly-braces-square-brackets-or-quotes&#34; id=&#34;toc-unmatched-parentheses-curly-braces-square-brackets-or-quotes&#34;&gt;1. Unmatched parentheses, curly braces, square brackets or quotes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#using-a-function-that-is-not-installed-or-loaded&#34; id=&#34;toc-using-a-function-that-is-not-installed-or-loaded&#34;&gt;2. Using a function that is not installed or loaded&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#typos-in-function-variable-dataset-object-or-package-names&#34; id=&#34;toc-typos-in-function-variable-dataset-object-or-package-names&#34;&gt;3. Typos in function, variable, dataset, object or package names&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#missing-incorrect-or-misspelled-arguments-in-functions&#34; id=&#34;toc-missing-incorrect-or-misspelled-arguments-in-functions&#34;&gt;4. Missing, incorrect or misspelled arguments in functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#wrong-inappropriate-or-inconsistent-data-types&#34; id=&#34;toc-wrong-inappropriate-or-inconsistent-data-types&#34;&gt;5. Wrong, inappropriate or inconsistent data types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#forgetting-the-sign-in-ggplot2&#34; id=&#34;toc-forgetting-the-sign-in-ggplot2&#34;&gt;6. Forgetting the + sign in ggplot2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#misunderstanding-between-and&#34; id=&#34;toc-misunderstanding-between-and&#34;&gt;7. Misunderstanding between = and ==&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#undefined-columns-selected&#34; id=&#34;toc-undefined-columns-selected&#34;&gt;8. Undefined columns selected&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#problem-when-importing-or-using-the-wrong-data-file&#34; id=&#34;toc-problem-when-importing-or-using-the-wrong-data-file&#34;&gt;9. Problem when importing or using the wrong data file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#problem-when-using-the-operator&#34; id=&#34;toc-problem-when-using-the-operator&#34;&gt;10. Problem when using the $ operator&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#operator-is-invalid-for-atomic-vectors&#34; id=&#34;toc-operator-is-invalid-for-atomic-vectors&#34;&gt;$ operator is invalid for atomic vectors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#object-of-type-closure-is-not-subsettable&#34; id=&#34;toc-object-of-type-closure-is-not-subsettable&#34;&gt;object of type ‘closure’ is not subsettable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#warnings&#34; id=&#34;toc-warnings&#34;&gt;Warnings&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#nas-introduced-by-coercion&#34; id=&#34;toc-nas-introduced-by-coercion&#34;&gt;NAs introduced by coercion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#removed-rows-containing-non-finite-values-stat_bin&#34; id=&#34;toc-removed-rows-containing-non-finite-values-stat_bin&#34;&gt;Removed … rows containing non-finite values (stat_bin())&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/top-10-errors-in-r.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;If you are just starting with R, you will often encounter errors in your code which prevent it to run. I remember when I was just starting to use R, errors in my code were so frequent that I almost gave up learning this programming language. I even recall that I went back to Excel a few times to finish my analyses because I could not find what was causing the issue.&lt;/p&gt;
&lt;p&gt;Fortunately, I forced myself to continue despite the difficulties of the beginning. And today, even if I still encounter errors almost every time I write R code, with experience and practice, it takes less and less time to fix them. If you are also struggling at the beginning, rest assured, it is normal: everyone experiences some frustration when learning a new programming language (and this is the case not only with R).&lt;/p&gt;
&lt;p&gt;In this post, I highlight the &lt;strong&gt;10 most common errors in R and how to fix them&lt;/strong&gt;. Of course, errors depend on your code and your analyses, so it is impossible to cover all of them (and Google does it way better than me). However, I would like to focus on some common syntax mistakes that are frequent when learning R, and which can sometimes take a long time to be fixed before realizing that the solution is right in front of our eyes.&lt;/p&gt;
&lt;p&gt;This collection is based on my personal experience and the errors encountered by my students when I &lt;a href=&#34;https://antoinesoetewey.com/teaching/&#34;&gt;teach&lt;/a&gt; R. This list being non-exhaustive, feel free to comment (at the end of the post) with errors you often face when using R.&lt;/p&gt;
&lt;p&gt;For each error, I provide examples and solutions to fix them. I also mention a couple of warnings (which are, strictly speaking, not errors) at the end of the post.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;unmatched-parentheses-curly-braces-square-brackets-or-quotes&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;1. Unmatched parentheses, curly braces, square brackets or quotes&lt;/h1&gt;
&lt;p&gt;One rather trivial but still quite frequent error is a missing parenthesis, curly brace, square bracket or quotation mark.&lt;/p&gt;
&lt;p&gt;This type of error is applicable to many programming languages. In R, for instance:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## missing a closing parenthesis:
mean(c(1, 7, 13)
     
## missing a curly brace before &amp;quot;else&amp;quot;:
x &amp;lt;- 7 
if(x &amp;gt; 10) {
  print(&amp;quot;x &amp;gt; 10&amp;quot;)
 else {
  print(&amp;quot;x &amp;lt;= 10&amp;quot;)
 }
  
## missing a square bracket:
summary(ggplot2::diamonds[, &amp;quot;price&amp;quot;)

## missing a closing quote in 2nd element:
grp &amp;lt;- c(&amp;quot;Group 1&amp;quot;, &amp;quot;Group 2) 
grp&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These errors are easy to detect when the code is basic, but can become much harder to spot with a more complex code, for instance:&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;for (i in y) {
  for (j in x) {
    p &amp;lt;- ggboxplot(dat,
      x = colnames(dat[j]), y = colnames(dat[i]),
      color = colnames(dat[j]),
      legend = &amp;quot;none&amp;quot;,
      palette = &amp;quot;npg&amp;quot;,
      add = &amp;quot;jitter&amp;quot;
    )
    print(
      p + stat_compare_means(aes(label = paste0(..method.., &amp;quot;, p-value = &amp;quot;, ..p.format..),
        method = method1, label.y = max(dat[, i], na.rm = TRUE)
      )
      + stat_compare_means(comparisons = my_comparisons, method = method2, label = &amp;quot;p.format&amp;quot;)
    )
  }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thankfully, if you use RStudio,&lt;a href=&#34;#fn2&#34; class=&#34;footnote-ref&#34; id=&#34;fnref2&#34;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt; a closing parenthesis, curly brace, square bracket or quotation mark will automatically be written when you open one.&lt;/p&gt;
&lt;p&gt;Bear in mind that when installing a package, you &lt;em&gt;must&lt;/em&gt; use (single or double) quotation marks around the package’s name:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct:
install.packages(ggplot2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in install.packages : object &amp;#39;ggplot2&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Instead, write one of the two following options:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;ggplot2&amp;quot;)

# install.packages(&amp;#39;ggplot2&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;solution&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;The solution of course is to simply match all opening parentheses, curly braces, square brackets and quotation marks with their closing counterparts:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(c(1, 7, 13))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- 7
if (x &amp;gt; 10) {
  print(&amp;quot;x &amp;gt; 10&amp;quot;)
} else {
  print(&amp;quot;x &amp;lt;= 10&amp;quot;)
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;x &amp;lt;= 10&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(ggplot2::diamonds[, &amp;quot;price&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      price      
##  Min.   :  326  
##  1st Qu.:  950  
##  Median : 2401  
##  Mean   : 3933  
##  3rd Qu.: 5324  
##  Max.   :18823&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;grp &amp;lt;- c(&amp;quot;Group 1&amp;quot;, &amp;quot;Group 2&amp;quot;)
grp&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;Group 1&amp;quot; &amp;quot;Group 2&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also, make sure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;to correctly place commas:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct (misplaced comma):
c(&amp;quot;Group 1,&amp;quot; &amp;quot;Group 2&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error: unexpected string constant in &amp;quot;c(&amp;quot;Group 1,&amp;quot; &amp;quot;Group 2&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## also NOT correct (missing comma):
c(&amp;quot;Group 1&amp;quot; &amp;quot;Group 2&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error: unexpected string constant in &amp;quot;c(&amp;quot;Group 1&amp;quot; &amp;quot;Group 2&amp;quot;&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## correct:
c(&amp;quot;Group 1&amp;quot;, &amp;quot;Group 2&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;you do not mix single and double quotation marks for the same element:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct:
c(&amp;quot;Group 1&amp;#39;)

## correct:
c(&amp;quot;Group 1&amp;quot;)

## also correct:
c(&amp;#39;Group 1&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that &lt;code&gt;c(&#39;Group 1&#39;, &#34;Group 2&#34;)&lt;/code&gt; does not throw an error but for consistency, it is not recommended to mix single and double quotes within the same vector.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;using-a-function-that-is-not-installed-or-loaded&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;2. Using a function that is not installed or loaded&lt;/h1&gt;
&lt;p&gt;If you encounter the following error: “Error in … : could not find function ‘…’”, for example:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/could-not-find-function-R.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;it means you are trying to use a function belonging to a package which is not yet installed or loaded.&lt;/p&gt;
&lt;div id=&#34;solution-1&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;To solve this error, you have to install the package (if it is not installed yet) and load it with the &lt;code&gt;install.packages()&lt;/code&gt; and &lt;code&gt;library()&lt;/code&gt; functions, respectively:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## install package:
install.packages(&amp;quot;ggplot2&amp;quot;)

## load package:
library(ggplot2)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are not sure about the usage of these two functions, see more details about &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;installing and loading a package in R&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;typos-in-function-variable-dataset-object-or-package-names&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;3. Typos in function, variable, dataset, object or package names&lt;/h1&gt;
&lt;p&gt;Another common mistake is to misspell a function, a variable, a dataset, an object or a package’s name, for example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in function name:
maen(c(1, 7, 13))&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in maen(c(1, 7, 13)) : could not find function &amp;quot;maen&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in variable name:
summary(ggplot2::diamonds[, &amp;quot;detph&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error: Column `detph` doesn&amp;#39;t exist&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in dataset name:
data &amp;lt;- data.frame(
  x = rnorm(10),
  y = rnorm(10)
)
summary(dta[, 2])&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in summary(dta[, 2]) : object &amp;#39;dta&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in object name:
test &amp;lt;- c(1, 7, 13)
mean(tset)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in mean(tset) : object &amp;#39;tset&amp;#39; not found&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## typo in package name:
library(&amp;quot;tydiverse&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in library(&amp;quot;tydiverse&amp;quot;) : there is no package called ‘tydiverse’&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;solution-2&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;Make sure that you correctly spell all your functions, variables, datasets, objects and packages:&lt;/p&gt;
&lt;p&gt;Note that &lt;strong&gt;R is case sensitive&lt;/strong&gt;; &lt;code&gt;mean()&lt;/code&gt; is considered different than &lt;code&gt;Mean()&lt;/code&gt; for R!&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(c(1, 7, 13))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(ggplot2::diamonds[, &amp;quot;depth&amp;quot;])&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      depth      
##  Min.   :43.00  
##  1st Qu.:61.00  
##  Median :61.80  
##  Mean   :61.75  
##  3rd Qu.:62.50  
##  Max.   :79.00&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data &amp;lt;- data.frame(
  x = rnorm(10),
  y = rnorm(10)
)
data[, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1.3048697  2.2866454 -1.3888607 -0.2787888 -0.1333213  0.6359504
##  [7] -0.2842529 -2.6564554 -2.4404669  1.3201133&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;test &amp;lt;- c(1, 7, 13)
mean(test)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (&amp;lt;http://conflicted.r-lib.org/&amp;gt;) to force all conflicts to become errors&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are sure that you correctly spelled an object, a function or a dataset but you still have an error stating that “object ‘…’ is not found”, make sure that you defined your object/function/dataset &lt;em&gt;before&lt;/em&gt; calling it!&lt;/p&gt;
&lt;p&gt;It often happens that a student asks me to come to his/her computer because he/she runs the exact same code than me, but cannot make it work. Most of the time, if his/her code is indeed exactly the same than mine, he/she simply has not executed a object/function/dataset before running the code which includes that object/function/dataset. In other words, he/she simply tries to use an undefined object or variable.&lt;/p&gt;
&lt;p&gt;Remember that writing code in a R script (contrarily to the console) does not mean it is compiled. You actually have to run it (by clicking on the Run button or using the keyboard shortcut) in order the code to be executed and used later. If you are still struggling with this, see the &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;basics of R and RStudio&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;missing-incorrect-or-misspelled-arguments-in-functions&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;4. Missing, incorrect or misspelled arguments in functions&lt;/h1&gt;
&lt;p&gt;Most R functions require arguments. For example, the &lt;code&gt;rnorm()&lt;/code&gt; function requires at least the number of observations, specified via the argument &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Your code will not run if you do not specify compulsory arguments, or if incorrectly specify an argument. Moreover, the result might not be what you expect if you misspell an argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## missing compulsory argument:
rnorm()&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in rnorm() : argument &amp;quot;n&amp;quot; is missing, with no default&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## incorrect argument:
rnorm(n = 3, var = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in rnorm(n = 3, var = 1) : unused argument (var = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## misspelled argument:
mean(c(1, 7, 13, NA), narm = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The last piece of code does not throw an error, but the result is not what we want.&lt;/p&gt;
&lt;div id=&#34;solution-3&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;To solve these errors, make sure to specify &lt;strong&gt;at least all compulsory arguments&lt;/strong&gt; of the function, and the correct ones:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;rnorm()&lt;/code&gt;, it is the standard deviation, &lt;code&gt;sd&lt;/code&gt;, which can be specified in addition to the number of observations &lt;code&gt;n&lt;/code&gt; (instead of the variance &lt;code&gt;var&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Removing &lt;code&gt;NA&lt;/code&gt; is done with &lt;code&gt;na.rm&lt;/code&gt; (instead of &lt;code&gt;narm&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rnorm(n = 3, sd = 1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] -0.3066386 -1.7813084 -0.1719174&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean(c(1, 7, 13, NA), na.rm = TRUE)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not know the arguments of a function by heart, you can always check the documentation with &lt;code&gt;?function_name&lt;/code&gt; or &lt;code&gt;help(function_name)&lt;/code&gt;, for example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;?rnorm()

## or:
help(rnorm)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;wrong-inappropriate-or-inconsistent-data-types&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;5. Wrong, inappropriate or inconsistent data types&lt;/h1&gt;
&lt;p&gt;There are several &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/&#34;&gt;data types in R&lt;/a&gt;, the main ones being:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Numeric&lt;/li&gt;
&lt;li&gt;Character&lt;/li&gt;
&lt;li&gt;Factor&lt;/li&gt;
&lt;li&gt;Logical&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You know that some operations and analyses are possible and appropriate only with some specific types of data.&lt;/p&gt;
&lt;p&gt;For example, it is not appropriate to compute the &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#mean&#34;&gt;mean&lt;/a&gt; of a factor or character variable:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;gender &amp;lt;- factor(c(&amp;quot;female&amp;quot;, &amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;, &amp;quot;female&amp;quot;, &amp;quot;male&amp;quot;))

mean(gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning in mean.default(gender): argument is not numeric or logical: returning
## NA&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Likewise, although it is technically possible, it makes little sense to draw a &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/#barplot&#34;&gt;barplot&lt;/a&gt; of a &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/&#34;&gt;quantitative continuous&lt;/a&gt; variable because in most cases, the frequency will be 1 for each value:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(rnorm(10)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-33-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(By the way, if your data is not already displayed in the form of a table, do not forget to add &lt;code&gt;table()&lt;/code&gt; inside the &lt;code&gt;barplot()&lt;/code&gt; function.)&lt;/em&gt;&lt;/p&gt;
&lt;div id=&#34;solution-4&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;Make sure to use the appropriate operation and type of analysis depending on the variable(s) of interest.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;for factor variables, it is more appropriate to compute frequencies and/or relative frequencies, and draw barplots&lt;/li&gt;
&lt;li&gt;for quantitative continuous variables, it is more appropriate to compute the mean, median, etc. and draw histograms, boxplots, etc.&lt;/li&gt;
&lt;li&gt;for logical variables, the mean,&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; a frequency table and a barplot are appropriate&lt;/li&gt;
&lt;li&gt;for character variables, &lt;a href=&#34;https://statsandr.com/blog/draw-a-word-cloud-with-a-shiny-app/&#34;&gt;word clouds&lt;/a&gt; are the most appropriate (unless the variable can be considered as a factor variable because there are not too many different levels)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We now illustrate the examples in R:&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## factor:
table(gender)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## gender
## female   male 
##      3      2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;prop.table(table(gender))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## gender
## female   male 
##    0.6    0.4&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(gender))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-34-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## quantitative continuous:
x &amp;lt;- rnorm(100)

summary(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -2.99309 -0.74143  0.01809 -0.08570  0.58937  2.70189&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;par(mfrow = c(1, 2)) ## combine two plots
hist(x)
boxplot(x)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-34-2.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## logical:
x &amp;lt;- c(TRUE, FALSE, FALSE, TRUE, TRUE)

mean(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 0.6&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## x
## FALSE  TRUE 
##     2     3&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;barplot(table(x))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-35-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;For the interested reader, see the most common &lt;a href=&#34;https://statsandr.com/blog/descriptive-statistics-in-r/&#34;&gt;descriptive statistics in R&lt;/a&gt; for different types of data.&lt;/p&gt;
&lt;p&gt;Note that, as for descriptive statistics, the choice of the statistical test depends on the variable’s type. See this &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;flowchart&lt;/a&gt; to help you in selecting the most appropriate statistical test depending on the number of variables and their types.&lt;/p&gt;
&lt;p&gt;An error linked to the one mentioned above is &lt;strong&gt;inconsistent&lt;/strong&gt; data type. See it in practice with the following example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(2.4, 3.7, 5.1, 9.8)
class(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;numeric&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;y &amp;lt;- c(2.4, 3.7, 5.1, &amp;quot;9.8&amp;quot;)
class(y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;character&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, vector &lt;code&gt;x&lt;/code&gt; is numerical, whereas vector &lt;code&gt;y&lt;/code&gt; is in the form of character. This is due to the fact that the last element of &lt;code&gt;y&lt;/code&gt; is surrounded with quotation marks (and thus considered as a string instead of a numerical value), so the entire vector takes the character form.&lt;/p&gt;
&lt;p&gt;This can happen when you &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;import a dataset into R&lt;/a&gt; and one or several elements of a variable are not encoded correctly. This leads to the entire variable to be considered as a character variable by R.&lt;/p&gt;
&lt;p&gt;To avoid this, it is a good practice to check the structure of your dataset (with &lt;code&gt;str()&lt;/code&gt;) after importing it to make sure all your variables have the desired format. If not, you can either correct the values in the initial file or change the format in R (with &lt;code&gt;as.numeric()&lt;/code&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;forgetting-the-sign-in-ggplot2&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;6. Forgetting the + sign in ggplot2&lt;/h1&gt;
&lt;p&gt;If you just learned to use the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;ggplot2 package&lt;/a&gt; for your visualizations (and I highly recommend it!), a common mistake is to forget the &lt;code&gt;+&lt;/code&gt; sign.&lt;/p&gt;
&lt;p&gt;You know that a visualization made with ggplot2 is constructed by adding several layers:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## load package:
library(ggplot2)

## first layer, the dataset:
ggplot(data = diamonds) +
  ## second layer, the aesthetics:
  aes(x = cut, y = price) +
  ## third layer, the type of plot:
  geom_boxplot() +
  ## add more layers:
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-37-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;solution-5&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;For all your graphics with ggplot2, do not forget to add a &lt;strong&gt;&lt;code&gt;+&lt;/code&gt; sign after each layer &lt;em&gt;except&lt;/em&gt; the last one&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;misunderstanding-between-and&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;7. Misunderstanding between = and ==&lt;/h1&gt;
&lt;p&gt;Assignment in R can be done in three ways, from the most to the least common:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;-&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;=&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;assign()&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The second method, that is &lt;code&gt;=&lt;/code&gt;, should not be confused with &lt;code&gt;==&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Indeed, assigning an object (with any of the three above methods) is used to save something in R. For example, if we want to save the vector &lt;code&gt;(1, 3, 7)&lt;/code&gt; and rename that vector &lt;code&gt;x&lt;/code&gt;, we can write:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(1, 3, 7)

## or:
x = c(1, 3, 7)

## or:
assign(&amp;quot;x&amp;quot;, c(1, 3, 7))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When executing this piece of code, you will see that the vector &lt;code&gt;x&lt;/code&gt; of size 3 appears in the tab “Environment” (the top right panel if you use the default view of RStudio):&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/R-environment.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From now on, we can use that vector simply by calling it by its name:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 1 3 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By no means, you can assign an object with &lt;code&gt;==&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## NOT correct if we want to assign c(1, 3, 7) to x:
x == c(1, 3, 7)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So you are wondering, when would we need to use &lt;code&gt;==&lt;/code&gt;? Actually, it is used when you want to use an equal sign.&lt;/p&gt;
&lt;p&gt;I understand that it may be abstract and confusing at the moment, so let’s suppose the following two scenarios as examples (which are the two most common cases when we use &lt;code&gt;==&lt;/code&gt;):&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;we want to check whether an assigned object or variable respects some conditions, and&lt;/li&gt;
&lt;li&gt;we want to subset a dataframe based on one or several conditions.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For these examples, suppose a &lt;a href=&#34;https://statsandr.com/blog/what-is-the-difference-between-population-and-sample/&#34;&gt;sample&lt;/a&gt; of 5 children:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## create dataframe:
dat &amp;lt;- data.frame(
  Name = c(&amp;quot;Mary&amp;quot;, &amp;quot;Linda&amp;quot;, &amp;quot;James&amp;quot;, &amp;quot;John&amp;quot;, &amp;quot;Patricia&amp;quot;),
  Age = c(7, 10, 3, 9, 7),
  Gender = c(&amp;quot;Girl&amp;quot;, &amp;quot;Girl&amp;quot;, &amp;quot;Boy&amp;quot;, &amp;quot;Boy&amp;quot;, &amp;quot;Girl&amp;quot;)
)

## print dataframe:
dat&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 2    Linda  10   Girl
## 3    James   3    Boy
## 4     John   9    Boy
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s now write different pieces of code for these two scenarios to illustrate them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We want to check whether the variable &lt;code&gt;Age&lt;/code&gt; is equal to the vector &lt;code&gt;(1, 2, 3, 4, 5)&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$Age == 1:5&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] FALSE FALSE  TRUE FALSE FALSE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this code, we ask whether the first element of the variable &lt;code&gt;Age&lt;/code&gt; is equal to 1, the second element of the variable &lt;code&gt;Age&lt;/code&gt; is equal to 2, and so on. The answer is of course &lt;code&gt;FALSE&lt;/code&gt;, &lt;code&gt;FALSE&lt;/code&gt;, &lt;code&gt;TRUE&lt;/code&gt;, &lt;code&gt;FALSE&lt;/code&gt; and &lt;code&gt;FALSE&lt;/code&gt; since only the third child has an age &lt;strong&gt;equal&lt;/strong&gt; to 3 years.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We want to know which of our 5 sampled children are girls:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat$Gender == &amp;quot;Girl&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  TRUE  TRUE FALSE FALSE  TRUE&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The results show that the first, second and fifth children are girls, while the third and fourth children are not girls.&lt;/p&gt;
&lt;p&gt;If you write any of these two lines:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## this overwrites Age and Gender:
dat$Age = 1:5
dat$Gender = &amp;quot;Girl&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You actually overwrite the &lt;code&gt;Age&lt;/code&gt; and &lt;code&gt;Gender&lt;/code&gt; variables, such that our 5 children will have an age from 1 to 5 (1 year for the first child, up to 5 years for the fifth child) and all of them will be girls.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Now suppose we want to subset our dataframe based on a condition, namely, we want to extract only the children who are 7 years old:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;subset(dat, Age == 7)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not want to use the subset function, you can also use square brackets:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[dat$Age == 7, ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see in the previous examples, we do not want to assign anything. Instead, we are asking “is this variable or vector &lt;em&gt;equal&lt;/em&gt; to something else?”. For that specific need, we use &lt;code&gt;==&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So to sum up, for technical reasons and in order to distinguish between the two concepts, R uses &lt;code&gt;=&lt;/code&gt; for assignments, and &lt;code&gt;==&lt;/code&gt; for the equality sign. Make sure to understand the difference between the two to avoid any errors.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;undefined-columns-selected&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;8. Undefined columns selected&lt;/h1&gt;
&lt;p&gt;If you are used to subset dataframes with square brackets, &lt;code&gt;[]&lt;/code&gt;, instead of the &lt;code&gt;subset()&lt;/code&gt; or &lt;code&gt;filter()&lt;/code&gt; functions, you may have faced the error “Error in [.data.frame(…) : undefined columns selected”.&lt;/p&gt;
&lt;p&gt;This occurs when R does not understand the column you want to use while subsetting the dataset.&lt;/p&gt;
&lt;p&gt;Considering the same sample of 5 children introduced earlier, the following code will throw an error:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[dat$Age == 7]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in `[.data.frame`(dat, dat$Age == 7) : undefined columns selected&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;because it does not specify the column dimension.&lt;/p&gt;
&lt;div id=&#34;solution-6&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;Remember that dataframes in R have two dimensions:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;the rows (one for each experimental unit), and&lt;/li&gt;
&lt;li&gt;the columns (one for each variable)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;and &lt;strong&gt;in that particular order&lt;/strong&gt; (so row first, then column)!&lt;/p&gt;
&lt;p&gt;Since dataframes have two dimensions, R expects two dimensions when you call &lt;code&gt;dat[]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In particular, it expects the first and then the second dimension, &lt;strong&gt;separated by a comma&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat[dat$Age == 7, ]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Name Age Gender
## 1     Mary   7   Girl
## 5 Patricia   7   Girl&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code means that we are extracting all rows where &lt;code&gt;Age&lt;/code&gt; is equal to 7 (first dimension, i.e. before the comma), for all variables of the dataset (since we did not specify any column after the comma).&lt;/p&gt;
&lt;p&gt;For the interested reader, see more ways to &lt;a href=&#34;https://statsandr.com/blog/data-manipulation-in-r/&#34;&gt;subset and manipulate data in R&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;problem-when-importing-or-using-the-wrong-data-file&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;9. Problem when importing or using the wrong data file&lt;/h1&gt;
&lt;p&gt;Importing a dataset in R can be quite challenging for beginners, mainly due to the misunderstanding about the working directory.&lt;/p&gt;
&lt;p&gt;When importing a file, &lt;strong&gt;R will not search for the file in all your folders&lt;/strong&gt; of your computer. Instead, it will look only in one specific folder. If your dataset is not inside that folder, it will result in an error such as “cannot open file ‘…’: No such file or directory”:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/cannot-open-file-no-such-file-or-directory.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;To fix this, you must specify the path to the folder where your dataset is located. In other words, you need to tell R in which folder you want it to work, hence the name working directory.&lt;/p&gt;
&lt;p&gt;Setting the working directory can be done with the &lt;code&gt;setwd()&lt;/code&gt; function or via the “Files” tab in the lower right panel of RStudio:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/files-r-studio.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Alternatively, you can move the dataset in the folder where R is currently working (this can be found with &lt;code&gt;getwd()&lt;/code&gt;). See more details on &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;importing a file into R and about the working directory&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Another related problem is to use the wrong file. This error is different than the previous ones in the sense that you will not encounter an error but your analyses will still be wrong.&lt;/p&gt;
&lt;p&gt;It may sound trivial, but make sure to import and use the correct data file! This is particularly the case if you have files for different points in time and which have a common structure (for example weekly or monthly data files with the exact same variables). It happened to me that I reported results for the wrong week (fortunately, without much consequence).&lt;/p&gt;
&lt;p&gt;Also, make sure that you actually use all the rows you want to include in your analyses. It happened to me that, in order to test a model (and avoid long computing times), I extracted a random sample of the original dataset, and almost forgot about this sampling when running my final analyses.&lt;/p&gt;
&lt;p&gt;It is thus a good practice to remind you to remove sampling and filters after you have tested your code (and before interpreting the final results).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;problem-when-using-the-operator&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;10. Problem when using the $ operator&lt;/h1&gt;
&lt;p&gt;For the last error of this top 10, I would like to focus on two related errors:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;“$ operator is invalid for atomic vectors”, and&lt;/li&gt;
&lt;li&gt;“object of type ‘closure’ is not subsettable”.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I gather them in one single section because they are linked to each other in the sense that they both involve the &lt;code&gt;$&lt;/code&gt; operator.&lt;/p&gt;
&lt;div id=&#34;operator-is-invalid-for-atomic-vectors&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;$ operator is invalid for atomic vectors&lt;/h2&gt;
&lt;p&gt;To understand this error, we first must recall that an atomic vector is a &lt;em&gt;one&lt;/em&gt;-dimensional object (usually created with &lt;code&gt;c()&lt;/code&gt;). This is different than dataframes or matrices which are &lt;em&gt;two&lt;/em&gt;-dimensional (i.e., rows form the first dimension and columns correspond to the second dimension).&lt;/p&gt;
&lt;p&gt;The error “$ operator is invalid for atomic vectors” occurs when we try to access an element of an atomic vector using the dollar operator (&lt;code&gt;$&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## define atomic vector:
x &amp;lt;- c(1, 3, 7)

## set names:
names(x) &amp;lt;- LETTERS[1:3]

## print vector:
x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## A B C 
## 1 3 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## access value of element C:
x$C&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in x$C : $ operator is invalid for atomic vectors&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;solution-7&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;$&lt;/code&gt; operator cannot be used to extract elements in atomic vectors. Instead, we must use double brackets &lt;code&gt;[[]]&lt;/code&gt; notation:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x[[&amp;quot;C&amp;quot;]]&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember that the &lt;code&gt;$&lt;/code&gt; operator can be used with dataframes, so we can also fix this error by first converting the atomic vector to a dataframe,&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt; and then access an element by its name with the &lt;code&gt;$&lt;/code&gt; operator:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## convert atomic vector to dataframe:
x &amp;lt;- as.data.frame(t(x))

## print x:
x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   A B C
## 1 1 3 7&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## access value of element C:
x$C&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;object-of-type-closure-is-not-subsettable&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;object of type ‘closure’ is not subsettable&lt;/h2&gt;
&lt;p&gt;Another error (which I must admit is quite obscure and confusing when learning R) is the following: “object of type ‘closure’ is not subsettable”.&lt;/p&gt;
&lt;p&gt;This error occurs when we try to subset or access some elements of a function. An example with the well-known &lt;code&gt;mean()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;mean[1:3]&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in mean[1:3] : object of type &amp;#39;closure&amp;#39; is not subsettable&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In R, we can subset lists, vectors, matrices, dataframes, but not functions. So it throws an error because it is impossible to subset an object of type “closure”, and a function is of that type:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;typeof(mean)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;closure&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Most of the times, you will not encounter this error when using a basic function such as the &lt;code&gt;mean()&lt;/code&gt; function (because it is unlikely that your goal is really to subset a function…).&lt;/p&gt;
&lt;p&gt;Indeed, you will most likely face this error when trying to subset a dataset named &lt;code&gt;data&lt;/code&gt;, but this dataset is not defined in the environment (because it has not been imported or created properly for instance).&lt;/p&gt;
&lt;p&gt;To understand the concept, see the following examples:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## create dataset:
data &amp;lt;- data.frame(
  x = rnorm(10),
  y = rnorm(10)
)

## print variable x:
data$x&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1]  1.12288964  1.43985574 -1.09711377 -0.11731956  1.20149840 -0.46972958
##  [7] -0.05246948 -0.08610730 -0.88767902 -0.44468400&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So far so good. Now suppose we made a mistake when creating the dataset:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## create dataset (with mistake):
data &amp;lt;- data.frame(x = rnorm(10)
                   y = rnorm(10))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will notice that a comma is missing between variables &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;. As a result, the dataset named &lt;code&gt;data&lt;/code&gt; is not created and thus not defined.&lt;/p&gt;
&lt;p&gt;Therefore, if we now try to access the variable &lt;code&gt;x&lt;/code&gt; from that dataset &lt;code&gt;data&lt;/code&gt;, R will actually try to subset the function named &lt;code&gt;data&lt;/code&gt; instead of the dataset named &lt;code&gt;data&lt;/code&gt;!&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;data$x&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;## Error in data$x : object of type &amp;#39;closure&amp;#39; is not subsettable&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This happens because, I repeat, the dataset &lt;code&gt;data&lt;/code&gt; does not exist, so R looks for an object named &lt;code&gt;data&lt;/code&gt; and find a function with that name:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;class(data)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] &amp;quot;function&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;warnings&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Warnings&lt;/h1&gt;
&lt;p&gt;Warnings are different than errors in the sense that they alert you about something, but it does not prevent you from running the code. It is a good practice to read these warnings as they may give you valuable information.&lt;/p&gt;
&lt;p&gt;There are too many warnings to mention them all, but I would like to focus on two common ones:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;“NAs introduced by coercion”, and&lt;/li&gt;
&lt;li&gt;“Removed … rows containing non-finite values (stat_bin())”.&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;nas-introduced-by-coercion&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;NAs introduced by coercion&lt;/h2&gt;
&lt;p&gt;This warning occurs when you try to convert a vector which includes at least one non-numerical value to a numeric vector:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;x &amp;lt;- c(1, 3, 7, &amp;quot;Emma&amp;quot;)

as.numeric(x)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: NAs introduced by coercion&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1  3  7 NA&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You do not need to fix it since it is only a warning and not an error. R is simply informing you that at least one element in the initial vector was converted to &lt;code&gt;NA&lt;/code&gt; because it could not be converted to a numeric value.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;removed-rows-containing-non-finite-values-stat_bin&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Removed … rows containing non-finite values (stat_bin())&lt;/h2&gt;
&lt;p&gt;This warning occurs when you use &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;ggplot2&lt;/a&gt; to draw plots. For instance:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(airquality) +
  aes(x = Ozone) +
  geom_histogram()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## Warning: Removed 37 rows containing non-finite values (`stat_bin()`).&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/top-10-errors-in-r/index_files/figure-html/unnamed-chunk-65-1.png&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Again, as it is a warning you do not need to fix it. It is simply informing you that there are some missing values (&lt;code&gt;NA&lt;/code&gt;) in the variable of interest and that these missing values are removed to construct the plot.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope that this collection of errors prevented you from making some coding mistakes, or that it helped you in debugging your code.&lt;/p&gt;
&lt;p&gt;If you still cannot fix your error, I would recommend to read the documentation of the function (if you struggle with a function in particular), or look online for the solution. Bear in mind that if you encounter an error, it is very likely that someone else posted the answer online (Stack Overflow is usually a good resource).&lt;/p&gt;
&lt;p&gt;R has a steep learning curve, in particular if you are not familiar with another programming language. Nonetheless, with practice and time, you will make less and less coding errors, but more importantly, you will be more and more proficient in typing the right keywords in search engines, resulting in less time spent looking for the solution.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;There are 2 mistakes in that piece of code, feel free to try to fix them as an exercise.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn2&#34;&gt;&lt;p&gt;And I strongly recommend using RStudio and not just R. See the differences &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;here&lt;/a&gt;.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Note that &lt;code&gt;mean()&lt;/code&gt; applied to a logical variable gives the proportion of &lt;code&gt;TRUE&lt;/code&gt;.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;&lt;code&gt;par(mfrow = c(1, 2))&lt;/code&gt; is used to put two plots next to each other.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;Note that we also need to take the transpose of the vector &lt;code&gt;x&lt;/code&gt; in order to have it as 1 row, 3 columns.&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>How to keep yourself updated with the latest R news?</title>
      <link>https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/</link>
      <pubDate>Thu, 13 Oct 2022 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/</guid>
      <description>
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/htmltools-fill/fill.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/datatables-css/datatables-crosstalk.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/datatables-binding/datatables.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/jquery/jquery-3.6.0.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-core/css/jquery.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-core/css/jquery.dataTables.extra.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-core/js/jquery.dataTables.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/jszip/jszip.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/pdfmake/pdfmake.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/pdfmake/vfs_fonts.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/css/buttons.dataTables.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/dataTables.buttons.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/buttons.html5.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/buttons.colVis.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/dt-ext-buttons/js/buttons.print.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/nouislider/jquery.nouislider.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/nouislider/jquery.nouislider.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/selectize/selectize.bootstrap3.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/selectize/selectize.min.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/crosstalk/css/crosstalk.min.css&#34; rel=&#34;stylesheet&#34; /&gt;
&lt;script src=&#34;https://statsandr.com/blog/how-to-keep-up-to-date-with-the-latest-r-news/index_files/crosstalk/js/crosstalk.min.js&#34;&gt;&lt;/script&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#how-do-i-keep-track&#34; id=&#34;toc-how-do-i-keep-track&#34;&gt;How do I keep track?&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#twitter&#34; id=&#34;toc-twitter&#34;&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#newsletters&#34; id=&#34;toc-newsletters&#34;&gt;Newsletters&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;images/how-to-keep-up-to-date-with-the-latest-R-news.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;At the end of one of the training sessions I gave on R, a student asked me the following question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;How do you keep yourself updated with the latest R news?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It is true that R, being open source (meaning that everyone can contribute), is evolving rapidly. This means that even if I am using R for several years and on a daily basis, I like to stay informed in order to stay up to date with the program and the latest coding practices.&lt;/p&gt;
&lt;p&gt;In fact, I learn about new packages, new functions and new features almost everyday. Most of them are not particularly useful for my research or my teaching tasks, but sometimes I discover such a nice package or function that I replace my code with new one.&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The training was an advanced one, so the student had a good knowledge of R and was not looking for more tutorials or courses. She was interested in knowing where to look for updates about current and new R packages and functions.&lt;/p&gt;
&lt;p&gt;After sharing my sources with all students following the training, I thought it would be useful to others. In this article, I share my sources—from where I get the latest R updates and news.&lt;/p&gt;
&lt;p&gt;The sources are divided into two main categories: &lt;strong&gt;Twitter and newsletters.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;how-do-i-keep-track&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;How do I keep track?&lt;/h1&gt;
&lt;div id=&#34;twitter&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Twitter&lt;/h2&gt;
&lt;p&gt;To be honest, I mostly use Twitter to keep up to date with R news.&lt;/p&gt;
&lt;p&gt;Twitter allows me to follow discussions about statistical methods or approaches, and to keep me informed about publications of new blog posts.&lt;/p&gt;
&lt;p&gt;What I particularly like with Twitter is that there is a mix between:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;short messages about new functions or packages (most of the time with an illustration or an example), and&lt;/li&gt;
&lt;li&gt;announcements of new blog posts that cover specific subjects in details.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this, I follow people (researchers, professors, bloggers, statisticians, data scientists, etc.) that are working in my domains of interest. For instance, I am mostly interested in the application of statistics in R, data science, biostatistics and data visualization. I thus follow accounts which regularly post about these topics. I also avoid following accounts that cover topics I am not interested in, so that my Twitter feed really shows information I am most likely to be interested in.&lt;/p&gt;
&lt;p&gt;Below, you will see a list of some of the accounts I follow, classified by themes. Of course, this is a &lt;strong&gt;non-exhaustive list!&lt;/strong&gt; There are plenty of very inspiring and intelligent people that are not in the list, simply because I cannot afford to put them all.&lt;/p&gt;
&lt;p&gt;If you follow people that post regularly about the themes covered below, feel free to add them in the comments. I am always looking for new inspiring accounts to follow.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that the accounts are displayed in alphabetical order and the table is searchable.&lt;/em&gt;&lt;/p&gt;
&lt;div class=&#34;datatables html-widget html-fill-item&#34; id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:auto;&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;filter&#34;:&#34;top&#34;,&#34;vertical&#34;:false,&#34;filterHTML&#34;:&#34;&lt;tr&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n  &lt;td data-type=\&#34;character\&#34; style=\&#34;vertical-align: top;\&#34;&gt;\n    &lt;div class=\&#34;form-group has-feedback\&#34; style=\&#34;margin-bottom: auto;\&#34;&gt;\n      &lt;input type=\&#34;search\&#34; placeholder=\&#34;All\&#34; class=\&#34;form-control\&#34; style=\&#34;width: 100%;\&#34;/&gt;\n      &lt;span class=\&#34;glyphicon glyphicon-remove-circle form-control-feedback\&#34;&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/td&gt;\n&lt;\/tr&gt;&#34;,&#34;extensions&#34;:[&#34;Buttons&#34;],&#34;data&#34;:[[&#34;R for Data Science&#34;,&#34;Allison Horst&#34;,&#34;Kyle Cuilla&#34;,&#34;R4DS online learning community&#34;,&#34;Julia Silge&#34;,&#34;Tanya Shapiro&#34;,&#34;rOpenSci&#34;,&#34;Shannon Pileggi&#34;,&#34;R for the Rest of Us&#34;,&#34;David Keyes&#34;,&#34;Jenny Bryan&#34;,&#34;David Robinson&#34;,&#34;Sharon Machlis&#34;,&#34;Chelsea Parlett-Pelleriti&#34;,&#34;Mara Averick&#34;,&#34;Rohan Alexander&#34;,&#34;JD Long&#34;,&#34;Achim Zeileis&#34;,&#34;Oscar Baruffa&#34;,&#34;Cosima Meyer&#34;,&#34;Alison Hill&#34;,&#34;Keith McNulty&#34;,&#34;mikefc&#34;,&#34;Mark Edmondson&#34;,&#34;Rafael Irizarry&#34;,&#34;Rami Krispin&#34;,&#34;Indrajeet Patil&#34;,&#34;Lucy D&#39;Agostino McGowan&#34;,&#34;Daniela Witten&#34;,&#34;Jim Frost&#34;,&#34;easystats&#34;,&#34;Frank Harrell&#34;,&#34;Dan Quintana&#34;,&#34;Laurent Gatto&#34;,&#34;Maarten van Smeden&#34;,&#34;Ted Laderas&#34;,&#34;R Medicine&#34;,&#34;Ewen Harrison&#34;,&#34;Cédric Scherer&#34;,&#34;Tom Mock&#34;,&#34;Cara Thompson&#34;,&#34;Alex Albright&#34;,&#34;Maarten Lambrechts&#34;,&#34;r/DataIsBeautiful&#34;,&#34;Cole Knaflic&#34;,&#34;Yan Holtz&#34;,&#34;Kieran Healy&#34;,&#34;Will Chase&#34;,&#34;Dean Attali&#34;,&#34;Nick Strayer&#34;,&#34;R-bloggers&#34;,&#34;Hadley Wickham&#34;,&#34;One R Package a Day&#34;,&#34;R Function A Day&#34;,&#34;ThinkR&#34;,&#34;#RStats Question A Day&#34;,&#34;Maëlle Salmon&#34;,&#34;R Weekly&#34;,&#34;R Weekly Live&#34;,&#34;We are R-Ladies&#34;,&#34;Colin Fay&#34;,&#34;R Tweets&#34;,&#34;R posts you might have missed!&#34;,&#34;Quarto&#34;,&#34;R Markdown&#34;,&#34;The R Foundation&#34;,&#34;Alastair Rushworth&#34;,&#34;Rstats&#34;,&#34;Charlotte Wickham&#34;,&#34;Garrett Grolemund&#34;,&#34;Yihui Xie&#34;,&#34;Garrick Aden-Buie&#34;,&#34;RStudio Tips&#34;,&#34;Jeff Leek&#34;,&#34;RStudio&#34;,&#34;Stats and R&#34;,&#34;Roger D. Peng&#34;,&#34;Claire Della Vedova (in French)&#34;],[&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Biostatistics&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;Visualization &amp; R Shiny&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;R package &amp; R environment&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Data analysis &amp; data science&#34;,&#34;Biostatistics&#34;],[&#34;&lt;a href=&#39;https://twitter.com/rstats4ds&#39; target=&#39;_blank&#39;&gt;@rstats4ds&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/allison_horst&#39; target=&#39;_blank&#39;&gt;@allison_horst&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/kc_analytics&#39; target=&#39;_blank&#39;&gt;@kc_analytics&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/R4DScommunity&#39; target=&#39;_blank&#39;&gt;@R4DScommunity&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/juliasilge&#39; target=&#39;_blank&#39;&gt;@juliasilge&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/tanya_shapiro&#39; target=&#39;_blank&#39;&gt;@tanya_shapiro&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rOpenSci&#39; target=&#39;_blank&#39;&gt;@rOpenSci&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/PipingHotData&#39; target=&#39;_blank&#39;&gt;@PipingHotData&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rfortherest&#39; target=&#39;_blank&#39;&gt;@rfortherest&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dgkeyes&#39; target=&#39;_blank&#39;&gt;@dgkeyes&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/JennyBryan&#39; target=&#39;_blank&#39;&gt;@JennyBryan&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/drob&#39; target=&#39;_blank&#39;&gt;@drob&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/sharon000&#39; target=&#39;_blank&#39;&gt;@sharon000&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/ChelseaParlett&#39; target=&#39;_blank&#39;&gt;@ChelseaParlett&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dataandme&#39; target=&#39;_blank&#39;&gt;@dataandme&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/RohanAlexander&#39; target=&#39;_blank&#39;&gt;@RohanAlexander&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/CMastication&#39; target=&#39;_blank&#39;&gt;@CMastication&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/AchimZeileis&#39; target=&#39;_blank&#39;&gt;@AchimZeileis&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/OscarBaruffa&#39; target=&#39;_blank&#39;&gt;@OscarBaruffa&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/cosima_meyer&#39; target=&#39;_blank&#39;&gt;@cosima_meyer&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/apreshill&#39; target=&#39;_blank&#39;&gt;@apreshill&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dr_keithmcnulty&#39; target=&#39;_blank&#39;&gt;@dr_keithmcnulty&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/coolbutuseless&#39; target=&#39;_blank&#39;&gt;@coolbutuseless&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/HoloMarkeD&#39; target=&#39;_blank&#39;&gt;@HoloMarkeD&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rafalab&#39; target=&#39;_blank&#39;&gt;@rafalab&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/Rami_Krispin&#39; target=&#39;_blank&#39;&gt;@Rami_Krispin&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/patilindrajeets&#39; target=&#39;_blank&#39;&gt;@patilindrajeets&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/LucyStats&#39; target=&#39;_blank&#39;&gt;@LucyStats&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/daniela_witten&#39; target=&#39;_blank&#39;&gt;@daniela_witten&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/statisticsbyjim&#39; target=&#39;_blank&#39;&gt;@statisticsbyjim&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/easystats4u&#39; target=&#39;_blank&#39;&gt;@easystats4u&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/f2harrell&#39; target=&#39;_blank&#39;&gt;@f2harrell&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/dsquintana&#39; target=&#39;_blank&#39;&gt;@dsquintana&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/lgatt0&#39; target=&#39;_blank&#39;&gt;@lgatt0&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/MaartenvSmeden&#39; target=&#39;_blank&#39;&gt;@MaartenvSmeden&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/tladeras&#39; target=&#39;_blank&#39;&gt;@tladeras&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/r_medicine&#39; target=&#39;_blank&#39;&gt;@r_medicine&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/ewenharrison&#39; target=&#39;_blank&#39;&gt;@ewenharrison&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/CedScherer&#39; target=&#39;_blank&#39;&gt;@CedScherer&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/thomas_mock&#39; target=&#39;_blank&#39;&gt;@thomas_mock&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/cararthompson&#39; target=&#39;_blank&#39;&gt;@cararthompson&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/AllbriteAllday&#39; target=&#39;_blank&#39;&gt;@AllbriteAllday&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/maartenzam&#39; target=&#39;_blank&#39;&gt;@maartenzam&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/DataIsBeautiful&#39; target=&#39;_blank&#39;&gt;@DataIsBeautiful&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/storywithdata&#39; target=&#39;_blank&#39;&gt;@storywithdata&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/R_Graph_Gallery&#39; target=&#39;_blank&#39;&gt;@R_Graph_Gallery&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/kjhealy&#39; target=&#39;_blank&#39;&gt;@kjhealy&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/W_R_Chase&#39; target=&#39;_blank&#39;&gt;@W_R_Chase&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/daattali&#39; target=&#39;_blank&#39;&gt;@daattali&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/NicholasStrayer&#39; target=&#39;_blank&#39;&gt;@NicholasStrayer&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/Rbloggers&#39; target=&#39;_blank&#39;&gt;@Rbloggers&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/hadleywickham&#39; target=&#39;_blank&#39;&gt;@hadleywickham&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/RLangPackage&#39; target=&#39;_blank&#39;&gt;@RLangPackage&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rfunctionaday&#39; target=&#39;_blank&#39;&gt;@rfunctionaday&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/thinkR_fr&#39; target=&#39;_blank&#39;&gt;@thinkR_fr&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/data_question&#39; target=&#39;_blank&#39;&gt;@data_question&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/ma_salmon&#39; target=&#39;_blank&#39;&gt;@ma_salmon&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rweekly_org&#39; target=&#39;_blank&#39;&gt;@rweekly_org&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rweekly_live&#39; target=&#39;_blank&#39;&gt;@rweekly_live&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/WeAreRLadies&#39; target=&#39;_blank&#39;&gt;@WeAreRLadies&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/_ColinFay&#39; target=&#39;_blank&#39;&gt;@_ColinFay&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstats_tweets&#39; target=&#39;_blank&#39;&gt;@rstats_tweets&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/icymi_r&#39; target=&#39;_blank&#39;&gt;@icymi_r&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/quarto_pub&#39; target=&#39;_blank&#39;&gt;@quarto_pub&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rmarkdown&#39; target=&#39;_blank&#39;&gt;@rmarkdown&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/_R_Foundation&#39; target=&#39;_blank&#39;&gt;@_R_Foundation&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rushworth_a&#39; target=&#39;_blank&#39;&gt;@rushworth_a&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstatstweet&#39; target=&#39;_blank&#39;&gt;@rstatstweet&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/CVWickham&#39; target=&#39;_blank&#39;&gt;@CVWickham&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/StatGarrett&#39; target=&#39;_blank&#39;&gt;@StatGarrett&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/xieyihui&#39; target=&#39;_blank&#39;&gt;@xieyihui&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/grrrck&#39; target=&#39;_blank&#39;&gt;@grrrck&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstudiotips&#39; target=&#39;_blank&#39;&gt;@rstudiotips&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/jtleek&#39; target=&#39;_blank&#39;&gt;@jtleek&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rstudio&#39; target=&#39;_blank&#39;&gt;@rstudio&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/statsandr&#39; target=&#39;_blank&#39;&gt;@statsandr&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/rdpeng&#39; target=&#39;_blank&#39;&gt;@rdpeng&lt;\/a&gt;&#34;,&#34;&lt;a href=&#39;https://twitter.com/blog_SLR&#39; target=&#39;_blank&#39;&gt;@blog_SLR&lt;\/a&gt;&#34;]],&#34;container&#34;:&#34;&lt;table class=\&#34;display\&#34;&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th&gt;Name&lt;\/th&gt;\n      &lt;th&gt;Category&lt;\/th&gt;\n      &lt;th&gt;Link&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n&lt;\/table&gt;&#34;,&#34;options&#34;:{&#34;pageLength&#34;:78,&#34;order&#34;:[0,&#34;asc&#34;],&#34;autoWidth&#34;:true,&#34;dom&#34;:&#34;Blfrtip&#34;,&#34;buttons&#34;:[&#34;copy&#34;,&#34;csv&#34;,&#34;excel&#34;,&#34;pdf&#34;,&#34;print&#34;],&#34;columnDefs&#34;:[{&#34;name&#34;:&#34;Name&#34;,&#34;targets&#34;:0},{&#34;name&#34;:&#34;Category&#34;,&#34;targets&#34;:1},{&#34;name&#34;:&#34;Link&#34;,&#34;targets&#34;:2}],&#34;orderClasses&#34;:false,&#34;orderCellsTop&#34;:true,&#34;lengthMenu&#34;:[10,25,50,78,100]}},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;You will also find many news when exploring &lt;a href=&#34;https://twitter.com/hashtag/rstats?src=hashtag_click&#34;&gt;#rstats&lt;/a&gt; on Twitter.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;newsletters&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Newsletters&lt;/h2&gt;
&lt;p&gt;Besides Twitter, I also read new blog posts and stay informed through these newsletters:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;https://www.r-bloggers.com/&#34;&gt;R-Bloggers&lt;/a&gt; (daily)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rweekly.org/&#34;&gt;R Weekly&lt;/a&gt; (weekly)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.r-project.org/mail.html&#34;&gt;R mailing lists&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The 2 first newsletters are actually blog aggregators, so collections of many many blogs. If you have your own blog, don’t hesitate to submit it to make it accessible to more people.&lt;/p&gt;
&lt;p&gt;You can always subscribe to a blog you like, but if it is related to R, it will most likely be shared via R-Bloggers or R Weekly.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article will help you to keep track of great blogs, tutorials and other resources about R. Feel free to follow me on Twitter (&lt;a href=&#34;https://twitter.com/statsandr&#34;&gt;&lt;span class=&#34;citation&#34;&gt;@statsandr&lt;/span&gt;&lt;/a&gt;), where I tweet my new articles and retweet everything I find interesting or worth mentioning.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;See for example this &lt;a href=&#34;https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/#update-with-the-ggstatsplot-package&#34;&gt;article&lt;/a&gt;. The package I discovered was so useful and interesting (to me), that I added a new section to the post and now use it instead of the older package.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>How to do a t-test or ANOVA for more than one variable at once in R?</title>
      <link>https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/</link>
      <pubDate>Thu, 19 Mar 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#perform-multiple-tests-at-once&#34; id=&#34;toc-perform-multiple-tests-at-once&#34;&gt;Perform multiple tests at once&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#concise-and-easily-interpretable-results&#34; id=&#34;toc-concise-and-easily-interpretable-results&#34;&gt;Concise and easily interpretable results&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#t-test&#34; id=&#34;toc-t-test&#34;&gt;T-test&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#additional-p-value-adjustment-methods&#34; id=&#34;toc-additional-p-value-adjustment-methods&#34;&gt;Additional &lt;em&gt;p&lt;/em&gt;-value adjustment methods&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#anova&#34; id=&#34;toc-anova&#34;&gt;ANOVA&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#to-go-even-further&#34; id=&#34;toc-to-go-even-further&#34;&gt;To go even further&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#update-with-the-ggstatsplot-package&#34; id=&#34;toc-update-with-the-ggstatsplot-package&#34;&gt;Update with the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#references&#34; id=&#34;toc-references&#34;&gt;References&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/How%20to%20do%20a%20t-test%20or%20ANOVA%20for%20many%20variables%20at%20once%20in%20R%20and%20communicate%20the%20results%20in%20a%20better%20way.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;As part of my teaching assistant position in a Belgian university, students often ask me for some help in their statistical analyses for their master’s thesis.&lt;/p&gt;
&lt;p&gt;A frequent question is how to compare groups of patients in terms of several &lt;a href=&#34;https://statsandr.com/blog/variable-types-and-examples/#continuous&#34;&gt;quantitative continuous&lt;/a&gt; variables. Most of us know that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To compare two groups, a &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;Student’s t-test&lt;/a&gt; should be used&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To compare three groups or more, an &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; should be performed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These two tests are quite basic and have been extensively documented online and in statistical textbooks so the difficulty is not in how to perform these tests.&lt;/p&gt;
&lt;p&gt;In the past, I used to do the analyses by following these 3 steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Draw boxplots illustrating the distributions by group (with the &lt;code&gt;boxplot()&lt;/code&gt; function or thanks to the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;&lt;code&gt;{esquisse}&lt;/code&gt; R Studio addin&lt;/a&gt; if I wanted to use the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Perform a t-test or an ANOVA depending on the number of groups to compare (with the &lt;code&gt;t.test()&lt;/code&gt; and &lt;code&gt;oneway.test()&lt;/code&gt; functions for t-test and ANOVA, respectively)&lt;/li&gt;
&lt;li&gt;Repeat steps 1 and 2 for each variable&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This was feasible as long as there were only a couple of variables to test. Nonetheless, most students came to me asking to perform these kind of tests not on one or two variables, but on &lt;strong&gt;multiples&lt;/strong&gt; variables. So when there were more than one variable to test, I quickly realized that I was wasting my time and that there must be a more efficient way to do the job.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;: you must be very careful with the issue of &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#issue-of-multiple-testing&#34;&gt;multiple testing&lt;/a&gt; (also referred as multiplicity) which can arise when you perform multiple tests. In short, when a large number of statistical tests are performed, some will have &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values less than 0.05 purely by chance, even if all null hypotheses are in fact really true. This is known as multiplicity or multiple testing. You can tackle this problem by using the Bonferroni correction, among others. The Bonferroni correction is a simple method that allows many t-tests to be made while still assuring an overall confidence level is maintained. For this, instead of using the standard threshold of &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 5\)&lt;/span&gt;% for the significance level, you can use &lt;span class=&#34;math inline&#34;&gt;\(\alpha = \frac{0.05}{m}\)&lt;/span&gt; where &lt;span class=&#34;math inline&#34;&gt;\(m\)&lt;/span&gt; is the number of t-tests. For example, if you perform 20 t-tests with a desired &lt;span class=&#34;math inline&#34;&gt;\(\alpha = 0.05\)&lt;/span&gt;, the Bonferroni correction implies that you would reject the null hypothesis for each individual test when the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value is smaller than &lt;span class=&#34;math inline&#34;&gt;\(\alpha = \frac{0.05}{20} = 0.0025\)&lt;/span&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Note also that there is no universally accepted approach for dealing with the problem of multiple comparisons. Usually, you should choose a &lt;em&gt;p&lt;/em&gt;-value adjustment measure familiar to your audience or in your field of study. The Bonferroni correction is easy to implement. It is however not appropriate if you have a very large number of tests to perform (imagine you want to do 10,000 t-tests, a &lt;em&gt;p&lt;/em&gt;-value would have to be less than &lt;span class=&#34;math inline&#34;&gt;\(\frac{0.05}{10000} = 0.000005\)&lt;/span&gt; to be significant). A more powerful method is also to adjust the false discovery rate using the Benjamini-Hochberg or Holm procedure &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-mcdonald2014multiple&#34;&gt;McDonald 2014&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Another option is to use a multivariate ANOVA (MANOVA), if your independent variable has more than two levels. This is particularly useful when your dependent variables are correlated. Correlation between the dependent variables provides MANOVA the following advantages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Identify patterns between several dependent variables&lt;/strong&gt;: The independent variables can influence the relationship between dependent variables instead of influencing a single dependent variable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Address the issue of multiple testing&lt;/strong&gt;: with MANOVA, the error rate equals the significance level (with no &lt;em&gt;p&lt;/em&gt;-value adjustment method needed).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Greater statistical power&lt;/strong&gt;: When the dependent variables are correlated, MANOVA can identify effects that are too small for the ANOVA to detect.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that MANOVA is used if your independent variable has more than two levels. If your independent variable has only two levels, the multivariate equivalent of the t-test is Hotelling’s &lt;span class=&#34;math inline&#34;&gt;\(T^2\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;This article aims at presenting a way to perform multiple t-tests and ANOVA from a &lt;strong&gt;technical point of view&lt;/strong&gt; (how to implement it in R). Discussion on which adjustment method to use or whether there is a more appropriate model to fit the data is beyond the scope of this article (so be sure to understand the implications of using the code below for your own analyses). Make sure also to test the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#underlying-assumptions-of-anova&#34;&gt;assumptions&lt;/a&gt; of the ANOVA before interpreting results.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;perform-multiple-tests-at-once&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Perform multiple tests at once&lt;/h1&gt;
&lt;p&gt;I thus wrote a piece of code that automated the process, by drawing boxplots and performing the tests on several variables at once. Below is the code I used, illustrating the process with the &lt;code&gt;iris&lt;/code&gt; dataset. The &lt;code&gt;Species&lt;/code&gt; variable has 3 levels, so let’s remove one, and then draw a boxplot and apply a t-test on all 4 continuous variables at once. Note that the continuous variables that we would like to test are variables 1 to 4 in the &lt;code&gt;iris&lt;/code&gt; dataset.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris

# remove one level to have only two groups
dat &amp;lt;- subset(dat, Species != &amp;quot;setosa&amp;quot;)
dat$Species &amp;lt;- factor(dat$Species)

# boxplots and t-tests for the 4 variables at once
for (i in 1:4) { # variables to compare are variables 1 to 4
  boxplot(dat[, i] ~ dat$Species, # draw boxplots by group
    ylab = names(dat[i]), # rename y-axis with variable&amp;#39;s name
    xlab = &amp;quot;Species&amp;quot;
  )
  print(t.test(dat[, i] ~ dat$Species)) # print results of t-test
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -5.6292, df = 94.025, p-value = 1.866e-07
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -0.8819731 -0.4220269
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    5.936                    6.588&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -3.2058, df = 97.927, p-value = 0.001819
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -0.33028364 -0.07771636
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    2.770                    2.974&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -12.604, df = 95.57, p-value &amp;lt; 2.2e-16
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -1.49549 -1.08851
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    4.260                    5.552&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-1-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;## 
## 	Welch Two Sample t-test
## 
## data:  dat[, i] by dat$Species
## t = -14.625, df = 89.043, p-value &amp;lt; 2.2e-16
## alternative hypothesis: true difference in means between group versicolor and group virginica is not equal to 0
## 95 percent confidence interval:
##  -0.7951002 -0.6048998
## sample estimates:
## mean in group versicolor  mean in group virginica 
##                    1.326                    2.026&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, the above piece of code draws a boxplot and then prints results of the test for each continuous variable, all at once.&lt;/p&gt;
&lt;p&gt;At some point in the past, I even wrote code to:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;draw a boxplot&lt;/li&gt;
&lt;li&gt;test for the equality of variances (thanks to the Levene’s test)&lt;/li&gt;
&lt;li&gt;depending on whether the variances were equal or unequal, the appropriate test was applied: the Welch test if the variances were unequal and the Student’s t-test in the case the variances were equal (see more details about the different versions of the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;t-test for two samples&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;apply steps 1 to 3 for all continuous variables at once&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I had a similar code for ANOVA in case I needed to compare more than two groups.&lt;/p&gt;
&lt;p&gt;The code was doing the job relatively well. Indeed, thanks to this code I was able to test several variables in an automated way in the sense that it compared groups for all variables at once.&lt;/p&gt;
&lt;p&gt;The only thing I had to change from one project to another is that I needed to modify the name of the grouping variable and the numbering of the continuous variables to test (&lt;code&gt;Species&lt;/code&gt; and &lt;code&gt;1:4&lt;/code&gt; in the above code).&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;concise-and-easily-interpretable-results&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Concise and easily interpretable results&lt;/h1&gt;
&lt;div id=&#34;t-test&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;T-test&lt;/h2&gt;
&lt;p&gt;Although it was working quite well and applicable to different projects with only minor changes, I was still unsatisfied with another point.&lt;/p&gt;
&lt;p&gt;Someone who is proficient in statistics and R can read and interpret the output of a t-test without any difficulty. However, as you may have noticed with your own statistical projects, most people do not know what to look for in the results and are sometimes a bit confused when they see so many graphs, code, output, results and numeric values in a document. They are quite easily overwhelmed by this mass of information and unable to extract the key message.&lt;/p&gt;
&lt;p&gt;With my old R routine, the time I was saving by automating the process of t-tests and ANOVA was (partially) lost when I had to explain R outputs to my students so that they could interpret the results correctly. Although most of the time it simply boiled down to pointing out what to look for in the outputs (i.e., &lt;em&gt;p&lt;/em&gt;-values), I was still losing quite a lot of time because these outputs were, in my opinion, too detailed for most real-life applications and for students in introductory classes. In other words, too much information seemed to be confusing for many people so I was still not convinced that it was the most optimal way to share statistical results to nonscientists.&lt;/p&gt;
&lt;p&gt;Of course, they came to me for statistical advices, so they expected to have these results and I needed to give them answers to their questions and hypotheses. Nonetheless, I wanted to find a better way to communicate these results to this type of audience, with the minimum of information required to arrive at a conclusion. No more and no less than that.&lt;/p&gt;
&lt;p&gt;After a long time spent online trying to figure out a way to present results in a more concise and readable way, I discovered the &lt;a href=&#34;https://cran.r-project.org/web/packages/ggpubr/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{ggpubr}&lt;/code&gt; package&lt;/a&gt;. This package allows to indicate the test used and the &lt;em&gt;p&lt;/em&gt;-value of the test directly on a ggplot2-based graph. It also facilitates the creation of publication-ready plots for non-advanced statistical audiences.&lt;/p&gt;
&lt;p&gt;After many refinements and modifications of the initial code (available in this &lt;a href=&#34;http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;), I finally came up with a rather stable and robust process to perform t-tests and ANOVA for more than one variable at once, and more importantly, make the results concise and easily readable by anyone (statisticians or not).&lt;/p&gt;
&lt;p&gt;A graph is worth a thousand words, so here are the exact same tests than in the previous section, but this time with my new R routine:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggpubr)

# Edit from here #
x &amp;lt;- which(names(dat) == &amp;quot;Species&amp;quot;) # name of grouping variable
y &amp;lt;- which(names(dat) == &amp;quot;Sepal.Length&amp;quot; # names of variables to test
| names(dat) == &amp;quot;Sepal.Width&amp;quot; |
  names(dat) == &amp;quot;Petal.Length&amp;quot; |
  names(dat) == &amp;quot;Petal.Width&amp;quot;)
method &amp;lt;- &amp;quot;t.test&amp;quot; # one of &amp;quot;wilcox.test&amp;quot; or &amp;quot;t.test&amp;quot;
paired &amp;lt;- FALSE # if paired make sure that in the dataframe you have first all individuals at T1, then all individuals again at T2
# Edit until here


# Edit at your own risk
for (i in y) {
  for (j in x) {
    if (paired == TRUE) {
      p &amp;lt;- ggpaired(dat,
        x = colnames(dat[j]), y = colnames(dat[i]),
        color = colnames(dat[j]), line.color = &amp;quot;gray&amp;quot;, line.size = 0.4,
        palette = &amp;quot;npg&amp;quot;,
        legend = &amp;quot;none&amp;quot;,
        xlab = colnames(dat[j]),
        ylab = colnames(dat[i]),
        add = &amp;quot;jitter&amp;quot;
      )
    } else {
      p &amp;lt;- ggboxplot(dat,
        x = colnames(dat[j]), y = colnames(dat[i]),
        color = colnames(dat[j]),
        palette = &amp;quot;npg&amp;quot;,
        legend = &amp;quot;none&amp;quot;,
        add = &amp;quot;jitter&amp;quot;
      )
    }
    #  Add p-value
    print(p + stat_compare_means(aes(label = paste0(after_stat(method), &amp;quot;, p-value = &amp;quot;, after_stat(p.format))),
      method = method,
      paired = paired,
      # group.by = NULL,
      ref.group = NULL
    ))
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-2-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see from the graphs above, only the most important information is presented for each variable:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a visual comparison of the groups thanks to boxplots&lt;/li&gt;
&lt;li&gt;the name of the &lt;a href=&#34;https://statsandr.com/blog/what-statistical-test-should-i-do/&#34;&gt;statistical test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;the &lt;em&gt;p&lt;/em&gt;-value of the test&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Of course, experts may be interested in more advanced results. However, this simple yet complete graph, which includes the name of the test and the &lt;em&gt;p&lt;/em&gt;-value, gives all the necessary information to answer the question: “Are the groups different?”.&lt;/p&gt;
&lt;p&gt;In my experience, I have noticed that students and professionals (especially those from a less scientific background) understand way better these results than the ones presented in the previous section.&lt;/p&gt;
&lt;p&gt;The only lines of code that need to be modified for your own project is the name of the grouping variable (&lt;code&gt;Species&lt;/code&gt; in the above code), the names of the variables you want to test (&lt;code&gt;Sepal.Length&lt;/code&gt;, &lt;code&gt;Sepal.Width&lt;/code&gt;, etc.),&lt;a href=&#34;#fn2&#34; class=&#34;footnote-ref&#34; id=&#34;fnref2&#34;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt; whether you want to apply a &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;t-test&lt;/a&gt; (&lt;code&gt;t.test&lt;/code&gt;) or &lt;a href=&#34;https://statsandr.com/blog/wilcoxon-test-in-r-how-to-compare-2-groups-under-the-non-normality-assumption/&#34;&gt;Wilcoxon test&lt;/a&gt; (&lt;code&gt;wilcox.test&lt;/code&gt;) and whether the samples are paired or not (&lt;code&gt;FALSE&lt;/code&gt; if samples are independent, &lt;code&gt;TRUE&lt;/code&gt; if they are paired).&lt;/p&gt;
&lt;p&gt;Based on these graphs, it is easy, even for non-experts, to interpret the results and conclude that the &lt;code&gt;versicolor&lt;/code&gt; and &lt;code&gt;virginica&lt;/code&gt; species are significantly different in terms of all 4 variables (since all &lt;em&gt;p&lt;/em&gt;-values &lt;span class=&#34;math inline&#34;&gt;\(&amp;lt; \frac{0.05}{4} = 0.0125\)&lt;/span&gt; (remind that the Bonferroni correction is applied to avoid the issue of multiple testing, so we divide the usual &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; level by 4 because there are 4 t-tests)).&lt;/p&gt;
&lt;div id=&#34;additional-p-value-adjustment-methods&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Additional &lt;em&gt;p&lt;/em&gt;-value adjustment methods&lt;/h3&gt;
&lt;p&gt;If you would like to use another &lt;em&gt;p&lt;/em&gt;-value adjustment method, you can use the &lt;code&gt;p.adjust()&lt;/code&gt; function. Below are the raw &lt;em&gt;p&lt;/em&gt;-values found above, together with &lt;em&gt;p&lt;/em&gt;-values derived from the main adjustment methods (presented in a dataframe):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;raw_pvalue &amp;lt;- numeric(length = length(1:4))
for (i in (1:4)) {
  raw_pvalue[i] &amp;lt;- t.test(dat[, i] ~ dat$Species,
    alternative = &amp;quot;two.sided&amp;quot;
  )$p.value
}

df &amp;lt;- data.frame(
  Variable = names(dat[, 1:4]),
  raw_pvalue = round(raw_pvalue, 3)
)

df$Bonferroni &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;bonferroni&amp;quot;
  )
df$BH &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;BH&amp;quot;
  )
df$Holm &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;holm&amp;quot;
  )
df$Hochberg &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;hochberg&amp;quot;
  )
df$Hommel &amp;lt;-
  p.adjust(df$raw_pvalue,
    method = &amp;quot;hommel&amp;quot;
  )
df$BY &amp;lt;-
  round(p.adjust(df$raw_pvalue,
    method = &amp;quot;BY&amp;quot;
  ), 3)
df&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       Variable raw_pvalue Bonferroni    BH  Holm Hochberg Hommel    BY
## 1 Sepal.Length      0.000      0.000 0.000 0.000    0.000  0.000 0.000
## 2  Sepal.Width      0.002      0.008 0.002 0.002    0.002  0.002 0.004
## 3 Petal.Length      0.000      0.000 0.000 0.000    0.000  0.000 0.000
## 4  Petal.Width      0.000      0.000 0.000 0.000    0.000  0.000 0.000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Regardless of the &lt;em&gt;p&lt;/em&gt;-value adjustment method, the two species are different for all 4 variables. Note that the adjustment method should be chosen before looking at the results to avoid choosing the method based on the results.&lt;/p&gt;
&lt;p&gt;Below another function that allows to perform multiple Student’s t-tests or Wilcoxon tests at once and choose the &lt;em&gt;p&lt;/em&gt;-value adjustment method. The function also allows to specify whether samples are paired or unpaired and whether the variances are assumed to be equal or not. (The code has been adapted from Mark White’s &lt;a href=&#34;https://www.markhw.com/blog/t-table&#34; target=&#34;_blank&#34;&gt;article&lt;/a&gt;.)&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;t_table &amp;lt;- function(data, dvs, iv,
                    var_equal = TRUE,
                    p_adj = &amp;quot;none&amp;quot;,
                    alpha = 0.05,
                    paired = FALSE,
                    wilcoxon = FALSE) {
  if (!inherits(data, &amp;quot;data.frame&amp;quot;)) {
    stop(&amp;quot;data must be a data.frame&amp;quot;)
  }

  if (!all(c(dvs, iv) %in% names(data))) {
    stop(&amp;quot;at least one column given in dvs and iv are not in the data&amp;quot;)
  }

  if (!all(sapply(data[, dvs], is.numeric))) {
    stop(&amp;quot;all dvs must be numeric&amp;quot;)
  }

  if (length(unique(na.omit(data[[iv]]))) != 2) {
    stop(&amp;quot;independent variable must only have two unique values&amp;quot;)
  }

  out &amp;lt;- lapply(dvs, function(x) {
    if (paired == FALSE &amp;amp; wilcoxon == FALSE) {
      tres &amp;lt;- t.test(data[[x]] ~ data[[iv]], var.equal = var_equal)
    } else if (paired == FALSE &amp;amp; wilcoxon == TRUE) {
      tres &amp;lt;- wilcox.test(data[[x]] ~ data[[iv]])
    } else if (paired == TRUE &amp;amp; wilcoxon == FALSE) {
      tres &amp;lt;- t.test(data[[x]] ~ data[[iv]],
        var.equal = var_equal,
        paired = TRUE
      )
    } else {
      tres &amp;lt;- wilcox.test(data[[x]] ~ data[[iv]],
        paired = TRUE
      )
    }

    c(
      p_value = tres$p.value
    )
  })

  out &amp;lt;- as.data.frame(do.call(rbind, out))
  out &amp;lt;- cbind(variable = dvs, out)
  names(out) &amp;lt;- gsub(&amp;quot;[^0-9A-Za-z_]&amp;quot;, &amp;quot;&amp;quot;, names(out))

  out$p_value &amp;lt;- p.adjust(out$p_value, p_adj)
  out$conclusion &amp;lt;- ifelse(out$p_value &amp;lt; alpha,
    paste0(&amp;quot;Reject H0 at &amp;quot;, alpha * 100, &amp;quot;%&amp;quot;),
    paste0(&amp;quot;Do not reject H0 at &amp;quot;, alpha * 100, &amp;quot;%&amp;quot;)
  )
  out$p_value &amp;lt;- ifelse(out$p_value &amp;lt; 0.001,
    &amp;quot;&amp;lt;0.001&amp;quot;,
    round(out$p_value, 3)
  )

  return(out)
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Applied to our dataset, with no adjustment method for the &lt;em&gt;p&lt;/em&gt;-values:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;result &amp;lt;- t_table(
  data = dat,
  c(&amp;quot;Sepal.Length&amp;quot;, &amp;quot;Sepal.Width&amp;quot;, &amp;quot;Petal.Length&amp;quot;, &amp;quot;Petal.Width&amp;quot;),
  &amp;quot;Species&amp;quot;
)

result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       variable p_value      conclusion
## 1 Sepal.Length  &amp;lt;0.001 Reject H0 at 5%
## 2  Sepal.Width   0.002 Reject H0 at 5%
## 3 Petal.Length  &amp;lt;0.001 Reject H0 at 5%
## 4  Petal.Width  &amp;lt;0.001 Reject H0 at 5%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And with the &lt;span class=&#34;citation&#34;&gt;Holm (&lt;a href=&#34;#ref-holm1979simple&#34;&gt;1979&lt;/a&gt;)&lt;/span&gt; adjustment method:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;result &amp;lt;- t_table(
  data = dat,
  c(&amp;quot;Sepal.Length&amp;quot;, &amp;quot;Sepal.Width&amp;quot;, &amp;quot;Petal.Length&amp;quot;, &amp;quot;Petal.Width&amp;quot;),
  &amp;quot;Species&amp;quot;,
  p_adj = &amp;quot;holm&amp;quot;
)

result&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##       variable p_value      conclusion
## 1 Sepal.Length  &amp;lt;0.001 Reject H0 at 5%
## 2  Sepal.Width   0.002 Reject H0 at 5%
## 3 Petal.Length  &amp;lt;0.001 Reject H0 at 5%
## 4  Petal.Width  &amp;lt;0.001 Reject H0 at 5%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Again, with the Holm’s adjustment method, we conclude that, at the 5% significance level, the two species are significantly different from each other in terms of all 4 variables.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;anova&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;ANOVA&lt;/h2&gt;
&lt;p&gt;Below the same process with an ANOVA. Note that we reload the dataset &lt;code&gt;iris&lt;/code&gt; to include all three &lt;code&gt;Species&lt;/code&gt; this time:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris

# Edit from here
x &amp;lt;- which(names(dat) == &amp;quot;Species&amp;quot;) # name of grouping variable
y &amp;lt;- which(names(dat) == &amp;quot;Sepal.Length&amp;quot; # names of variables to test
| names(dat) == &amp;quot;Sepal.Width&amp;quot; |
  names(dat) == &amp;quot;Petal.Length&amp;quot; |
  names(dat) == &amp;quot;Petal.Width&amp;quot;)
method1 &amp;lt;- &amp;quot;anova&amp;quot; # one of &amp;quot;anova&amp;quot; or &amp;quot;kruskal.test&amp;quot;
method2 &amp;lt;- &amp;quot;t.test&amp;quot; # one of &amp;quot;wilcox.test&amp;quot; or &amp;quot;t.test&amp;quot;
my_comparisons &amp;lt;- list(c(&amp;quot;setosa&amp;quot;, &amp;quot;versicolor&amp;quot;), c(&amp;quot;setosa&amp;quot;, &amp;quot;virginica&amp;quot;), c(&amp;quot;versicolor&amp;quot;, &amp;quot;virginica&amp;quot;)) # comparisons for post-hoc tests
# Edit until here


# Edit at your own risk
for (i in y) {
  for (j in x) {
    p &amp;lt;- ggboxplot(dat,
      x = colnames(dat[j]), y = colnames(dat[i]),
      color = colnames(dat[j]),
      legend = &amp;quot;none&amp;quot;,
      palette = &amp;quot;npg&amp;quot;,
      add = &amp;quot;jitter&amp;quot;
    )
    print(
      p + stat_compare_means(aes(label = paste0(after_stat(method), &amp;quot;, p-value = &amp;quot;, after_stat(p.format))),
        method = method1, label.y = max(dat[, i], na.rm = TRUE)
      )
      + stat_compare_means(comparisons = my_comparisons, method = method2, label = &amp;quot;p.format&amp;quot;) # remove if p-value of ANOVA or Kruskal-Wallis test &amp;gt;= alpha
    )
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-7-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Like the improved routine for the t-test, I have noticed that students and non-expert professionals understand ANOVA results presented this way much more easily compared to the default R outputs.&lt;/p&gt;
&lt;p&gt;With one graph for each variable, it is easy to see that all species are different from each other in terms of all 4 variables.&lt;a href=&#34;#fn3&#34; class=&#34;footnote-ref&#34; id=&#34;fnref3&#34;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want to apply the same automated process to your data, you will need to modify the name of the grouping variable (&lt;code&gt;Species&lt;/code&gt;), the names of the variables you want to test (&lt;code&gt;Sepal.Length&lt;/code&gt;, etc.), whether you want to perform an &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; (&lt;code&gt;anova&lt;/code&gt;) or &lt;a href=&#34;https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/&#34;&gt;Kruskal-Wallis test&lt;/a&gt; (&lt;code&gt;kruskal.test&lt;/code&gt;) and finally specify the comparisons for the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/#post-hoc-test&#34;&gt;post-hoc tests&lt;/a&gt;.&lt;a href=&#34;#fn4&#34; class=&#34;footnote-ref&#34; id=&#34;fnref4&#34;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;to-go-even-further&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;To go even further&lt;/h1&gt;
&lt;p&gt;As we have seen, these two improved R routines allow to:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Perform t-tests and ANOVA on a small or large number of variables with only minor changes to the code. I basically only have to replace the variable names and the name of the test I want to use. It takes almost the same time to test one or several variables so it is quite an improvement compared to testing one variable at a time.&lt;/li&gt;
&lt;li&gt;Share test results in a much proper and cleaner way. This is possible thanks to a graph showing the observations by group and the &lt;em&gt;p&lt;/em&gt;-value of the appropriate test included directly on the graph. This is particularly important when communicating results to a wider audience or to people from diverse backgrounds.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, like most of my R routines, these two pieces of code are still a work in progress. Below are some additional features I have been thinking of and which could be added in the future to make the process of comparing two or more groups even more optimal:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add the possibility to select variables by their numbering in the dataframe. For the moment it is only possible to do it via their names. This will allow to automate the process even further because instead of typing all variable names one by one, we could simply type &lt;code&gt;4:25&lt;/code&gt; (to test variables 4 to 25 for instance).&lt;/li&gt;
&lt;li&gt;Add the possibility to choose a &lt;em&gt;p&lt;/em&gt;-value adjustment method. Currently, raw &lt;em&gt;p&lt;/em&gt;-values are displayed in the graphs and I manually adjust them afterwards or adjust the &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;When comparing more than two groups, it is only possible to apply an ANOVA or Kruskal-Wallis test at the moment. A major improvement would be to add the possibility to perform a repeated measures ANOVA (i.e., an ANOVA when the samples are dependent). It is currently already possible to do a t-test with two paired samples, but it is not yet possible to do the same with more than two groups.&lt;/li&gt;
&lt;li&gt;Another less important (yet still nice) feature when comparing more than 2 groups would be to automatically apply post-hoc tests only in the case where the null hypothesis of the ANOVA or Kruskal-Wallis test is rejected (so when there is at least one group different from the others, because if the null hypothesis of equal groups is not rejected we do not apply a post-hoc test). At the present time, I manually add or remove the code that displays the &lt;em&gt;p&lt;/em&gt;-values of post-hoc tests depending on the global &lt;em&gt;p&lt;/em&gt;-value of the ANOVA or Kruskal-Wallis test.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I will try to add these features in the future, or I would be glad to help if the author of the &lt;code&gt;{ggpubr}&lt;/code&gt; package needs help in including these features (I hope he will see this article!).&lt;/p&gt;
&lt;p&gt;Last but not least, the following packages may be of interest to some readers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you want to report statistical results on a graph, I advise you to check the &lt;a href=&#34;https://indrajeetpatil.github.io/ggstatsplot/&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{ggstatsplot}&lt;/code&gt; package&lt;/a&gt; and in particular the &lt;code&gt;ggbetweenstats()&lt;/code&gt; and &lt;code&gt;ggwithinstats()&lt;/code&gt; functions. These functions allow to compare a continuous variable across multiple groups or conditions (for both independent and paired samples). Two advantages of the functions is that:
&lt;ul&gt;
&lt;li&gt;it is very easy to switch from parametric to nonparametric tests and&lt;/li&gt;
&lt;li&gt;it automatically runs an ANOVA or t-test depending on the number of groups to compare&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that many different statistical results are displayed on the graph, not only the name of the test and the &lt;em&gt;p&lt;/em&gt;-value so a bit of simplicity and clarity is lost for more precision. However, it is still very convenient to be able to include tests results on a graph in order to combine the advantages of a visualization and a sound statistical analysis. Something that I still need to figure out is how to run the code on several variables at once.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;a href=&#34;https://cloud.r-project.org/web/packages/compareGroups/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{compareGroups}&lt;/code&gt; package&lt;/a&gt; also provides a nice way to compare groups. It comes with a really complete Shiny app, available with:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;compareGroups&amp;quot;)
library(compareGroups)
cGroupsWUI()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;update-with-the-ggstatsplot-package&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Update with the &lt;code&gt;{ggstatsplot}&lt;/code&gt; package&lt;/h1&gt;
&lt;p&gt;Several months after having written this article, I finally found a way to plot and run analyses on several variables at once with the package &lt;code&gt;{ggstatsplot}&lt;/code&gt; &lt;span class=&#34;citation&#34;&gt;(&lt;a href=&#34;#ref-patil2021ggstatsplot&#34;&gt;Patil 2021&lt;/a&gt;)&lt;/span&gt;. This was the main feature I was missing and which prevented me from using it more often.&lt;/p&gt;
&lt;p&gt;Although I still find that too much statistical details are displayed (in particular for non experts), I still believe the &lt;code&gt;ggbetweenstats()&lt;/code&gt; and &lt;code&gt;ggwithinstats()&lt;/code&gt; functions are worth mentioning in this article. I actually now use those two functions almost as often as my previous routines because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I do not have to care about the number of groups to compare, the functions automatically choose the appropriate test according to the number of groups (ANOVA for 3 groups or more, and t-test for 2 groups)&lt;/li&gt;
&lt;li&gt;I can select variables based on their column numbering, and not based on their names anymore (which prevents me from writing those variable names manually)&lt;/li&gt;
&lt;li&gt;When comparing 3 or more groups (so for ANOVA, Kruskal-Wallis, repeated measure ANOVA or Friedman), &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values of the post-hoc tests within each dependent variable are by default the adjusted &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values (Holm is the default but many adjustment methods are available)&lt;/li&gt;
&lt;li&gt;It is possible to compare both independent and paired samples, no matter the number of groups (remember that with the &lt;code&gt;ggpubr&lt;/code&gt; package I could only do paired samples for two samples, not for 3 samples)&lt;/li&gt;
&lt;li&gt;They allow to easily switch between the parametric and nonparametric version&lt;/li&gt;
&lt;li&gt;All this in a more concise manner using the &lt;code&gt;{purrr}&lt;/code&gt; package&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For those of you who are interested, below my updated R routine which include these functions and applied this time on the &lt;code&gt;penguins&lt;/code&gt; dataset.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(palmerpenguins)

dat &amp;lt;- penguins
str(dat)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## tibble [344 × 8] (S3: tbl_df/tbl/data.frame)
##  $ species          : Factor w/ 3 levels &amp;quot;Adelie&amp;quot;,&amp;quot;Chinstrap&amp;quot;,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ island           : Factor w/ 3 levels &amp;quot;Biscoe&amp;quot;,&amp;quot;Dream&amp;quot;,..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ bill_length_mm   : num [1:344] 39.1 39.5 40.3 NA 36.7 39.3 38.9 39.2 34.1 42 ...
##  $ bill_depth_mm    : num [1:344] 18.7 17.4 18 NA 19.3 20.6 17.8 19.6 18.1 20.2 ...
##  $ flipper_length_mm: int [1:344] 181 186 195 NA 193 190 181 195 193 190 ...
##  $ body_mass_g      : int [1:344] 3750 3800 3250 NA 3450 3650 3625 4675 3475 4250 ...
##  $ sex              : Factor w/ 2 levels &amp;quot;female&amp;quot;,&amp;quot;male&amp;quot;: 2 1 1 NA 1 2 1 2 NA NA ...
##  $ year             : int [1:344] 2007 2007 2007 2007 2007 2007 2007 2007 2007 2007 ...&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We illustrate the routine for two groups with the variables &lt;code&gt;sex&lt;/code&gt; (two factors) as independent variable, and the 4 quantitative continuous variables &lt;code&gt;bill_length_mm&lt;/code&gt;, &lt;code&gt;bill_depth_mm&lt;/code&gt;, &lt;code&gt;flipper_length_mm&lt;/code&gt; and &lt;code&gt;body_mass_g&lt;/code&gt; as dependent variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggstatsplot)
library(tibble)

# Comparison between sexes

# edit from here
x &amp;lt;- &amp;quot;sex&amp;quot;
cols &amp;lt;- 3:6 # the 4 continuous dependent variables
type &amp;lt;- &amp;quot;parametric&amp;quot; # given the large number of observations, we use the parametric version
paired &amp;lt;- FALSE # FALSE for independent samples, TRUE for paired samples
# edit until here

# edit at your own risk
plotlist &amp;lt;-
  purrr::pmap(
    .l = list(
      data = list(as_tibble(dat)),
      x = x,
      y = as.list(colnames(dat)[cols]),
      plot.type = &amp;quot;box&amp;quot;, # for boxplot
      type = type, # parametric or nonparametric
      pairwise.comparisons = TRUE, # to run post-hoc tests if more than 2 groups
      pairwise.display = &amp;quot;significant&amp;quot;, # show only significant differences
      bf.message = FALSE, # remove message about Bayes Factor
      centrality.plotting = FALSE # remove central measure
    ),
    .f = ifelse(paired, # automatically use ggwithinstats if paired samples, ggbetweenstats otherwise
      ggstatsplot::ggwithinstats,
      ggstatsplot::ggbetweenstats
    ),
    violin.args = list(width = 0, linewidth = 0) # remove violin plots and keep only boxplots
  )

# print all plots together with statistical results
for (i in 1:length(plotlist)) {
  print(plotlist[[i]])
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-10-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;We now illustrate the routine for 3 groups or more with the variable &lt;code&gt;species&lt;/code&gt; (three factors) as independent variable, and the 4 same dependent variables:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Comparison between species

# edit from here
x &amp;lt;- &amp;quot;species&amp;quot;
cols &amp;lt;- 3:6 # the 4 continuous dependent variables
type &amp;lt;- &amp;quot;parametric&amp;quot; # given the large number of observations, we use the parametric version
paired &amp;lt;- FALSE # FALSE for independent samples, TRUE for paired samples
# edit until here

# edit at your own risk
plotlist &amp;lt;-
  purrr::pmap(
    .l = list(
      data = list(as_tibble(dat)),
      x = x,
      y = as.list(colnames(dat)[cols]),
      plot.type = &amp;quot;box&amp;quot;, # for boxplot
      type = type, # parametric or nonparametric
      pairwise.comparisons = TRUE, # to run post-hoc tests if more than 2 groups
      pairwise.display = &amp;quot;significant&amp;quot;, # show only significant differences
      bf.message = FALSE, # remove message about Bayes Factor
      centrality.plotting = FALSE # remove central measure
    ),
    .f = ifelse(paired, # automatically use ggwithinstats if paired samples, ggbetweenstats otherwise
      ggstatsplot::ggwithinstats,
      ggstatsplot::ggbetweenstats
    ),
    violin.args = list(width = 0, linewidth = 0) # remove violin plots and keep only boxplots
  )

# print all plots together with statistical results
for (i in 1:length(plotlist)) {
  print(plotlist[[i]])
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-2.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-3.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;img src=&#34;https://statsandr.com/blog/2020-03-19-how-to-do-a-t-test-or-anova-for-many-variables-at-once-in-r-and-communicate-the-results-in-a-better-way_files/figure-html/unnamed-chunk-11-4.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, I only have to specify:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the name of the grouping variable (&lt;code&gt;sex&lt;/code&gt; and &lt;code&gt;species&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;the number of the dependent variables (variables 3 to 6 in the dataset),&lt;/li&gt;
&lt;li&gt;whether I want to use the parametric or nonparametric version and&lt;/li&gt;
&lt;li&gt;whether samples are independent (&lt;code&gt;paired = FALSE&lt;/code&gt;) or paired (&lt;code&gt;paired = TRUE&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Everything else is automated—the outputs show a graphical representation of what we are comparing, together with the details of the statistical analyses in the subtitle of the plot (the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value among others).&lt;/p&gt;
&lt;p&gt;Note that the code shown above is actually the same if I want to compare 2 groups or more than 2 groups. I wrote twice the same code (once for 2 groups and once again for 3 groups) for illustrative purposes only, but they are the same and should be treated as one for your projects.&lt;/p&gt;
&lt;!-- Feel free to discover the package and see how it works by yourself via this [Shiny app](https://antoinesoetewey.shinyapps.io/ggstatsplotShiny/){target=&#34;_blank&#34;}. --&gt;
&lt;p&gt;I must admit I am quite &lt;strong&gt;satisfied&lt;/strong&gt; with this routine, now that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I can automate it on many variables at once and I do not need to write the variable names manually anymore,&lt;/li&gt;
&lt;li&gt;at the same time, I can choose the appropriate test among all the available ones (depending on the number of groups, whether they are paired or not, and whether I want to use the parametric or nonparametric version).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nonetheless, I must also admit that I am still &lt;strong&gt;not satisfied&lt;/strong&gt; with the level of details of the statistical results. As already mentioned, many students get confused and get lost in front of so much information (except the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value and the number of observations, most of the details are rather obscure to them because they are not covered in introductory statistic classes).&lt;/p&gt;
&lt;p&gt;I saved time thanks to all improvements in comparison to my previous routine, but I definitely lose time when I have to point out to them what they should look for. After discussing with other professors, I noticed that they have the same problem.&lt;/p&gt;
&lt;p&gt;For the moment, you can only print all results or none. I have opened an &lt;a href=&#34;https://github.com/IndrajeetPatil/ggstatsplot/issues/669&#34; target=&#34;_blank&#34;&gt;issue&lt;/a&gt; kindly requesting to add the possibility to display only a summary (with the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-value and the name of the test for instance).&lt;a href=&#34;#fn5&#34; class=&#34;footnote-ref&#34; id=&#34;fnref5&#34;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt; I will update again this article if the maintainer of the package includes this feature in the future. So stay tuned!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article will help you to perform t-tests and ANOVA for multiple variables at once and make the results more easily readable and interpretable by non-scientists. Learn more about the &lt;a href=&#34;https://statsandr.com/blog/student-s-t-test-in-r-and-by-hand-how-to-compare-two-groups-under-different-scenarios/&#34;&gt;t-test&lt;/a&gt; to compare two groups, or the &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt; to compare 3 groups or more.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level1 unnumbered&#34;&gt;
&lt;h1&gt;References&lt;/h1&gt;
&lt;div id=&#34;refs&#34; class=&#34;references csl-bib-body hanging-indent&#34;&gt;
&lt;div id=&#34;ref-holm1979simple&#34; class=&#34;csl-entry&#34;&gt;
Holm, Sture. 1979. &lt;span&gt;“A Simple Sequentially Rejective Multiple Test Procedure.”&lt;/span&gt; &lt;em&gt;Scandinavian Journal of Statistics&lt;/em&gt;, 65–70.
&lt;/div&gt;
&lt;div id=&#34;ref-mcdonald2014multiple&#34; class=&#34;csl-entry&#34;&gt;
McDonald, JH. 2014. &lt;span&gt;“Multiple Tests.”&lt;/span&gt; &lt;em&gt;Handbook of Biological Statistics. 3rd Ed Baltimore, Maryland: Sparky House Publishing&lt;/em&gt;, 233–36.
&lt;/div&gt;
&lt;div id=&#34;ref-patil2021ggstatsplot&#34; class=&#34;csl-entry&#34;&gt;
Patil, Indrajeet. 2021. &lt;span&gt;“&lt;span class=&#34;nocase&#34;&gt;Visualizations with statistical details: The &lt;span class=&#34;nocase&#34;&gt;’ggstatsplot’&lt;/span&gt; approach&lt;/span&gt;.”&lt;/span&gt; &lt;em&gt;&lt;span class=&#34;nocase&#34;&gt;Journal of Open Source Software&lt;/span&gt;&lt;/em&gt; 6 (61): 3167. &lt;a href=&#34;https://doi.org/10.21105/joss.03167&#34;&gt;https://doi.org/10.21105/joss.03167&lt;/a&gt;.
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;In theory, an ANOVA can also be used to compare two groups as it will give the same results compared to a Student’s t-test, but in practice we use the Student’s t-test to compare two groups and the ANOVA to compare three groups or more.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn2&#34;&gt;&lt;p&gt;Do not forget to separate the variables you want to test with &lt;code&gt;|&lt;/code&gt;.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn3&#34;&gt;&lt;p&gt;Do not forget to adjust the &lt;span class=&#34;math inline&#34;&gt;\(p\)&lt;/span&gt;-values or the significance level &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. If you use the Bonferroni correction, the adjusted &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; is simply the desired &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt; level divided by the number of comparisons.&lt;a href=&#34;#fnref3&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn4&#34;&gt;&lt;p&gt;Post-hoc test is only the name used to refer to a specific type of statistical tests. Post-hoc test includes, among others, the Tukey HSD test, the Bonferroni correction, Dunnett’s test. Even if an ANOVA or a Kruskal-Wallis test can determine whether there is at least one group that is different from the others, it does not allow us to conclude &lt;strong&gt;which&lt;/strong&gt; are different from each other. For this purpose, there are post-hoc tests that compare all groups two by two to determine which ones are different, after adjusting for multiple comparisons. Concretely, post-hoc tests are performed to each possible pair of groups &lt;strong&gt;after&lt;/strong&gt; an ANOVA or a Kruskal-Wallis test has shown that there is at least one group which is different (hence “post” in the name of this type of test). The null and alternative hypotheses and the interpretations of these tests are similar to a Student’s t-test for two samples.&lt;a href=&#34;#fnref4&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn5&#34;&gt;&lt;p&gt;I am open to contribute to the package if I can help!&lt;a href=&#34;#fnref5&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>An efficient way to install and load R packages</title>
      <link>https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/</link>
      <pubDate>Fri, 31 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-is-an-r-package-and-how-to-use-it&#34; id=&#34;toc-what-is-an-r-package-and-how-to-use-it&#34;&gt;What is an R package and how to use it?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#inefficient-way-to-install-and-load-r-packages&#34; id=&#34;toc-inefficient-way-to-install-and-load-r-packages&#34;&gt;Inefficient way to install and load R packages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#more-efficient-way&#34; id=&#34;toc-more-efficient-way&#34;&gt;More efficient way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#most-efficient-way&#34; id=&#34;toc-most-efficient-way&#34;&gt;Most efficient way&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#pacman-package&#34; id=&#34;toc-pacman-package&#34;&gt;&lt;code&gt;{pacman}&lt;/code&gt; package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#librarian-package&#34; id=&#34;toc-librarian-package&#34;&gt;&lt;code&gt;{librarian}&lt;/code&gt; package&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages_files/0_6wKnVe1op_A5stKw.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;what-is-an-r-package-and-how-to-use-it&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What is an R package and how to use it?&lt;/h1&gt;
&lt;p&gt;Unlike other programs, only fundamental functionalities come by default with R. You will thus often need to install some “extensions” to perform the analyses you want. These extensions which are collections of functions and datasets developed and published by R users are called &lt;strong&gt;packages&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Packages extend existing base R functionalities by adding new ones. R is open source so everyone can write code and publish it as a package, and everyone can install a package and start using the functions or datasets built inside the package, all this for free.&lt;/p&gt;
&lt;p&gt;In order to use a package, it needs to be installed on your computer by running &lt;code&gt;install.packages(&#34;name_of_package&#34;)&lt;/code&gt; (do not forget &lt;code&gt;&#34;&#34;&lt;/code&gt; around the name of the package, otherwise R will look for an object saved under that name!). Once the package is installed, you must load the package and only after it has been loaded you can use all the functions and datasets it contains. To load a package, run &lt;code&gt;library(name_of_package)&lt;/code&gt; (this time &lt;code&gt;&#34;&#34;&lt;/code&gt; around the name of the package are optional, but can still be used if you wish).&lt;/p&gt;
&lt;p&gt;Note that packages must be &lt;strong&gt;installed only once&lt;/strong&gt; (until you update your R, then you have to install them again), whereas packages must be &lt;strong&gt;loaded every time you open R&lt;/strong&gt;.&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;inefficient-way-to-install-and-load-r-packages&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Inefficient way to install and load R packages&lt;/h1&gt;
&lt;p&gt;Depending on how long you have been using R, you may use a limited amount of packages or, on the contrary, a large amount of them. As you use more and more packages you will soon start to have (too) many lines of code just for installing and loading them.&lt;/p&gt;
&lt;p&gt;Here is a preview of the code from my PhD thesis showing how the installation and loading of R packages looked like when I started working on R (only a fraction of them are displayed to shorten the code):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Installation of required packages
install.packages(&amp;quot;tidyverse&amp;quot;)
install.packages(&amp;quot;ggplot2&amp;quot;)
install.packages(&amp;quot;readxl&amp;quot;)
install.packages(&amp;quot;dplyr&amp;quot;)
install.packages(&amp;quot;tidyr&amp;quot;)
install.packages(&amp;quot;ggfortify&amp;quot;)
install.packages(&amp;quot;DT&amp;quot;)
install.packages(&amp;quot;reshape2&amp;quot;)
install.packages(&amp;quot;knitr&amp;quot;)
install.packages(&amp;quot;lubridate&amp;quot;)

# Load packages
library(&amp;quot;tidyverse&amp;quot;)
library(&amp;quot;ggplot2&amp;quot;)
library(&amp;quot;readxl&amp;quot;)
library(&amp;quot;dplyr&amp;quot;)
library(&amp;quot;tidyr&amp;quot;)
library(&amp;quot;ggfortify&amp;quot;)
library(&amp;quot;DT&amp;quot;)
library(&amp;quot;reshape2&amp;quot;)
library(&amp;quot;knitr&amp;quot;)
library(&amp;quot;lubridate&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can guess the code became longer and longer as I needed more and more packages for my analyses. Moreover, I tended to reinstall all packages as I was working on 4 different computers and I could not remember which packages were already installed on which machine. Reinstalling all packages every time I opened my script or R Markdown document was a waste of time.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;more-efficient-way&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;More efficient way&lt;/h1&gt;
&lt;p&gt;Then one day, a colleague of mine shared some of his code with me. I am glad he did as he introduced me to a much more efficient way to install and load R packages. He gave me the permission to share the tip, so here is the code I now use to perform the task of installing and loading R packages:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Package names
packages &amp;lt;- c(&amp;quot;ggplot2&amp;quot;, &amp;quot;readxl&amp;quot;, &amp;quot;dplyr&amp;quot;, &amp;quot;tidyr&amp;quot;, &amp;quot;ggfortify&amp;quot;, &amp;quot;DT&amp;quot;, &amp;quot;reshape2&amp;quot;, &amp;quot;knitr&amp;quot;, &amp;quot;lubridate&amp;quot;, &amp;quot;pwr&amp;quot;, &amp;quot;psy&amp;quot;, &amp;quot;car&amp;quot;, &amp;quot;doBy&amp;quot;, &amp;quot;imputeMissings&amp;quot;, &amp;quot;RcmdrMisc&amp;quot;, &amp;quot;questionr&amp;quot;, &amp;quot;vcd&amp;quot;, &amp;quot;multcomp&amp;quot;, &amp;quot;KappaGUI&amp;quot;, &amp;quot;rcompanion&amp;quot;, &amp;quot;FactoMineR&amp;quot;, &amp;quot;factoextra&amp;quot;, &amp;quot;corrplot&amp;quot;, &amp;quot;ltm&amp;quot;, &amp;quot;goeveg&amp;quot;, &amp;quot;corrplot&amp;quot;, &amp;quot;FSA&amp;quot;, &amp;quot;MASS&amp;quot;, &amp;quot;scales&amp;quot;, &amp;quot;nlme&amp;quot;, &amp;quot;psych&amp;quot;, &amp;quot;ordinal&amp;quot;, &amp;quot;lmtest&amp;quot;, &amp;quot;ggpubr&amp;quot;, &amp;quot;dslabs&amp;quot;, &amp;quot;stringr&amp;quot;, &amp;quot;assist&amp;quot;, &amp;quot;ggstatsplot&amp;quot;, &amp;quot;forcats&amp;quot;, &amp;quot;styler&amp;quot;, &amp;quot;remedy&amp;quot;, &amp;quot;snakecaser&amp;quot;, &amp;quot;addinslist&amp;quot;, &amp;quot;esquisse&amp;quot;, &amp;quot;here&amp;quot;, &amp;quot;summarytools&amp;quot;, &amp;quot;magrittr&amp;quot;, &amp;quot;tidyverse&amp;quot;, &amp;quot;funModeling&amp;quot;, &amp;quot;pander&amp;quot;, &amp;quot;cluster&amp;quot;, &amp;quot;abind&amp;quot;)

# Install packages not yet installed
installed_packages &amp;lt;- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
  install.packages(packages[!installed_packages])
}

# Packages loading
invisible(lapply(packages, library, character.only = TRUE))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code for installing and loading R packages is more efficient in several ways:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;The function &lt;code&gt;install.packages()&lt;/code&gt; accepts a vector as argument, so one line of code for each package in the past is now one line including all packages&lt;/li&gt;
&lt;li&gt;In the second part of the code, it checks whether a package is already installed or not, and then install only the missing ones&lt;/li&gt;
&lt;li&gt;Regarding the packages loading (the last part of the code), the &lt;code&gt;lapply()&lt;/code&gt; function is used to call the &lt;code&gt;library()&lt;/code&gt; function on all packages at once, which makes the code more condense.&lt;/li&gt;
&lt;li&gt;The output when loading a package is rarely useful. The &lt;code&gt;invisible()&lt;/code&gt; function removes this output.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;From that day on, every time I need to use a new package, I simply add it to the vector &lt;code&gt;packages&lt;/code&gt; at the top of the code, which is located at the top of my scripts and R Markdown documents. No matter on which computer I am working on, running the entire code will install only the missing packages and will load all of them. This greatly reduced the running time for the installation and loading of my R packages.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;most-efficient-way&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Most efficient way&lt;/h1&gt;
&lt;div id=&#34;pacman-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{pacman}&lt;/code&gt; package&lt;/h2&gt;
&lt;p&gt;After this article was published, a reader informed me about the &lt;code&gt;{pacman}&lt;/code&gt; package. After having read the documentation and try it out myself, I learned that the function &lt;code&gt;p_load()&lt;/code&gt; from &lt;code&gt;{pacman}&lt;/code&gt; checks to see if a package is installed, if not it attempts to install the package and then loads it. It can also be applied to several packages at once, all this in a very condensed way:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;pacman&amp;quot;)

pacman::p_load(ggplot2, tidyr, dplyr)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Find more about this package on &lt;a href=&#34;https://cran.r-project.org/web/packages/pacman/index.html&#34; target=&#34;_blank&#34;&gt;CRAN&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;librarian-package&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;&lt;code&gt;{librarian}&lt;/code&gt; package&lt;/h2&gt;
&lt;p&gt;Like &lt;code&gt;{pacman}&lt;/code&gt;, the &lt;code&gt;shelf()&lt;/code&gt; function from the &lt;code&gt;{librarian}&lt;/code&gt; package automatically installs, updates, and loads R packages that are not yet installed in a single function. The function accepts packages from CRAN, GitHub, and Bioconductor (only if Bioconductor’s &lt;code&gt;Biobase&lt;/code&gt; package is installed). The function also accepts multiple package entries, provided as a comma-separated list of unquoted names (so no &lt;code&gt;&#34;&#34;&lt;/code&gt; around package names).&lt;/p&gt;
&lt;p&gt;Last but not least, the &lt;code&gt;{librarian}&lt;/code&gt; package allows to load packages automatically at the start of every R session (thanks to the &lt;code&gt;lib_startup()&lt;/code&gt; function) and search for new packages on CRAN by keywords or regular expressions (thanks to the &lt;code&gt;browse_cran()&lt;/code&gt; function).&lt;/p&gt;
&lt;p&gt;Here is an example of how to install missing packages and load them with the &lt;code&gt;shelf()&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# From CRAN:
install.packages(&amp;quot;librarian&amp;quot;)

librarian::shelf(ggplot2, DesiQuintans / desiderata, pander)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For CRAN packages, provide the package name as normal without &lt;code&gt;&#34;&#34;&lt;/code&gt; and for GitHub packages, provide the username and package name separated by &lt;code&gt;/&lt;/code&gt; (i.e., &lt;code&gt;UserName/RepoName&lt;/code&gt; as shown for the &lt;code&gt;desiderata&lt;/code&gt; package).&lt;/p&gt;
&lt;p&gt;Find more about this package on &lt;a href=&#34;https://cran.r-project.org/web/packages/librarian/index.html&#34; target=&#34;_blank&#34;&gt;CRAN&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope the article helped you to install and load R packages in a more efficient way.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A special thanks Danilo and James for informing me about the &lt;code&gt;{pacman}&lt;/code&gt; and &lt;code&gt;{librarian}&lt;/code&gt; packages.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;As suggested by Patrick, it is a good practice to &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/#insert-a-comment-in-r-and-r-markdown&#34;&gt;comment&lt;/a&gt; (with a &lt;code&gt;#&lt;/code&gt; in front of the line of code) the installation of your packages after they have been installed on your computer. This avoids installing packages on someone else’s computer when you share your code. If they want to install them before running your code, they will need to do it by themselves.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>RStudio addins, or how to make your coding life easier?</title>
      <link>https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/</link>
      <pubDate>Sun, 26 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#what-are-rstudio-addins&#34; id=&#34;toc-what-are-rstudio-addins&#34;&gt;What are RStudio addins?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#installation&#34; id=&#34;toc-installation&#34;&gt;Installation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#addins&#34; id=&#34;toc-addins&#34;&gt;Addins&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#esquisse&#34; id=&#34;toc-esquisse&#34;&gt;Esquisse&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#ggthemeassist&#34; id=&#34;toc-ggthemeassist&#34;&gt;ggThemeAssist&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#questionr&#34; id=&#34;toc-questionr&#34;&gt;Questionr&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#recoding-factors&#34; id=&#34;toc-recoding-factors&#34;&gt;Recoding factors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reordering-factors&#34; id=&#34;toc-reordering-factors&#34;&gt;Reordering factors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#categorize-a-numeric-variable&#34; id=&#34;toc-categorize-a-numeric-variable&#34;&gt;Categorize a numeric variable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#remedy&#34; id=&#34;toc-remedy&#34;&gt;Remedy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#styler&#34; id=&#34;toc-styler&#34;&gt;Styler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#snakecaser&#34; id=&#34;toc-snakecaser&#34;&gt;Snakecaser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#viewpipesteps&#34; id=&#34;toc-viewpipesteps&#34;&gt;ViewPipeSteps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ymlthis&#34; id=&#34;toc-ymlthis&#34;&gt;Ymlthis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reprex&#34; id=&#34;toc-reprex&#34;&gt;Reprex&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#blogdown&#34; id=&#34;toc-blogdown&#34;&gt;Blogdown&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addins.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;div id=&#34;what-are-rstudio-addins&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What are RStudio addins?&lt;/h1&gt;
&lt;p&gt;Although I have been using RStudio for several years, I only recently discovered RStudio addins. Since then, I am using these addins almost every time I use RStudio.&lt;/p&gt;
&lt;p&gt;What are RStudio addins? RStudio addins are extensions which provide a simple mechanism for executing advanced R functions from within RStudio. In simpler words, when executing an addin (by clicking a button in the Addins menu), the corresponding code is executed without you having to write the code. If it is still not clear, remember that for &lt;a href=&#34;https://statsandr.com/blog/how-to-import-an-excel-file-in-rstudio/&#34;&gt;importing a dataset in RStudio&lt;/a&gt;, you have two options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;import it by writing the code (thanks to the &lt;code&gt;read.csv()&lt;/code&gt; function for instance)&lt;/li&gt;
&lt;li&gt;or you can import it by clicking on the “Import Dataset” button in the Environment pane, set the importing settings, then click on “Import”&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An RStudio addin is exactly like the Import Dataset button but for other common functionalities. So you could write code as you can import a dataset by writing code, but thanks to RStudio addins you can execute code without actually writing the necessary code. By using the RStudio addins, RStudio will run the required code for you. RStudio addins can be as simple as a function that inserts a commonly used snippet of code, and as complex as a Shiny application that accepts input from the user to draw a plot. RStudio addins have the advantage that they allow you to execute complex and advanced code much more easily than if you would have to write it yourself.&lt;/p&gt;
&lt;p&gt;I believe addins are worth trying for all R users. Beginners will have the possibility to use functions that they would not have used otherwise because the code is too complex, whereas advanced users may find them useful to speed up the writing of their code in some circumstances. For other tips in R, see the article “&lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;Tips and tricks in RStudio and R Markdown&lt;/a&gt;”.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;installation&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Installation&lt;/h1&gt;
&lt;p&gt;RStudio Addins are distributed as R packages. So before being able to use them, you need to install them.&lt;/p&gt;
&lt;p&gt;You can install an addin exactly the same way you &lt;a href=&#34;https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/&#34;&gt;install a package&lt;/a&gt;: &lt;code&gt;install.packages(&#34;name_of_addin&#34;)&lt;/code&gt;. Once you have installed the R package that contains the addin, it will immediately become available within RStudio, via the Addins menu located at the top.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addins-toolbar.png&#34; alt=&#34;RStudio addins toolbar&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;RStudio addins toolbar&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;See this &lt;a href=&#34;https://rstudio.github.io/rstudioaddins/#registering-addins&#34; target=&#34;_blank&#34;&gt;guide&lt;/a&gt; if you want to install a personal package as addin. In short, you have to create an R package, put your functions in a specific file and RStudio will automatically discover and register these addins when your package is installed.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;addins&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Addins&lt;/h1&gt;
&lt;p&gt;If you are still not convinced, see below a list of the addins I find most useful together with concrete examples in the following sections.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;Esquisse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#questionr&#34;&gt;Questionr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#remedy&#34;&gt;Remedy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#styler&#34;&gt;Styler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#snakecaser&#34;&gt;Snakecaser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#viewpipesteps&#34;&gt;ViewPipeSteps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#ymlthis&#34;&gt;Ymlthis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#reprex&#34;&gt;Reprex&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#blogdown&#34;&gt;Blogdown&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that this list is not exhaustive and you are likely to find others useful too depending on what type of analyses you do on RStudio. Feel free to comment at the end of the article to let me know (and other readers) addins you found worth using.&lt;/p&gt;
&lt;div id=&#34;esquisse&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Esquisse&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;{esquisse}&lt;/code&gt; is an addin developed by a French company called &lt;a href=&#34;https://www.dreamrs.fr/&#34; target=&#34;_blank&#34;&gt;dreamRs&lt;/a&gt;. Here is how they define it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This addin allows you to interactively explore your data by visualizing it with the ggplot2 package. It allows you to draw bar plots, curves, scatter plots, histograms, boxplot and sf objects, then export the graph or retrieve the code to reproduce the graph.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;With this addin you can easily create beautiful graphs from the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt; and the best part according to me is that you can retrieve the code to reproduce the graph. Compared to the default &lt;code&gt;{graphics}&lt;/code&gt; package, it is true that graphs from the &lt;code&gt;{ggplot2}&lt;/code&gt; package look usually better but the code is also longer and more complex. With this addin, you can draw graphs from the &lt;code&gt;{ggplot2}&lt;/code&gt; package by dragging and dropping variables of interest in an user-friendly and interactive window, and then use the generated code in your script.&lt;/p&gt;
&lt;p&gt;For the sake of illustration, let’s say we want to create a scatter plot of the variables &lt;code&gt;Sepal.Length&lt;/code&gt; and &lt;code&gt;Petal.Length&lt;/code&gt; of the dataset &lt;code&gt;iris&lt;/code&gt; and color the points by the variable &lt;code&gt;Species&lt;/code&gt;. For this, follow these steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;load the dataset and rename it:&lt;a href=&#34;#fn1&#34; class=&#34;footnote-ref&#34; id=&#34;fnref1&#34;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dat &amp;lt;- iris&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;install the package &lt;code&gt;{esquisse}&lt;/code&gt;. This must be done only once&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;install.packages(&amp;quot;esquisse&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;open the ‘ggplot2’ builder from the RStudio Addins menu:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-RStudio-addin.png&#34; alt=&#34;Step 3: Open ‘ggplot2’ builder from the RStudio addins menu&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Open ‘ggplot2’ builder from the RStudio addins menu&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;4&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Select the dataset you want to work on (in this case &lt;code&gt;dat&lt;/code&gt;) and click on “Validate imported data” after checking that the number of observations and variables are correct (green box):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-rstudio-addin2.png&#34; alt=&#34;Step 4: Select dataset and validate the imported data&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 4: Select dataset and validate the imported data&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;5&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Drag and drop the variables of interest in the corresponding areas. In this case, we would like to draw a scatter plot of the variables &lt;code&gt;Sepal.Length&lt;/code&gt; and &lt;code&gt;Petal.Length&lt;/code&gt; and color points based on the variable &lt;code&gt;Species&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-rstudio-addin3.png&#34; alt=&#34;Step 5: Drag and drop the variables in the corresponding areas&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 5: Drag and drop the variables in the corresponding areas&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;6&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Click on “&amp;lt;/&amp;gt; Export &amp;amp; code” at the bottom right of the window. You can either copy the code and paste it where you want to place it in your script, or you can click on “Insert code in script” to place the code where your cursor is located in your script:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/esquisse-rstudio-addin4.png&#34; alt=&#34;Step 6: Retrieve the code to use it in your script&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6: Retrieve the code to use it in your script&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you chose the second option, the following code should appear where your cursor was located:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Sepal.Length, y = Petal.Length, colour = Species) +
  geom_point(shape = &amp;quot;circle&amp;quot;, size = 1.5) +
  scale_color_hue(direction = 1) +
  theme_minimal()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/figure-html/unnamed-chunk-4-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Many different options and customizations are possible (e.g., axis labels, colors, legend position, theme, data filtering, etc.). For this, use the buttons located at the bottom of the window (“Labels &amp;amp; title”, “Plot options” and “Data”). You can see the changes instantly in the window, and when the plot corresponds to your needs, export the code into your script.&lt;/p&gt;
&lt;p&gt;I will not go into more details regarding the different types of plots and the customizations, but make sure to try other types of plots by moving variables and customize it to see what is possible.&lt;/p&gt;
&lt;div id=&#34;ggthemeassist&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;ggThemeAssist&lt;/h3&gt;
&lt;p&gt;Note that there is another addin called &lt;code&gt;{ggThemeAssist}&lt;/code&gt; which helps you to edit the &lt;code&gt;theme()&lt;/code&gt; layer of a &lt;code&gt;{ggplot2}&lt;/code&gt; plot.&lt;/p&gt;
&lt;p&gt;This layer allows you to modify the appearance of the background, grids, axes, labels, legend, (sub)title, caption, etc.&lt;/p&gt;
&lt;p&gt;To use this addin:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write the code of the plot in &lt;code&gt;{ggplot2}&lt;/code&gt; (it does not work for a plot written in base R)&lt;/li&gt;
&lt;li&gt;Highlight the code&lt;/li&gt;
&lt;li&gt;Select the &lt;code&gt;{ggThemeAssist}&lt;/code&gt; addin in the addins menu&lt;/li&gt;
&lt;li&gt;Customize your plot according to your needs&lt;/li&gt;
&lt;li&gt;Click on the button Done and your code will be edited with your changes:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;ggplot(dat) +
  aes(x = Sepal.Length, y = Petal.Length, colour = Species) +
  geom_point(shape = &amp;quot;circle&amp;quot;, size = 1.5) +
  scale_color_hue(direction = 1) +
  theme_minimal() +
  theme(
    panel.grid.major = element_line(linetype = &amp;quot;blank&amp;quot;),
    panel.grid.minor = element_line(linetype = &amp;quot;blank&amp;quot;),
    legend.position = c(0.88, 0.22)
  ) +
  theme(plot.caption = element_text(face = &amp;quot;italic&amp;quot;)) +
  labs(
    title = &amp;quot;Sepal &amp;amp; petal length by species&amp;quot;,
    x = &amp;quot;Sepal length&amp;quot;, y = &amp;quot;Petal length&amp;quot;,
    caption = &amp;quot;Data: iris&amp;quot;
  )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/figure-html/unnamed-chunk-5-1.png&#34; alt=&#34;&#34; width=&#34;100%&#34; style=&#34;display: block; margin: auto;&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Find more information about the &lt;code&gt;theme()&lt;/code&gt; layer in this &lt;a href=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/ggplot_theme_system_cheatsheet.pdf&#34;&gt;cheatsheet&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;questionr&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Questionr&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;{questionr}&lt;/code&gt; addin is useful for survey analysis and when dealing with &lt;a href=&#34;https://statsandr.com/blog/data-types-in-r/#factor&#34;&gt;factor variables&lt;/a&gt;. With this addin, you can easily reorder and recode factor variables. The addin also allows to easily transform a numeric variable into factors (i.e., categorize a continuous variable) thanks to the &lt;code&gt;cut()&lt;/code&gt; function. Like any other addin, after having installed the &lt;code&gt;{questionr}&lt;/code&gt; package, you should see it appearing in the addins menu at the top. From the addins dropdown menu, choose whether you want to reorder or recode your factor variable, or categorize your numeric variable.&lt;/p&gt;
&lt;div id=&#34;recoding-factors&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Recoding factors&lt;/h3&gt;
&lt;p&gt;Instead of writing the &lt;code&gt;recode()&lt;/code&gt; function from the &lt;code&gt;{dplyr}&lt;/code&gt; package, we can use the &lt;code&gt;{questionr}&lt;/code&gt; addin.&lt;/p&gt;
&lt;p&gt;For this example, let’s say we want to recode the &lt;code&gt;Species&lt;/code&gt; variable to shorten the length of the factors, and then store this new variable as &lt;code&gt;Species_rec&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.04.35.png&#34; alt=&#34;Step 1: Select the variable to be recoded and the recoding settings&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Select the variable to be recoded and the recoding settings&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.04.39.png&#34; alt=&#34;Step 2: Specify the names of the new factors&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Specify the names of the new factors&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.04.42.png&#34; alt=&#34;Step 3: Check the results thanks to the contingency table and use the code at the top&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Check the results thanks to the contingency table and use the code at the top&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;reordering-factors&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Reordering factors&lt;/h3&gt;
&lt;p&gt;Similar to recoding, we can reorder factors thanks to the &lt;code&gt;{questionr}&lt;/code&gt; addin. Let’s say we want to reorder the 3 factors of the &lt;code&gt;Species&lt;/code&gt; variable such that the order is &lt;code&gt;versicolor&lt;/code&gt; then &lt;code&gt;virginica&lt;/code&gt; and finally &lt;code&gt;setosa&lt;/code&gt;. This can be done as follows:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.06.28.png&#34; alt=&#34;Step 1: Select the variable to reorder and the new variable name&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Select the variable to reorder and the new variable name&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.06.31.png&#34; alt=&#34;Step 2: Specify the order you want&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Specify the order you want&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.06.36.png&#34; alt=&#34;Step 3: Use the code at the top in your script&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Use the code at the top in your script&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;categorize-a-numeric-variable&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Categorize a numeric variable&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;{questionr}&lt;/code&gt; addin also allows to transform a numeric variable into a categorical variable. This is often done for the age, when age is transformed into age groups for instance. For this example, let’s say we want to create 3 categories of the variable &lt;code&gt;Sepal.Length&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.39.12.png&#34; alt=&#34;Step 1: Choose the variable to be transformed and the new variable name&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Choose the variable to be transformed and the new variable name&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.39.41.png&#34; alt=&#34;Step 2: Set the number of breaks equal to 3&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Set the number of breaks equal to 3&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;(Try by yourself the other cutting methods and see the results directly in the window.)&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.40.15.png&#34; alt=&#34;Step 3: Check the result thanks to the barplot at the bottom&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Check the result thanks to the barplot at the bottom&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-01-27%20at%2010.40.23.png&#34; alt=&#34;Step 4: Use the code in your script&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 4: Use the code in your script&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;remedy&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Remedy&lt;/h2&gt;
&lt;p&gt;If you often write in R Markdown, the &lt;code&gt;{remedy}&lt;/code&gt; addins will greatly facilitate your work. The addins allow you to add bold, creating lists, urls, italics, title (H1 to H6), footnote, etc. in an efficient way. I reckon that some of these tasks can be done faster by using the code directly rather than by going through the addins menu and then selecting the transformations you want. However, I personally cannot remember the code for all transformations, and it is quicker to apply it through the menu than by searching for the answer on Google or on your Markdown cheat sheet.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;styler&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Styler&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;{styler}&lt;/code&gt; addin allows to reformat your code in a more readable format by running &lt;code&gt;styler::tidyverse_style()&lt;/code&gt;. It works both for R scripts and R Markdown documents. You can either reformat the selected code, the active file or the active package. I find this addin particularly useful before sharing or publishing my code, so that it respects the most common styling guidelines for code.&lt;/p&gt;
&lt;p&gt;For instance, a piece of code like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1+1
#this is a comment
  for(i in 1:10){if(!i%%2){next}
print(i)
 }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;becomes much more neat and readable:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1 + 1
# this is a comment
for (i in 1:10) {
  if (!i %% 2) {
    next
  }
  print(i)
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;snakecaser&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Snakecaser&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;{snakecaser}&lt;/code&gt; addins converts a character string to the snake case styling. Snake case styling is the practice of writing character strings of several words separated by space into character strings with words separated with an underscore (&lt;code&gt;_&lt;/code&gt;). Moreover, it replaces capital letters with lowercases. For instance, the following string:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;This is the Test 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;will be transformed to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;this_is_the_test_1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The snake case styling is particularly useful (and even recommended by many R users) for variables, functions and file names, etc.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;viewpipesteps&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;ViewPipeSteps&lt;/h2&gt;
&lt;p&gt;Thanks to a reader of this article, I discovered the &lt;code&gt;ViewPipeSteps&lt;/code&gt; addin. This addin allows to print or view the output of your pipe chain after each step.&lt;/p&gt;
&lt;p&gt;For instance, here is a chain with the dataset &lt;code&gt;diamonds&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(tidyverse)

diamonds %&amp;gt;%
  select(carat, cut, color, clarity, price) %&amp;gt;%
  group_by(color) %&amp;gt;%
  summarise(n = n(), price = mean(price)) %&amp;gt;%
  arrange(desc(color))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 7 × 3
##   color     n price
##   &amp;lt;ord&amp;gt; &amp;lt;int&amp;gt; &amp;lt;dbl&amp;gt;
## 1 J      2808 5324.
## 2 I      5422 5092.
## 3 H      8304 4487.
## 4 G     11292 3999.
## 5 F      9542 3725.
## 6 E      9797 3077.
## 7 D      6775 3170.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are unsure about your pipe chain or want to debug it, you can view the output after each step by highlighting your entire chain then clicking on “View Pipe Chain Steps” from the addins menu:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-03-11%20at%2018.06.01.png&#34; /&gt;&lt;/p&gt;
&lt;p&gt;From the addins menu, you can choose to either print the result to the console, or view the result in a new pane (as if you called the function &lt;code&gt;View()&lt;/code&gt; after each step of the pipe). Clicking on View Pipe Chain Steps will open a new window with the output of each step:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/Screenshot%202020-03-11%20at%2018.09.59.png&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Note that you have to use the following command to install the &lt;code&gt;ViewPipeSteps&lt;/code&gt; addin:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;devtools::install_github(&amp;quot;daranzolin/ViewPipeSteps&amp;quot;)
library(ViewPipeSteps)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, you have no more excuses to use this pipe operator!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ymlthis&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Ymlthis&lt;/h2&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/ymlthis%20addin%20to%20write%20YAML%20header%20for%20R%20Markdown%20documents.png&#34; style=&#34;width:100.0%&#34; alt=&#34;ymlthis addin to easily write YAML header&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;ymlthis addin to easily write YAML header&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;a href=&#34;https://ymlthis.r-lib.org/index.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;ymlthis&lt;/code&gt; addin&lt;/a&gt; makes it easy to write YAML front matter for R Markdown and related documents. The addin will create YAML for you and put it in a file, such as an &lt;code&gt;.Rmd&lt;/code&gt; file, or on your clipboard.&lt;/p&gt;
&lt;p&gt;This addin is particularly useful if you want to write (more complicated) &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/#yaml-header&#34;&gt;YAML header&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;reprex&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Reprex&lt;/h2&gt;
&lt;p&gt;If you often ask the R community for help, this addin may be very useful!&lt;/p&gt;
&lt;p&gt;It is important to remember that when you ask someone for help, you have to help them help you by giving a precise and clear overview of your problem. This helps the community to quickly understand your issue and thus reduces the response time.&lt;/p&gt;
&lt;p&gt;In most cases, this involves providing a reproducible example, that is to say a piece of code (as small and as readable as possible) reproducing the problem encountered.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;{reprex}&lt;/code&gt; addin allows you to transform your reproducible example so that it can easily be shared on platforms such as GitHub, Stack Overflow, RStudio community, etc. The layout of your reproducible example will be adapted to the platform, and you can even include information about your R session.&lt;a href=&#34;#fn2&#34; class=&#34;footnote-ref&#34; id=&#34;fnref2&#34;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is how to use it steps by steps:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;First create your reproducible example in R (remember to keep it as short and readable as possible to save time to potential helpers):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example1.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Minimal reproducible example&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Minimal reproducible example&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Select the &lt;code&gt;{reprex}&lt;/code&gt; addin in the list of addins:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example2.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Select the {reprex} addin&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Select the {reprex} addin&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Select the platform on which you will post your issue (and check “Append session info” if you want to display your session info at the end of your reproducible example):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example3.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Set options in the {reprex} addin&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Set options in the {reprex} addin&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;4&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;You can now see the output of your reproducible example (right panel), but more importantly, it has been copied in your clipboard and it is now ready to be pasted on the platform of your choice:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example4.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Your reprex is copied in your clipboard&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Your reprex is copied in your clipboard&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;5&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Paste your reprex on the platform of your choice (here, it is posted as an issue on GitHub):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example5.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Paste your reprex&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Paste your reprex&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;6&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Check the final result of your reproducible example:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/best-rstudio-addins-in-rstudio-or-how-to-make-your-coding-life-easier_files/rstudio-addin-reprex-reproducible-example6.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Final result&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Final result&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;(Visit this GitHub &lt;a href=&#34;https://github.com/AntoineSoetewey/statsandr/issues/12&#34; target=&#34;_blank&#34;&gt;issue&lt;/a&gt; to see the final result.)&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;blogdown&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Blogdown&lt;/h2&gt;
&lt;p&gt;I put this addin at the end of the list because it will be of interest for only a limited number of RStudio users: people maintaining a blog written in R like this one (see why I recommend everyone to &lt;a href=&#34;https://statsandr.com/blog/7-benefits-of-sharing-your-code-in-a-data-science-blog/&#34;&gt;start a technical blog&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The most useful functionalities in this addin are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;New post: create a new post with &lt;code&gt;blogdown::new_post()&lt;/code&gt;. It can be used to create new pages as well, not only posts&lt;/li&gt;
&lt;li&gt;Insert image: insert an external image into a blog post&lt;/li&gt;
&lt;li&gt;Update metadata: update the title, author, date, categories and tags of the current blog post&lt;/li&gt;
&lt;li&gt;Serve site: run &lt;code&gt;blogdown::serve_site()&lt;/code&gt; to live preview your website locally&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope that you will find these addins useful for your future R-related projects. See other &lt;a href=&#34;https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/&#34;&gt;tips and tricks in RStudio and R Markdown&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes footnotes-end-of-document&#34;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&#34;fn1&#34;&gt;&lt;p&gt;You actually do not need to rename it. However, I often rename the datasets I work on with the same generic name &lt;code&gt;dat&lt;/code&gt; so when I reuse codes from a previous project for a new project, I do not have to change the name of the dataset in the code.&lt;a href=&#34;#fnref1&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li id=&#34;fn2&#34;&gt;&lt;p&gt;Thanks to Josep for the &lt;a href=&#34;https://medium.com/@josepmporra/great-post-you-could-have-a-look-to-reprex-addins-to-build-reproducible-examples-26bcdc0f8ed4&#34; target=&#34;_blank&#34;&gt;suggestion&lt;/a&gt;.&lt;a href=&#34;#fnref2&#34; class=&#34;footnote-back&#34;&gt;↩︎&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Tips and tricks in RStudio and R Markdown</title>
      <link>https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/</link>
      <pubDate>Tue, 21 Jan 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/tips-and-tricks-in-rstudio-and-r-markdown/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#run-code&#34; id=&#34;toc-run-code&#34;&gt;Run code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#insert-a-comment-in-r-and-r-markdown&#34; id=&#34;toc-insert-a-comment-in-r-and-r-markdown&#34;&gt;Insert a comment in R and R Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#knit-a-r-markdown-document&#34; id=&#34;toc-knit-a-r-markdown-document&#34;&gt;Knit a R Markdown document&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#code-snippets&#34; id=&#34;toc-code-snippets&#34;&gt;Code snippets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ordered-list-in-r-markdown&#34; id=&#34;toc-ordered-list-in-r-markdown&#34;&gt;Ordered list in R Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#new-code-chunk-in-r-markdown&#34; id=&#34;toc-new-code-chunk-in-r-markdown&#34;&gt;New code chunk in R Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#reformat-code&#34; id=&#34;toc-reformat-code&#34;&gt;Reformat code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#rstudio-addins&#34; id=&#34;toc-rstudio-addins&#34;&gt;RStudio addins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#pander-and-report-for-aesthetics&#34; id=&#34;toc-pander-and-report-for-aesthetics&#34;&gt;&lt;code&gt;{pander}&lt;/code&gt; and &lt;code&gt;{report}&lt;/code&gt; for aesthetics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#extract-equation-model-with-equatiomatic&#34; id=&#34;toc-extract-equation-model-with-equatiomatic&#34;&gt;Extract equation model with &lt;code&gt;{equatiomatic}&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#print-models-parameters&#34; id=&#34;toc-print-models-parameters&#34;&gt;Print model’s parameters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#pipe-operator&#34; id=&#34;toc-pipe-operator&#34;&gt;Pipe operator &lt;code&gt;%&amp;gt;%&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#others&#34; id=&#34;toc-others&#34;&gt;Others&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&#34;https://statsandr.com/blog/tips-and-tricks-in-r-markdown_files/tips-and-tricks-rstudio-and-r-markdown.jpeg&#34; style=&#34;width:100.0%&#34; /&gt;&lt;/p&gt;
&lt;p&gt;If you have the chance to work with an experienced programmer, you may be amazed by how fast she can write code. In this article, I share some tips and shortcuts you can use in RStudio and &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; to speed up the writing of your code.&lt;/p&gt;
&lt;div id=&#34;run-code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Run code&lt;/h1&gt;
&lt;p&gt;You most probably already know this shortcut but I still mention it for new R users. From your script you can run a chunk of code with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Enter on Mac
Ctrl + Enter on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;insert-a-comment-in-r-and-r-markdown&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Insert a comment in R and R Markdown&lt;/h1&gt;
&lt;p&gt;To insert a comment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Shift + C on Mac
Ctrl + Shift + C on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This shortcut can be used both for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;R code when you want to comment your code. It will add a &lt;code&gt;#&lt;/code&gt; at the beginning of the line&lt;/li&gt;
&lt;li&gt;for text in R Markdown. It will add &lt;code&gt;&amp;lt;!--&lt;/code&gt; and &lt;code&gt;--&amp;gt;&lt;/code&gt; around the text&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that if you want to comment more than one line, select all the lines you want to comment then use the shortcut. If you want to uncomment a comment, apply the same shortcut.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;knit-a-r-markdown-document&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Knit a R Markdown document&lt;/h1&gt;
&lt;p&gt;You can knit R Markdown documents by using this shortcut:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Shift + K on Mac
Ctrl + Shift + K on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;code-snippets&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Code snippets&lt;/h1&gt;
&lt;p&gt;Code snippets is usually a few characters long and is used as a shortcut to insert a common piece of code. You simply type a few characters then press &lt;code&gt;Tab&lt;/code&gt; and it will complete your code with a larger code. &lt;code&gt;Tab&lt;/code&gt; is then used again to navigate through the code where customization is required. For instance, if you type &lt;code&gt;fun&lt;/code&gt; then press &lt;code&gt;Tab&lt;/code&gt;, it will auto-complete the code with the required code to create a function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;name &amp;lt;- function(variables) {
  
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pressing &lt;code&gt;Tab&lt;/code&gt; again will jump through the placeholders for you to edit it. So you can first edit the name of the function, then the variables and finally the code inside the function (try by yourself!).&lt;/p&gt;
&lt;p&gt;There are many code snippets by default in RStudio. Here are the code snippets I use most often:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;lib&lt;/code&gt; to call &lt;code&gt;library()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(package)&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mat&lt;/code&gt; to create a matrix&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;matrix(data, nrow = rows, ncol = cols)&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;el&lt;/code&gt;, and &lt;code&gt;ei&lt;/code&gt; to create conditional expressions such as &lt;code&gt;if() {}&lt;/code&gt;, &lt;code&gt;else {}&lt;/code&gt; and &lt;code&gt;else if () {}&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;if (condition) {
  
}

else {
  
}

else if (condition) {
  
}&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fun&lt;/code&gt; to create a function&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;name &amp;lt;- function(variables) {

}&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;for&lt;/code&gt; to create for loops&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;for (variable in vector) {

}&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ts&lt;/code&gt; to insert a comment with the current date and time (useful if you have very long code and share it with others so they see when it has been edited)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Tue Jan 21 20:20:14 2020 ------------------------------&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;shinyapp&lt;/code&gt; every time I create a new &lt;a href=&#34;https://statsandr.com/tags/shiny/&#34;&gt;shiny app&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(shiny)

ui &amp;lt;- fluidPage()

server &amp;lt;- function(input, output, session) {

}

shinyApp(ui, server)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see all default code snippets and add yours by clicking on Tools &amp;gt; Global Options… &amp;gt; Code (left sidebar) &amp;gt; Edit Snippets…&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;ordered-list-in-r-markdown&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Ordered list in R Markdown&lt;/h1&gt;
&lt;p&gt;In R Markdown, when creating an ordered list such as this one:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Item 1&lt;/li&gt;
&lt;li&gt;Item 2&lt;/li&gt;
&lt;li&gt;Item 3&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Instead of bothering with the numbers and typing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Item 1
2. Item 2
3. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you can simply type&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Item 1
1. Item 2
1. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;for the exact same result (try it yourself or check the code of this article!). This way you do not need to bother which number is next when creating a new item.&lt;/p&gt;
&lt;p&gt;To go even further, any numeric will actually render the same result as long as the first item is the number you want to start from. For example, you could type:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Item 1
7. Item 2
3. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which renders&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Item 1&lt;/li&gt;
&lt;li&gt;Item 2&lt;/li&gt;
&lt;li&gt;Item 3&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, I suggest always using the number you want to start from for all items because if you move one item at the top, the list will start with this new number. For instance, if we move &lt;code&gt;7. Item 2&lt;/code&gt; from the previous list at the top, the list becomes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;7. Item 2
1. Item 1
3. Item 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which incorrectly renders&lt;/p&gt;
&lt;ol start=&#34;7&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Item 2&lt;/li&gt;
&lt;li&gt;Item 1&lt;/li&gt;
&lt;li&gt;Item 3&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&#34;new-code-chunk-in-r-markdown&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;New code chunk in R Markdown&lt;/h1&gt;
&lt;p&gt;When editing R Markdown documents, you will need to insert a new R code chunk many times. The following shortcuts will make your life easier:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + option + I on Mac (or command + alt + I depending on your keyboard)
Ctrl + ALT + I on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/tips-and-tricks-in-r-markdown_files/new%20R%20code%20chunk.png&#34; alt=&#34;&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;New R code chunk in R Markdown&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;reformat-code&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Reformat code&lt;/h1&gt;
&lt;p&gt;A clear and readable code is always easier and faster to read (and look more professional when sharing it to collaborators). To automatically apply the most common coding guidelines such as whitespaces, indents, etc., use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cmd + Shift + A on Mac
Ctrl + Shift + A on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So for example the following code which does not respect the guidelines (and which is not easy to read):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1+1
  for(i in 1:10){if(!i%%2){next}
print(i)
 }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;becomes much more neat and readable:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1 + 1
for (i in 1:10) {
  if (!i %% 2) {
    next
  }
  print(i)
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;rstudio-addins&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;RStudio addins&lt;/h1&gt;
&lt;p&gt;RStudio addins are extensions which provide a simple mechanism for executing advanced R functions from within RStudio. In simpler words, when executing an addin (by clicking a button in the Addins menu), the corresponding code is executed without you having to write the code. RStudio addins have the advantage that they allow you to execute complex and advanced code much more easily than if you would have to write it yourself.&lt;/p&gt;
&lt;p&gt;The addin I use most often is probably the &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/#esquisse&#34;&gt;&lt;code&gt;{esquisse}&lt;/code&gt; addin&lt;/a&gt;, which allows to draw plots with the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt; in a user-friendly and interactive way, and without having to write the code myself.&lt;/p&gt;
&lt;p&gt;RStudio addins are quite diverse and require a more detailed explanation, so I wrote an article focusing on these addins. See the article &lt;a href=&#34;https://statsandr.com/blog/rstudio-addins-or-how-to-make-your-coding-life-easier/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;pander-and-report-for-aesthetics&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;&lt;code&gt;{pander}&lt;/code&gt; and &lt;code&gt;{report}&lt;/code&gt; for aesthetics&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;pander()&lt;/code&gt; function from the &lt;code&gt;{pander}&lt;/code&gt; package is very useful for &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt; documents and reporting. It is not actually a shortcut but it greatly improves the aesthetics of R outputs.&lt;/p&gt;
&lt;p&gt;For instance, see below the difference between the default output of a &lt;a href=&#34;https://statsandr.com/blog/chi-square-test-of-independence-in-r/&#34;&gt;Chi-square test of independence&lt;/a&gt; and the output from the same test with the &lt;code&gt;pander()&lt;/code&gt; function (using the &lt;code&gt;diamonds&lt;/code&gt; dataset from the &lt;a href=&#34;https://statsandr.com/blog/graphics-in-r-with-ggplot2/&#34;&gt;&lt;code&gt;{ggplot2}&lt;/code&gt; package&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(ggplot2)
dat &amp;lt;- diamonds

test &amp;lt;- chisq.test(table(dat$cut, dat$color))
test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  Pearson&amp;#39;s Chi-squared test
## 
## data:  table(dat$cut, dat$color)
## X-squared = 310.32, df = 24, p-value &amp;lt; 2.2e-16&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(pander)
pander(test)&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:56%;&#34;&gt;
&lt;caption&gt;Pearson’s Chi-squared test: &lt;code&gt;table(dat$cut, dat$color)&lt;/code&gt;&lt;/caption&gt;
&lt;colgroup&gt;
&lt;col width=&#34;23%&#34; /&gt;
&lt;col width=&#34;6%&#34; /&gt;
&lt;col width=&#34;25%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;Test statistic&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;df&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;P value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;310.3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;24&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.395e-51 * * *&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;All information that you need are displayed in an elegant table. The &lt;code&gt;pander()&lt;/code&gt; function works on many statistical tests (not to say all of them, but I have not tried it on &lt;em&gt;all&lt;/em&gt; available tests in R) and on &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;regression models&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Linear model with lm()
model &amp;lt;- lm(price ~ carat + x + y + z,
  data = dat
)
model&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = price ~ carat + x + y + z, data = dat)
## 
## Coefficients:
## (Intercept)        carat            x            y            z  
##      1921.2      10233.9       -884.2        166.0       -576.2&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(model)&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:90%;&#34;&gt;
&lt;caption&gt;Fitting linear model: price ~ carat + x + y + z&lt;/caption&gt;
&lt;colgroup&gt;
&lt;col width=&#34;25%&#34; /&gt;
&lt;col width=&#34;15%&#34; /&gt;
&lt;col width=&#34;18%&#34; /&gt;
&lt;col width=&#34;13%&#34; /&gt;
&lt;col width=&#34;18%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt; &lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Estimate&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Std. Error&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;t value&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;Pr(&amp;gt;|t|)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;(Intercept)&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1921&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;104.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;18.41&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.977e-75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;carat&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;10234&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;62.94&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;162.6&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;x&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-884.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;40.47&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-21.85&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2.317e-105&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;y&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;166&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;25.86&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;6.421&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.365e-10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;z&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-576.2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;39.28&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;-14.67&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1.277e-48&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The pander function also makes datasets, tables, vectors, etc. more readable in R Markdown output. For example, see the differences below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;head(dat)[1:7] # first 6 observations of the first 7 variables&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## # A tibble: 6 × 7
##   carat cut       color clarity depth table price
##   &amp;lt;dbl&amp;gt; &amp;lt;ord&amp;gt;     &amp;lt;ord&amp;gt; &amp;lt;ord&amp;gt;   &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;int&amp;gt;
## 1  0.23 Ideal     E     SI2      61.5    55   326
## 2  0.21 Premium   E     SI1      59.8    61   326
## 3  0.23 Good      E     VS1      56.9    65   327
## 4  0.29 Premium   I     VS2      62.4    58   334
## 5  0.31 Good      J     SI2      63.3    58   335
## 6  0.24 Very Good J     VVS2     62.8    57   336&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(head(dat)[1:7])&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:86%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;16%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;13%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;col width=&#34;11%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;carat&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;cut&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;color&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;clarity&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;depth&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;table&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;price&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.23&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Ideal&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;61.5&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;55&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;326&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.21&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Premium&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;59.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;61&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;326&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.23&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Good&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS1&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;56.9&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;65&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;327&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.29&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Premium&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;I&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;62.4&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;58&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;334&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.31&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Good&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;J&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;63.3&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;58&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;335&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;0.24&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Very Good&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;J&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VVS2&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;62.8&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;57&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;336&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;summary(dat) # main descriptive statistics&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##      carat               cut        color        clarity          depth      
##  Min.   :0.2000   Fair     : 1610   D: 6775   SI1    :13065   Min.   :43.00  
##  1st Qu.:0.4000   Good     : 4906   E: 9797   VS2    :12258   1st Qu.:61.00  
##  Median :0.7000   Very Good:12082   F: 9542   SI2    : 9194   Median :61.80  
##  Mean   :0.7979   Premium  :13791   G:11292   VS1    : 8171   Mean   :61.75  
##  3rd Qu.:1.0400   Ideal    :21551   H: 8304   VVS2   : 5066   3rd Qu.:62.50  
##  Max.   :5.0100                     I: 5422   VVS1   : 3655   Max.   :79.00  
##                                     J: 2808   (Other): 2531                  
##      table           price             x                y         
##  Min.   :43.00   Min.   :  326   Min.   : 0.000   Min.   : 0.000  
##  1st Qu.:56.00   1st Qu.:  950   1st Qu.: 4.710   1st Qu.: 4.720  
##  Median :57.00   Median : 2401   Median : 5.700   Median : 5.710  
##  Mean   :57.46   Mean   : 3933   Mean   : 5.731   Mean   : 5.735  
##  3rd Qu.:59.00   3rd Qu.: 5324   3rd Qu.: 6.540   3rd Qu.: 6.540  
##  Max.   :95.00   Max.   :18823   Max.   :10.740   Max.   :58.900  
##                                                                   
##        z         
##  Min.   : 0.000  
##  1st Qu.: 2.910  
##  Median : 3.530  
##  Mean   : 3.539  
##  3rd Qu.: 4.040  
##  Max.   :31.800  
## &lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(summary(dat))&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;caption&gt;Table continues below&lt;/caption&gt;
&lt;colgroup&gt;
&lt;col width=&#34;22%&#34; /&gt;
&lt;col width=&#34;23%&#34; /&gt;
&lt;col width=&#34;12%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;carat&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;cut&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;color&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;clarity&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;depth&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Min. :0.2000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Fair : 1610&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;D: 6775&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI1 :13065&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. :43.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.:0.4000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Good : 4906&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;E: 9797&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS2 :12258&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.:61.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Median :0.7000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Very Good:12082&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;F: 9542&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;SI2 : 9194&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median :61.80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Mean :0.7979&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Premium :13791&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;G:11292&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VS1 : 8171&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean :61.75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.:1.0400&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Ideal :21551&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;H: 8304&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VVS2 : 5066&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.:62.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Max. :5.0100&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;I: 5422&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;VVS1 : 3655&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :79.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;J: 2808&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;(Other): 2531&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;colgroup&gt;
&lt;col width=&#34;19%&#34; /&gt;
&lt;col width=&#34;19%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;col width=&#34;20%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt;table&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;price&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;x&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;y&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;z&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Min. :43.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 326&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 0.000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 0.000&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Min. : 0.000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.:56.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 950&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 4.710&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 4.720&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1st Qu.: 2.910&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Median :57.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 2401&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 5.700&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 5.710&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Median : 3.530&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Mean :57.46&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 3933&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 5.731&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 5.735&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Mean : 3.539&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.:59.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 5324&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 6.540&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 6.540&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3rd Qu.: 4.040&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;Max. :95.00&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :18823&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :10.740&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :58.900&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;Max. :31.800&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;table(dat$cut, dat$color) # contingency table&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##            
##                D    E    F    G    H    I    J
##   Fair       163  224  312  314  303  175  119
##   Good       662  933  909  871  702  522  307
##   Very Good 1513 2400 2164 2299 1824 1204  678
##   Premium   1603 2337 2331 2924 2360 1428  808
##   Ideal     2834 3903 3826 4884 3115 2093  896&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(table(dat$cut, dat$color))&lt;/code&gt;&lt;/pre&gt;
&lt;table style=&#34;width:90%;&#34;&gt;
&lt;colgroup&gt;
&lt;col width=&#34;22%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;col width=&#34;9%&#34; /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;center&#34;&gt; &lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;D&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;E&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;F&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;G&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;H&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;I&lt;/th&gt;
&lt;th align=&#34;center&#34;&gt;J&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Fair&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;163&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;224&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;312&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;314&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;303&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;175&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;119&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Good&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;662&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;933&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;909&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;871&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;702&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;522&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;307&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Very Good&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1513&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2400&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2164&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2299&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1824&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1204&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;678&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Premium&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1603&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2337&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2331&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2924&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2360&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;1428&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;808&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;center&#34;&gt;&lt;strong&gt;Ideal&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2834&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3903&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3826&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;4884&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;3115&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;2093&lt;/td&gt;
&lt;td align=&#34;center&#34;&gt;896&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;names(dat) # variable names&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##  [1] &amp;quot;carat&amp;quot;   &amp;quot;cut&amp;quot;     &amp;quot;color&amp;quot;   &amp;quot;clarity&amp;quot; &amp;quot;depth&amp;quot;   &amp;quot;table&amp;quot;   &amp;quot;price&amp;quot;  
##  [8] &amp;quot;x&amp;quot;       &amp;quot;y&amp;quot;       &amp;quot;z&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(names(dat))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;carat&lt;/em&gt;, &lt;em&gt;cut&lt;/em&gt;, &lt;em&gt;color&lt;/em&gt;, &lt;em&gt;clarity&lt;/em&gt;, &lt;em&gt;depth&lt;/em&gt;, &lt;em&gt;table&lt;/em&gt;, &lt;em&gt;price&lt;/em&gt;, &lt;em&gt;x&lt;/em&gt;, &lt;em&gt;y&lt;/em&gt; and &lt;em&gt;z&lt;/em&gt;&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;rnorm(4) # generates 4 observations from a standard normal distribution&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1]  1.3709584 -0.5646982  0.3631284  0.6328626&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pander(rnorm(4))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;0.4043&lt;/em&gt;, &lt;em&gt;-0.1061&lt;/em&gt;, &lt;em&gt;1.512&lt;/em&gt; and &lt;em&gt;-0.09466&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This trick is particularly useful when writing in &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;R Markdown&lt;/a&gt;, as the generated document will look much nicer.&lt;/p&gt;
&lt;p&gt;Another trick for the aesthetics is the &lt;code&gt;report()&lt;/code&gt; function from the &lt;code&gt;{report}&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;Similar to &lt;code&gt;pander()&lt;/code&gt;, the &lt;code&gt;report()&lt;/code&gt; function allows to report test results in a more readable way—but it also interprets results for you. See for example with an &lt;a href=&#34;https://statsandr.com/blog/anova-in-r/&#34;&gt;ANOVA&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;remotes&amp;quot;)
# remotes::install_github(&amp;quot;easystats/report&amp;quot;) # You only need to do that once
library(&amp;quot;report&amp;quot;) # Load the package every time you start R

report(aov(price ~ cut,
  data = dat
))&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## The ANOVA (formula: price ~ cut) suggests that:
## 
##   - The main effect of cut is statistically significant and small (F(4, 53935) =
## 175.69, p &amp;lt; .001; Eta2 = 0.01, 95% CI [0.01, 1.00])
## 
## Effect sizes were labelled following Field&amp;#39;s (2013) recommendations.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In addition to the &lt;em&gt;p&lt;/em&gt;-value and the test statistic, the result of the test is displayed and interpreted for you.&lt;/p&gt;
&lt;p&gt;Note that the &lt;code&gt;report()&lt;/code&gt; function can be used for other analyses. See more examples in the package’s &lt;a href=&#34;https://easystats.github.io/report/&#34; target=&#34;_blank&#34;&gt;documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;extract-equation-model-with-equatiomatic&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Extract equation model with &lt;code&gt;{equatiomatic}&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;If you often need to write equations corresponding to statistical models in R Markdown reports, the &lt;a href=&#34;https://CRAN.R-project.org/package=equatiomatic&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;{equatiomatic}&lt;/code&gt;&lt;/a&gt; will help you to save time.&lt;/p&gt;
&lt;p&gt;Here is a basic example with a simple &lt;a href=&#34;https://statsandr.com/blog/multiple-linear-regression-made-simple/&#34;&gt;linear regression&lt;/a&gt; using the same dataset as above (i.e., &lt;code&gt;diamonds&lt;/code&gt; from &lt;code&gt;{ggplot2}&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# install.packages(&amp;quot;equatiomatic&amp;quot;)
library(equatiomatic)

# fit a basic multiple linear regression model
model &amp;lt;- lm(price ~ carat,
  data = dat
)

extract_eq(model,
  use_coefs = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\operatorname{\widehat{price}} = -2256.36 + 7756.43(\operatorname{carat})
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If the equation is long, you can display it on multiple lines by adding the argument &lt;code&gt;wrap = TRUE&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;model &amp;lt;- lm(price ~ carat + x + y + z + depth,
  data = dat
)

extract_eq(model,
  use_coefs = TRUE,
  wrap = TRUE,
  terms_per_line = 2
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{aligned}
\operatorname{\widehat{price}} &amp;amp;= 12196.69 + 10615.5(\operatorname{carat})\ - \\
&amp;amp;\quad 1369.67(\operatorname{x}) + 97.6(\operatorname{y})\ + \\
&amp;amp;\quad 64.2(\operatorname{z}) - 156.62(\operatorname{depth})
\end{aligned}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you use it in R Markdown, you need to add &lt;code&gt;results = &#39;asis&#39;&lt;/code&gt; for that specific code chunk, otherwise the equation will be rendered as a LaTeX equation&lt;/li&gt;
&lt;li&gt;At the time of writing, it works only for PDF and HTML output and not for Word&lt;/li&gt;
&lt;li&gt;The default number of terms per line is 4. You can change that with the &lt;code&gt;terms_per_line&lt;/code&gt; argument&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{equatiomatic}&lt;/code&gt; supports output from logistic regression as well. See all supported models in the &lt;a href=&#34;https://cran.r-project.org/web/packages/equatiomatic/vignettes/equatiomatic.html&#34; target=&#34;_blank&#34;&gt;vignette&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;If you need the theoretical model without the actual parameter estimates, remove the &lt;code&gt;use_coefs&lt;/code&gt; argument:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;extract_eq(model,
  wrap = TRUE
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{aligned}
\operatorname{price} &amp;amp;= \alpha + \beta_{1}(\operatorname{carat}) + \beta_{2}(\operatorname{x}) + \beta_{3}(\operatorname{y})\ + \\
&amp;amp;\quad \beta_{4}(\operatorname{z}) + \beta_{5}(\operatorname{depth}) + \epsilon
\end{aligned}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In that case, I prefer to use &lt;span class=&#34;math inline&#34;&gt;\(\beta_0\)&lt;/span&gt; as intercept instead of &lt;span class=&#34;math inline&#34;&gt;\(\alpha\)&lt;/span&gt;. You can change that with the &lt;code&gt;intercept = &#34;beta&#34;&lt;/code&gt; argument:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;extract_eq(model,
  wrap = TRUE,
  intercept = &amp;quot;beta&amp;quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
\begin{aligned}
\operatorname{price} &amp;amp;= \beta_{0} + \beta_{1}(\operatorname{carat}) + \beta_{2}(\operatorname{x}) + \beta_{3}(\operatorname{y})\ + \\
&amp;amp;\quad \beta_{4}(\operatorname{z}) + \beta_{5}(\operatorname{depth}) + \epsilon
\end{aligned}
\]&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;print-models-parameters&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Print model’s parameters&lt;/h1&gt;
&lt;p&gt;Thanks to the &lt;code&gt;print_html()&lt;/code&gt; and &lt;code&gt;model_parameters()&lt;/code&gt; functions from the &lt;code&gt;{parameters}&lt;/code&gt; packages, you can print a summary of a model in a nicely formatted way to make the output more readable in your HTML file. See for instance with the multiple linear regression presented above:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(parameters)
library(gt)

print_html(model_parameters(model, summary = TRUE))&lt;/code&gt;&lt;/pre&gt;
&lt;div id=&#34;ntzrociyde&#34; style=&#34;padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;&#34;&gt;
&lt;style&gt;html {
  font-family: -apple-system, BlinkMacSystemFont, &#39;Segoe UI&#39;, Roboto, Oxygen, Ubuntu, Cantarell, &#39;Helvetica Neue&#39;, &#39;Fira Sans&#39;, &#39;Droid Sans&#39;, Arial, sans-serif;
}

#ntzrociyde .gt_table {
  display: table;
  border-collapse: collapse;
  margin-left: auto;
  margin-right: auto;
  color: #333333;
  font-size: 100%;
  font-weight: normal;
  font-style: normal;
  background-color: #FFFFFF;
  width: auto;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #A8A8A8;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #A8A8A8;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
}

#ntzrociyde .gt_heading {
  background-color: #FFFFFF;
  text-align: center;
  border-bottom-color: #FFFFFF;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_caption {
  padding-top: 4px;
  padding-bottom: 4px;
}

#ntzrociyde .gt_title {
  color: #333333;
  font-size: 125%;
  font-weight: initial;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-color: #FFFFFF;
  border-bottom-width: 0;
}

#ntzrociyde .gt_subtitle {
  color: #333333;
  font-size: 85%;
  font-weight: initial;
  padding-top: 0;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-color: #FFFFFF;
  border-top-width: 0;
}

#ntzrociyde .gt_bottom_border {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ntzrociyde .gt_col_headings {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_col_heading {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
  overflow-x: hidden;
}

#ntzrociyde .gt_column_spanner_outer {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: normal;
  text-transform: inherit;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 4px;
  padding-right: 4px;
}

#ntzrociyde .gt_column_spanner_outer:first-child {
  padding-left: 0;
}

#ntzrociyde .gt_column_spanner_outer:last-child {
  padding-right: 0;
}

#ntzrociyde .gt_column_spanner {
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: bottom;
  padding-top: 5px;
  padding-bottom: 5px;
  overflow-x: hidden;
  display: inline-block;
  width: 100%;
}

#ntzrociyde .gt_group_heading {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  text-align: left;
}

#ntzrociyde .gt_empty_group_heading {
  padding: 0.5px;
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  vertical-align: middle;
}

#ntzrociyde .gt_from_md &gt; :first-child {
  margin-top: 0;
}

#ntzrociyde .gt_from_md &gt; :last-child {
  margin-bottom: 0;
}

#ntzrociyde .gt_row {
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
  margin: 10px;
  border-top-style: solid;
  border-top-width: 1px;
  border-top-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 1px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 1px;
  border-right-color: #D3D3D3;
  vertical-align: middle;
  overflow-x: hidden;
}

#ntzrociyde .gt_stub {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_stub_row_group {
  color: #333333;
  background-color: #FFFFFF;
  font-size: 100%;
  font-weight: initial;
  text-transform: inherit;
  border-right-style: solid;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
  padding-left: 5px;
  padding-right: 5px;
  vertical-align: top;
}

#ntzrociyde .gt_row_group_first td {
  border-top-width: 2px;
}

#ntzrociyde .gt_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_first_summary_row {
  border-top-style: solid;
  border-top-color: #D3D3D3;
}

#ntzrociyde .gt_first_summary_row.thick {
  border-top-width: 2px;
}

#ntzrociyde .gt_last_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ntzrociyde .gt_grand_summary_row {
  color: #333333;
  background-color: #FFFFFF;
  text-transform: inherit;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_first_grand_summary_row {
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-style: double;
  border-top-width: 6px;
  border-top-color: #D3D3D3;
}

#ntzrociyde .gt_striped {
  background-color: rgba(128, 128, 128, 0.05);
}

#ntzrociyde .gt_table_body {
  border-top-style: solid;
  border-top-width: 2px;
  border-top-color: #D3D3D3;
  border-bottom-style: solid;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
}

#ntzrociyde .gt_footnotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_footnote {
  margin: 0px;
  font-size: 90%;
  padding-left: 4px;
  padding-right: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_sourcenotes {
  color: #333333;
  background-color: #FFFFFF;
  border-bottom-style: none;
  border-bottom-width: 2px;
  border-bottom-color: #D3D3D3;
  border-left-style: none;
  border-left-width: 2px;
  border-left-color: #D3D3D3;
  border-right-style: none;
  border-right-width: 2px;
  border-right-color: #D3D3D3;
}

#ntzrociyde .gt_sourcenote {
  font-size: 90%;
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 5px;
  padding-right: 5px;
}

#ntzrociyde .gt_left {
  text-align: left;
}

#ntzrociyde .gt_center {
  text-align: center;
}

#ntzrociyde .gt_right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#ntzrociyde .gt_font_normal {
  font-weight: normal;
}

#ntzrociyde .gt_font_bold {
  font-weight: bold;
}

#ntzrociyde .gt_font_italic {
  font-style: italic;
}

#ntzrociyde .gt_super {
  font-size: 65%;
}

#ntzrociyde .gt_footnote_marks {
  font-style: italic;
  font-weight: normal;
  font-size: 75%;
  vertical-align: 0.4em;
}

#ntzrociyde .gt_asterisk {
  font-size: 100%;
  vertical-align: 0;
}

#ntzrociyde .gt_indent_1 {
  text-indent: 5px;
}

#ntzrociyde .gt_indent_2 {
  text-indent: 10px;
}

#ntzrociyde .gt_indent_3 {
  text-indent: 15px;
}

#ntzrociyde .gt_indent_4 {
  text-indent: 20px;
}

#ntzrociyde .gt_indent_5 {
  text-indent: 25px;
}
&lt;/style&gt;
&lt;table class=&#34;gt_table&#34;&gt;
  
  &lt;thead class=&#34;gt_col_headings&#34;&gt;
    &lt;tr&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_left&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;Parameter&#34;&gt;Parameter&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;Coefficient&#34;&gt;Coefficient&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;SE&#34;&gt;SE&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;95% CI&#34;&gt;95% CI&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;t(53934)&#34;&gt;t(53934)&lt;/th&gt;
      &lt;th class=&#34;gt_col_heading gt_columns_bottom_border gt_center&#34; rowspan=&#34;1&#34; colspan=&#34;1&#34; scope=&#34;col&#34; id=&#34;p&#34;&gt;p&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody class=&#34;gt_table_body&#34;&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;12196.69&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;367.64&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(11476.10, 12917.27)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;33.18&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;carat&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;10615.50&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;63.81&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(10490.43, 10740.56)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;166.37&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;x&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;-1369.67&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;43.48&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-1454.89, -1284.45)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;-31.50&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;y&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;97.60&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;25.76&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(47.10, 148.10)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;3.79&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;z&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;64.20&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;44.75&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-23.51, 151.91)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;1.43&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;0.151 &lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td headers=&#34;Parameter&#34; class=&#34;gt_row gt_left&#34; style=&#34;border-right-width: 1px; border-right-style: solid; border-right-color: #d3d3d3;&#34;&gt;depth&lt;/td&gt;
&lt;td headers=&#34;Coefficient&#34; class=&#34;gt_row gt_center&#34;&gt;-156.62&lt;/td&gt;
&lt;td headers=&#34;SE&#34; class=&#34;gt_row gt_center&#34;&gt;5.38&lt;/td&gt;
&lt;td headers=&#34;95% CI&#34; class=&#34;gt_row gt_center&#34;&gt;(-167.16, -146.09)&lt;/td&gt;
&lt;td headers=&#34;t(53934)&#34; class=&#34;gt_row gt_center&#34;&gt;-29.13&lt;/td&gt;
&lt;td headers=&#34;p&#34; class=&#34;gt_row gt_center&#34;&gt;&amp;lt; .001&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;tfoot class=&#34;gt_sourcenotes&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;gt_sourcenote&#34; colspan=&#34;6&#34;&gt;Model: price ~ carat + x + y + z + depth (53940 Observations)&lt;br&gt;Residual standard deviation: 1512.175 (df = 53934)&lt;br&gt;R2: 0.856; adjusted R2: 0.856&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tfoot&gt;
  
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;pipe-operator&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Pipe operator &lt;code&gt;%&amp;gt;%&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;If you are using the &lt;code&gt;{dplyr}&lt;/code&gt;, &lt;code&gt;{tidyverse}&lt;/code&gt; or &lt;code&gt;{magrittr}&lt;/code&gt; packages often, here is a shortcut for the pipe operator &lt;code&gt;%&amp;gt;%&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;command + Shift + M on Mac
Ctrl + Shift + M on Windows&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;others&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Others&lt;/h1&gt;
&lt;p&gt;Similar to many other programs, you can also use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;command + Shift + N&lt;/code&gt; on Mac and &lt;code&gt;Ctrl + Shift + N&lt;/code&gt; on Windows to open a new R Script&lt;/li&gt;
&lt;li&gt;&lt;code&gt;command + S&lt;/code&gt; on Mac and &lt;code&gt;Ctrl + S&lt;/code&gt; on Windows to save your current script or R Markdown document&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope you find these tips and tricks useful. If you are using others, feel free to share them in the comment section. See this &lt;a href=&#34;https://statsandr.com/blog/getting-started-in-r-markdown/&#34;&gt;starting guide in R Markdown&lt;/a&gt; if you are not familiar with it.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>