>

>

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

Diagram illustrating axion particle detection apparatus used in dark matter research experiments

Axions and the Search for Dark Matter, Explained for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

Conceptual diagram of axion dark matter detection apparatus with magnetic field coils and microwave cavity resonator for student research

Axions and dark matter: 10 Research Questions and Experiment Ideas for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

Conceptual illustration of axion particles and dark matter distribution in a galactic halo, relevant to particle physics and cosmology research

Axions and dark matter: 12 Questions Students Ask, Answered

By

Princeton Journal of Pre-Collegiate Research

Read more

Diagram illustrating the distance from the Sun to Earth and Mars with labeled orbital paths in the solar system

Distance From the Sun to Earth (and Mars): Solar System Distances Explained

By

Princeton Journal of Pre-Collegiate Research

Read more

Diagram showing scaled distances between planets in the solar system for student research and educational experiments

Distances in the solar system: 10 Research Questions and Experiment Ideas for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

Diagram illustrating the relative distances between planets in the solar system, with scale markers in astronomical units

Distances in the solar system: 12 Questions Students Ask, Answered

By

Princeton Journal of Pre-Collegiate Research

Read more

False-color map of Mars crustal magnetic field anomalies detected by the Mars Global Surveyor magnetometer, showing striped magnetic signatures in the southern highlands

Does Mars Have a Magnetic Field? What We Know and How We Know

By

Princeton Journal of Pre-Collegiate Research

Read more

The Martian magnetic field: 10 Research Questions and Experiment Ideas for Students

The Martian magnetic field: 10 Research Questions and Experiment Ideas for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

Illustration of Mars with crustal magnetic field lines and solar wind interaction depicted in scientific diagram style

The Martian magnetic field: 12 Questions Students Ask, Answered

By

Princeton Journal of Pre-Collegiate Research

Read more

Diagram illustrating rolling friction forces acting on a wheel in contact with a flat surface, with labeled vectors for normal force and resistive torque

Rolling Friction Explained: Definition, Examples and Experiments for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student measuring rolling friction of a cylinder on an inclined plane in a physics laboratory setting

Rolling friction: 10 Research Questions and Experiment Ideas for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

Diagram illustrating rolling friction forces acting on a sphere rolling across a flat surface, with labeled vectors for normal force, friction, and deformation

Rolling friction: 12 Questions Students Ask, Answered

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student conducting a controlled friction experiment on an inclined plane with a wooden block and spring scale

How to Find the Coefficient of Kinetic Friction: A Student Experiment Guide

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student measuring the coefficient of kinetic friction using a wooden block and spring scale on an inclined plane in a laboratory setting

The coefficient of kinetic friction: 10 Research Questions and Experiment Ideas for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

The coefficient of kinetic friction: 12 Questions Students Ask, Answered

The coefficient of kinetic friction: 12 Questions Students Ask, Answered

By

Princeton Journal of Pre-Collegiate Research

Read more

Diagram of standing wave harmonics on a vibrating string showing nodes and antinodes at fundamental and overtone frequencies

Harmonics and Standing Waves: What They Are and How to Test Them

By

Princeton Journal of Pre-Collegiate Research

Read more

High school student conducting a standing wave experiment with a vibrating string apparatus in a physics laboratory

Harmonics and standing waves: 10 Research Questions and Experiment Ideas for Students

By

Princeton Journal of Pre-Collegiate Research

Read more

Diagram illustrating harmonic frequencies and standing wave nodes and antinodes on a vibrating string in a physics laboratory setting

Harmonics and standing waves: 12 Questions Students Ask, Answered

By

Princeton Journal of Pre-Collegiate Research

Read more

Mathematical proof of the AM-GM inequality written on a chalkboard with algebraic notation and inequality symbols

AM-GM Inequality: Proof, Examples and Olympiad Uses

By

Princeton Journal of Pre-Collegiate Research

Read more

Educator reviewing a student research manuscript in an academic setting with scientific journals and data charts on the desk

For Educators: Supporting Student Research and Publication

By

Princeton Journal of Pre-Collegiate Research

Read more

A high school teacher reviewing a student's research manuscript at a desk covered with scientific papers and reference materials

How Teachers Can Support a Student’s First Publication

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.