>

>

How to use R for high school research data analysis

How to use R for high school research data analysis

Princeton Journal of Pre-Collegiate Research

High school student analyzing research data using R programming language on a laptop with statistical charts visible on screen

Learning how to use R for high school research data analysis can transform a good research project into a genuinely publishable one. R is free, powerful, and used by professional researchers at universities worldwide, which means you are not learning a workaround tool. You are learning the real thing.

This guide walks you through R from installation to interpretation. No prior programming experience is required. What is required is a willingness to be precise, patient, and methodical about your data.

Why R Belongs in Your High School Research Toolkit

Most students default to Excel or Google Sheets for data analysis. Those tools are fine for basic calculations, but they fall short when your research demands statistical rigor. R was built specifically for statistical computing, and it handles tasks that spreadsheets simply cannot, including regression modeling, hypothesis testing, and publication-quality data visualization.

Peer-reviewed journals, including those that publish pre-collegiate research, expect data to be analyzed with appropriate statistical methods. Submitting a paper with R-generated outputs signals to reviewers that you took your methodology seriously (and that your findings are reproducible). Reproducibility is a cornerstone of credible research. It means another researcher could run your exact code and get your exact results.

If you are planning to submit original work for publication, understanding how to analyze data rigorously is non-negotiable. Our guide on How To Analyze Data In A High School Research Project covers the broader analytical framework, and R fits directly into that framework as your primary instrument.

Setting Up R and RStudio

R is the programming language. RStudio is the interface that makes working with R far more manageable. You need both, and both are free.

  1. Download R from cran.r-project.org and install it first.

  2. Download RStudio Desktop from posit.co and install it second.

  3. Open RStudio. You will see four panels: the console, the script editor, the environment, and the files or plots panel.

The console is where R executes commands immediately. The script editor is where you write and save your full analysis code. Always write your analysis in the script editor, not just the console. That way, your entire workflow is documented and reproducible from start to finish.

Installing Your First Packages

R's base installation covers a lot, but packages extend its capabilities significantly. For high school research data analysis, three packages will handle most of what you need.

  • tidyverse: A collection of packages for data manipulation and visualization, including ggplot2 and dplyr.

  • readr: Simplifies importing CSV files, which is how most survey and experimental data arrives.

  • psych: Provides descriptive statistics functions particularly useful for social science and psychology research.

Install them by typing the following into your console and pressing Enter:

install.packages(c("tidyverse", "readr", "psych"))

You only install packages once. After that, you load them at the start of each session using the library() function. For example: library(tidyverse).

How to Use R for High School Research Data Analysis: The Core Workflow

Every research data analysis in R follows the same basic sequence: import, inspect, clean, analyze, visualize, interpret. Master this sequence and you can apply it to any dataset in any discipline.

Step 1: Import Your Data

Save your data as a CSV file. Most survey platforms like Google Forms and Qualtrics export directly to CSV. Use the following command to import it into R:

data <- read_csv("your_file_name.csv")

Replace your_file_name.csv with your actual file name. The <- symbol assigns the imported data to an object called data. You can name this object anything meaningful to your project, such as survey_results or experiment_data.

Step 2: Inspect Your Data

Before analyzing anything, understand what you have. These three commands are your starting point:

  • head(data): Displays the first six rows so you can confirm the import worked correctly.

  • str(data): Shows the structure, including variable names and data types.

  • summary(data): Provides basic descriptive statistics for every variable, including minimum, maximum, mean, and median values.

Inspection is not optional. Skipping it is how errors enter your analysis undetected and undermine your conclusions.

Step 3: Clean Your Data

Real data is messy. Responses may be missing, variables may be mislabeled, and outliers may distort your results. The dplyr package (part of tidyverse) handles most cleaning tasks efficiently.

To remove rows with missing values: data <- na.omit(data)

To rename a column: data <- rename(data, new_name = old_name)

To filter out implausible values (for example, ages below 10 in a high school study): data <- filter(data, age >= 10)

Document every cleaning decision in your script with a comment (lines starting with # in R are comments and do not execute). Reviewers and journal editors may ask how you handled data irregularities. Your script is your answer.

Running Statistical Tests in R

The statistical test you choose depends on your research question and the type of data you collected. Here are the most commonly applicable tests for high school research projects.

Descriptive Statistics

Start every analysis with descriptive statistics. They summarize your data before you make any inferential claims. Use the describe() function from the psych package for a comprehensive output:

describe(data)

This returns mean, standard deviation, median, skewness, and kurtosis for every numeric variable. Include a descriptive statistics table in your paper's methods or results section. It gives readers the context they need to evaluate your findings.

Comparing Two Groups: The t-Test

If your research question asks whether two groups differ on a continuous variable (for example, whether students who sleep more than eight hours score higher on a focus assessment), use a t-test:

t.test(score ~ group, data = data)

R will return a t-statistic, degrees of freedom, p-value, and confidence interval. A p-value below 0.05 conventionally indicates a statistically significant difference between groups (though always interpret this in context, not in isolation).

Examining Relationships: Correlation and Regression

To measure the relationship between two continuous variables, use correlation:

cor(data$variable1, data$variable2)

For a more complete analysis that controls for other variables or predicts an outcome, use linear regression:

model <- lm(outcome ~ predictor1 + predictor2, data = data)
summary(model)

The summary output includes coefficients, standard errors, and an R-squared value indicating how much variance in your outcome your predictors explain. Regression is particularly powerful for social science, public health, and economics research at the pre-collegiate level.

Categorical Data: Chi-Square Test

When both your variables are categorical (for example, gender and preference for a policy option), use a chi-square test:

chisq.test(table(data$variable1, data$variable2))

This tests whether the distribution of one categorical variable differs across levels of another. It is a standard test for survey-based research in sociology, political science, and public health.

Visualizing Data with ggplot2

Visualization is not decoration. A well-constructed figure communicates what paragraphs of text cannot. The ggplot2 package produces publication-quality graphics with precise control over every element.

Creating a Bar Chart

For categorical data, a bar chart is often the clearest choice:

ggplot(data, aes(x = category_variable)) + geom_bar() + labs(title = "Your Title", x = "Category", y = "Count")

Creating a Scatter Plot

For examining relationships between two continuous variables:

ggplot(data, aes(x = variable1, y = variable2)) + geom_point() + geom_smooth(method = "lm") + labs(title = "Your Title")

The geom_smooth(method = "lm") layer adds a regression line, which visually reinforces your statistical findings. Every figure you include in a research paper should have a descriptive caption and should be referenced explicitly in your results section.

Connecting Your Analysis to a Publishable Paper

Running the analysis is only part of the work. The other part is translating your R output into clear, precise academic writing. Your results section should report statistical findings in standard format: the test statistic, degrees of freedom (where applicable), p-value, and effect size or confidence interval.

For example, a t-test result might read: Students in the experimental group scored significantly higher on the assessment (t(48) = 3.21, p = 0.002, 95% CI [1.4, 5.6]).

Your methods section should state which version of R you used and which packages your analysis depended on. This is standard practice in academic publishing and supports reproducibility.

If you are still developing your paper's structure, our Research Paper Outline Template High School Students provides a clear framework for organizing your work from introduction through conclusion. For examples of how published high school researchers present their findings, see our High School Research Paper Example Publishable resource.

Strong abstracts also require accurate statistical reporting. Review our Abstract Examples Published High School Research Papers to see how quantitative findings are summarized concisely at the top of a paper.

Common Mistakes to Avoid

Even students who learn R quickly can undermine their analysis through avoidable errors. These are the most consequential ones.

  • Choosing the wrong test for your data type. Running a t-test on categorical data produces meaningless output. Match your test to your variables before you run anything.

  • Ignoring assumptions. Most parametric tests assume normally distributed data. Use shapiro.test() to check normality before proceeding.

  • Over-interpreting p-values. A p-value below 0.05 does not prove your hypothesis. It means the result is unlikely under the null hypothesis. Interpret findings with appropriate caution.

  • Failing to document your code. An undocumented script is not reproducible. Comment every meaningful step.

  • Presenting figures without context. Every graph needs a title, labeled axes, and a caption. A figure that requires the reader to guess what it shows weakens your paper.

How to Use R for High School Research Data Analysis: Next Steps

Knowing how to use R for high school research data analysis puts you ahead of the vast majority of pre-collegiate researchers. It signals methodological seriousness to reviewers and strengthens the credibility of every claim you make in your paper.

The learning curve is real but manageable. Start with your actual dataset. Run descriptive statistics first. Add complexity incrementally. Each analysis you complete builds the fluency that makes the next one faster and more confident.

If your research is still in its early stages, our Research Proposal Example For High School Students can help you define your question and methodology before you collect data. A well-designed study produces data that is far easier to analyze, so the work you do upfront pays dividends at every stage that follows.

When your analysis is complete and your paper is taking shape, consider submitting to a peer-reviewed journal that evaluates student work on its merits (not on institutional affiliation or prestige). The Princeton Journal of Pre-Collegiate Research publishes original research across all disciplines through rigorous blind review. Every accepted paper receives a DOI, making your work permanently citable in the academic record. Explore our Blogs for more guidance on every stage of the research and publication process, and visit the Princeton Journal of Pre-Collegiate Research to learn about submission requirements and what our reviewers look for in a publishable manuscript.

Your research deserves to be taken seriously. R is one of the most powerful tools available to make that happen.

Read More

High school students conducting original research with academic journals from European and Latin American institutions displayed on a desk

Publishing high school research in Europe and Latin America: country guides

By

Princeton Journal of Pre-Collegiate Research

Read more

A German high school student reviewing a scientific research manuscript at a university library desk

How to publish research as a high school student in Germany

By

Princeton Journal of Pre-Collegiate Research

Read more

A French high school student reviewing a scientific research manuscript at a library desk with academic journals

How to publish research as a high school student in France

By

Princeton Journal of Pre-Collegiate Research

Read more

A Dutch high school student reviewing a scientific research manuscript at a university library in the Netherlands

How to publish research as a high school student in the Netherlands

By

Princeton Journal of Pre-Collegiate Research

Read more

Irish high school student conducting original scientific research in a laboratory setting for academic publication

How to publish research as a high school student in Ireland

By

Princeton Journal of Pre-Collegiate Research

Read more

Brazilian high school student conducting scientific research in a laboratory setting, preparing a manuscript for academic publication

How to publish research as a high school student in Brazil

By

Princeton Journal of Pre-Collegiate Research

Read more

A high school student in Mexico reviewing a scientific research manuscript at a desk with academic journals and a laptop

How to publish research as a high school student in Mexico

By

Princeton Journal of Pre-Collegiate Research

Read more

Colombian high school student conducting scientific research in a laboratory setting, preparing a manuscript for academic publication

How to publish research as a high school student in Colombia

By

Princeton Journal of Pre-Collegiate Research

Read more

Chilean high school student conducting original scientific research in a laboratory setting for academic publication

How to publish research as a high school student in Chile

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student organizing research paper sections with academic journals and citation guides on a desk

High School Research Paper: Structure, Format and Examples

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student writing a research paper introduction at a desk with academic journals and notes

How to Write the Introduction of a Research Paper

By

Princeton Journal of Pre-Collegiate Research

Read more

A high school student writing a research methods section at a desk with scientific notes and a laptop

How to Write the Methods Section of a Research Paper

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student writing the discussion section of a research paper at a desk with academic journals and notes

How to Write the Discussion Section of a Research Paper

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student writing an abstract for a scientific research paper at a desk with academic journals and notes

How to Write an Abstract for a Research Paper

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student writing a literature review for an academic research paper at a library desk with scholarly journals and notebooks

How to Write a Literature Review for a High School Research Paper

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student reviewing a printed research manuscript at a desk with academic journals and a laptop, preparing for peer-reviewed publication

How to Publish a High School Research Paper: Step by Step

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student conducting original scientific research in a laboratory setting with notebooks and data collection materials

High School Student Research: How to Get Started

By

Princeton Journal of Pre-Collegiate Research

Read more

Academic researcher reviewing manuscript submission options across journal, preprint, conference, and blog platforms

Refresh: Journal vs preprint vs conference vs blog: where to share your work

By

Princeton Journal of Pre-Collegiate Research

Read more

A formal academic cover letter document beside a scientific research manuscript prepared for journal submission

How to Write a Cover Letter When Submitting to a Journal

By

Princeton Journal of Pre-Collegiate Research

Read more

Academic peer reviewer evaluating a student research manuscript with annotated feedback notes

What Reviewers Look for When Reading a Student Manuscript

By

Princeton Journal of Pre-Collegiate Research

Read more

A student researcher writing a formal response to peer reviewer comments on a scientific manuscript

How to Write a Response to Reviewer Comments

By

Princeton Journal of Pre-Collegiate Research

Read more

Princeton, New Jersey, United States
Published and Managed by The Princeton Journal of Precollegiate Scholarship Inc.
ISSN: 3143-8423
DOI: 10.67698

Copyright © Princeton Journal of Pre-Collegiate Research. All rights reserved

PJPCR is independently operated and is not affiliated with Princeton University or any of its colleges, departments or programs.

Princeton, New Jersey, United States
Published and Managed by The Princeton Journal of Precollegiate Scholarship Inc.
ISSN: 3143-8423
DOI: 10.67698

Copyright © Princeton Journal of Pre-Collegiate Research. All rights reserved

PJPCR is independently operated and is not affiliated with Princeton University or any of its colleges, departments or programs.

Princeton, New Jersey, United States
Published and Managed by The Princeton Journal of Precollegiate Scholarship Inc.
ISSN: 3143-8423
DOI: 10.67698

Copyright © Princeton Journal of Pre-Collegiate Research. All rights reserved

PJPCR is independently operated and is not affiliated with Princeton University or any of its colleges, departments or programs.