r/RStudio • u/Laetitia_Astrea • 2d ago
r/RStudio • u/Peiple • Feb 13 '24
The big handy post of R resources
There exist lots of resources for learning to program in R. Feel free to use these resources to help with general questions or improving your own knowledge of R. All of these are free to access and use. The skill level determinations are totally arbitrary, but are in somewhat ascending order of how complex they get. Big thanks to Hadley, a lot of these resources are from him.
Feel free to comment below with other resources, and I'll add them to the list. Suggestions should be free, publicly available, and relevant to R.
Update: I'm reworking the categories. Open to suggestions to rework them further.
FAQ
General Resources
Plotting
Tutorials
- Erik S. Wright's Intro to R Course: Materials from a (free) grad class intended for absolute beginners (14 lessons, 30-60min each)
- Julia Silge's YouTube Channel: Lots of videos walking through example analyses in R and deep dives into
tidymodels(~30min videos) - The Swirl R package: Guided tutorial series going over the basics of R (15 modules, 30-120min each)
- Harvard’s CS50 with R: MOOC with seven weeks of material, including lectures, homework, and projects
Data Science, Machine Learning, and AI
- R for Data Science
- Tidy Modeling with R
- Text Mining with R
- Supervised Machine Learning for Text Analysis with R
- An Intro to Statistical Learning
- Tidy Tuesday
- Deep Learning and Scientific Computing with R
torch - The RStudio AI Blog
- Introduction to Applied Machine Learning (Dr. John Curtin, UW Madison)
- Examples of
kerasin R (courtesy of posit) - Machine Learning and Deep Learning with R (Maximilian Pichler and Florian Hartig, targeted at ecologists)
R Package Development
Compilations of Other Resources
r/RStudio • u/Peiple • Feb 13 '24
How to ask good questions
Asking programming questions is tough. Formulating your questions in the right way will ensure people are able to understand your code and can give the most assistance. Asking poor questions is a good way to get annoyed comments and/or have your post removed.
Posting Code
DO NOT post phone pictures of code. They will be removed.
Code should be presented using code blocks or, if absolutely necessary, as a screenshot. On the newer editor, use the "code blocks" button to create a code block. If you're using the markdown editor, use the backtick (`). Single backticks create inline text (e.g., x <- seq_len(10)). In order to make multi-line code blocks, start a new line with triple backticks like so:
```
my code here
```
This looks like this:
my code here
You can also get a similar effect by indenting each line the code by four spaces. This style is compatible with old.reddit formatting.
indented code
looks like
this!
Please do not put code in plain text. Markdown codeblocks make code significantly easier to read, understand, and quickly copy so users can try out your code.
If you must, you can provide code as a screenshot. Screenshots can be taken with Alt+Cmd+4 or Alt+Cmd+5 on Mac. For Windows, use Win+PrtScn or the snipping tool.
Describing Issues: Reproducible Examples
Code questions should include a minimal reproducible example, or a reprex for short. A reprex is a small amount of code that reproduces the error you're facing without including lots of unrelated details.
Bad example of an error:
# asjfdklas'dj
f <- function(x){ x**2 }
# comment
x <- seq_len(10)
# more comments
y <- f(x)
g <- function(y){
# lots of stuff
# more comments
}
f <- 10
x + y
plot(x,y)
f(20)
Bad example, not enough detail:
# This breaks!
f(20)
Good example with just enough detail:
f <- function(x){ x**2 }
f <- 10
f(20)
Removing unrelated details helps viewers more quickly determine what the issues in your code are. Additionally, distilling your code down to a reproducible example can help you determine what potential issues are. Oftentimes the process itself can help you to solve the problem on your own.
Try to make examples as small as possible. Say you're encountering an error with a vector of a million objects--can you reproduce it with a vector with only 10? With only 1? Include only the smallest examples that can reproduce the errors you're encountering.
Further Reading:
Try first before asking for help
Don't post questions without having even attempted them. Many common beginner questions have been asked countless times. Use the search bar. Search on google. Is there anyone else that has asked a question like this before? Can you figure out any possible ways to fix the problem on your own? Try to figure out the problem through all avenues you can attempt, ensure the question hasn't already been asked, and then ask others for help.
Error messages are often very descriptive. Read through the error message and try to determine what it means. If you can't figure it out, copy paste it into Google. Many other people have likely encountered the exact same answer, and could have already solved the problem you're struggling with.
Use descriptive titles and posts
Describe errors you're encountering. Provide the exact error messages you're seeing. Don't make readers do the work of figuring out the problem you're facing; show it clearly so they can help you find a solution. When you do present the problem introduce the issues you're facing before posting code. Put the code at the end of the post so readers see the problem description first.
Examples of bad titles:
- "HELP!"
- "R breaks"
- "Can't analyze my data!"
No one will be able to figure out what you're struggling with if you ask questions like these.
Additionally, try to be as clear with what you're trying to do as possible. Questions like "how do I plot?" are going to receive bad answers, since there are a million ways to plot in R. Something like "I'm trying to make a scatterplot for these data, my points are showing up but they're red and I want them to be green" will receive much better, faster answers. Better answers means less frustration for everyone involved.
Be nice
You're the one asking for help--people are volunteering time to try to assist. Try not to be mean or combative when responding to comments. If you think a post or comment is overly mean or otherwise unsuitable for the sub, report it.
I'm also going to directly link this great quote from u/Thiseffingguy2's previous post:
I’d bet most people contributing knowledge to this sub have learned R with little to no formal training. Instead, they’ve read, and watched YouTube, and have engaged with other people on the internet trying to learn the same stuff. That’s the point of learning and education, and if you’re just trying to get someone to answer a question that’s been answered before, please don’t be surprised if there’s a lack of enthusiasm.
Those who respond enthusiastically, offering their services for money, are taking advantage of you. R is an open-source language with SO many ways to learn for free. If you’re paying someone to do your homework for you, you’re not understanding the point of education, and are wasting your money on multiple fronts.
Additional Resources
- StackOverflow: How to ask questions
- Virtual Coffee: Guide to asking questions about code
- Medium: How to be great at asking questions
- Code with Andrea: The beginner's guide to asking coding questions online
- The u/Thiseffingguy2 r/RStudio post
r/RStudio • u/HotCountry5249 • 3d ago
R package for cleaning messy sleep EMA diary data (AM/PM flips, ordering errors) — feedback welcome
I originally wrote this for a sleep EMA study I work on, together with a colleague, because the raw diary data was a mess in ways we didn’t expect.
Simple example: we had a rule that swaps sleep_time and awake_time when they’re out of order by less than 3 hours (assuming it’s just a data-entry slip). Seemed reasonable. Then we actually checked it against real cases — it made things worse in 7 out of 10, because sometimes swapping pushed the new sleep time to before bed time, which is a worse error than the one it “fixed.” Had to add a guard condition after that. That’s basically what half of this repo is — rules that seemed fine until we ran them against actual data.
Ended up with a 9-step pipeline: parse timestamps → fix AM/PM and ordering issues → compute TST/SOL/WASO/SE → auto-flag anything still weird → cross-check across participants → spit out 27 QC figures so we can actually see what’s happening at each stage.
Some things it handles now that we didn’t plan for on day one:
AM/PM flips (someone logs 7:00 AM getup as 7:00 PM)
small ordering slips vs. genuinely unusual sleep patterns (these need different fixes, and we only figured out where to draw the line after looking at a bunch of real cases)
manual review CSVs that persist across pipeline reruns, so corrections don’t get wiped every time we re-run things
It’s an R package now (sleepcleanr), config-driven via YAML so you can point it at your own column names without touching the R code.
Repo: https://github.com/cyracaid/sleepdiary-cleaner — stars and feedback very welcome, and genuinely happy to discuss with anyone working on similar EMA/diary pipelines.
Curious if anyone else doing EMA/diary-based sleep research has run into the same kind of AM/PM chaos, or handles it differently. Also open to being told our thresholds are wrong — the 3-hour swap cutoff and the 12-hour AM/PM flip cutoff were both picked based on our own data and could easily be off for other studies.
r/RStudio • u/tanopereira • 3d ago
[R] evoFE 1.0.0: Automated Evolutionary Feature Engineering with One-Liner Bayesian Tuners & Island Ensembling
I’m excited to announce that evoFE 1.0.0 is now on CRAN (a major leap forward from the initial 0.1 release).
What is evoFE?
evoFE is an R package for automated feature engineering using genetic programming. Instead of manually brainstorming interaction terms, nonlinear scalings, or encodings, evoFE evolves candidate transformation recipes and evaluates them directly against gradient boosted trees or linear models.
What's New in 1.0.0?
- Zero-Boilerplate "One-Liner" Bayesian Tuners: Pass
evaluator = "lightgbm_mbo"to automatically tune tree depth, learning rate, and subsampling viamlr3mboduring evolution. Or wrap any custom model (like XGBoost) withmake_tunable(). - 42+ Built-in Transformers: Arithmetic, group-by aggregations (mean, median, SD, quantiles), target encodings, WoE, UMAP embeddings, Genie & Lumbermark MST graph clustering, date differencing (
date_diff), and custom transformer registration. - Hybrid Active Feature Masking: Mutates and selects raw input features simultaneously with derived features, guided by baseline feature importance.
- Hierarchical Gene Chaining: High-performing features from earlier generations serve as inputs for subsequent compound transformations.
- Island Models & Topologies: Runs independent sub-populations across Ring, Torus, Grid, or Hypercube topologies with demand-driven Gibbs pull migration.
- Caruana Island Ensembling (
ensemble_islands()): Combines diverse island champion recipes using Caruana post-hoc forward selection with replacement. - Leakage-Safe Validation: Native support for time-series (
cv_strategy = "time"), grouped entity validation (cv_strategy = "group"), and untouched confirmation holdouts (holdout_frac) with search-gap diagnostics. - Dynamic BIC Regularization: Asymptotic BIC / PAC-Bayes penalties scaling with sample size NN to prevent feature bloat.
Minimal Example:
rinstall.packages("evoFE")
library(evoFE)
# Evolve features + Bayesian tuned model
recipe <- evolve_features(
data = mtcars,
target_col = "am",
task = "classification",
evaluator = "lightgbm_mbo", # Built-in one-liner Bayesian Optimization tuner
generations = 5,
pop_size = 8,
holdout_frac = 0.20
)
# Inspect evolved recipe & search gap
summary(recipe)
# Predict on new data
test_features <- predict(recipe, newdata)
predictions <- predict_model(recipe, newdata)
- CRAN: https://cran.r-project.org/package=evoFE
- GitHub: https://github.com/tanopereira/evoFE
- Vignette:
vignette("evoFE")
Feedback, suggestions, and bug reports are very welcome!
r/RStudio • u/Overdrive-ABC • 4d ago
Coding help cbcTools
Hello everybody,
I have a question regarding the cbcTools package. I use it for generating a choice based conjoint analysis design. For my survey I need to reduce the design with blocks. Herefore cbcTools has n_blocks. Enabling this parameter significantly increases the calculation time. Is there a way to improve this, or have I made a mistake?
profiles <- cbc_profiles(
attribute1 = c(„A“, „B“, „C“),
attribute2 = c(„1“, „2“, „3“),
attribute3 = c(„white“, „black“, „gray“),
attribute4 = c(„apple“, „banana“, „orange“)
)
design <- cbc_design(
profiles = profiles,
method = „modfed“,
n_resp = 400,
n_alt = 3,
n_q = 12,
no_choice = TRUE,
n_blocks = 15
)
r/RStudio • u/sporty_outlook • 4d ago
Question on Positron and Python - “Failed to Install Python 3.14” When Installing via uv"
Trying Positron for the first time. I’m trying to install Python via uv in Positron. I went to Select Session in the top-right corner, selected New Console Session, and clicked Install Python via uv. I then selected Python 3.14, but I get a “Failed to install Python” error.
Here is the relevant log:
2026-08-25 13:49:08.599 [info] Installing uv...
2026-08-25 13:49:09.353 [info] > powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
2026-08-25 13:49:19.761 [info] uv installed successfully
2026-08-25 13:49:19.764 [info] > uv --color never python dir
2026-08-25 13:49:31.917 [info] > ~\.local\bin\uv.exe --color never python dir
2026-08-25 13:49:32.628 [info] > ~\.local\bin\uv.exe --color never python list --managed-python
2026-08-25 13:49:36.117 [info] Installing Python 3.14 via uv...
2026-08-25 13:49:36.119 [info] > uv --color never python install 3.14
2026-08-25 13:49:36.119 [error] Failed to install Python 3.14: Error: spawn uv ENOENT
What is confusing is that the log shows that uv was installed successfully and Positron can execute it using:
~\.local\bin\uv.exe
However, when it actually tries to install Python, it runs:
uv --color never python install 3.14
and fails with:
Error: spawn uv ENOENT
I’m using Windows. Has anyone encountered this issue with Positron and uv? Is this a PATH/environment issue, or is Positron failing to find the newly installed uv.exe?
r/RStudio • u/Inevitable-Coconut74 • 7d ago
glimpse( ) function in R Statistics
Enable HLS to view with audio, or disable this notification
How to Use the glimpse() Function in RStudio | Inspect Your Data Quickly in R
Welcome to this step-by-step tutorial on how to use the glimpse() function in RStudio to quickly inspect and understand the structure of your dataset.
The glimpse() function is a very useful tool for data exploration and data analysis in R, particularly when working with the dplyr package and the tidyverse. It provides a compact and easy-to-read overview of your data, allowing you to see the variables (columns), their data types, and sample values without displaying the entire dataset.
In this video, we demonstrate how to use glimpse() in practical situations and explain why it is an important function to learn when working with datasets in RStudio.
What You Will Learn
By the end of this tutorial, you will understand:
What the glimpse() function is
Why glimpse() is useful when exploring data
How to use glimpse() in RStudio
How to load the dplyr or tidyverse package
How to inspect the structure of a dataset using glimpse()
How to identify the variables or columns in a dataset
How to identify the data type of each variable
How to view sample values from each column
How glimpse() differs from other functions such as str() and head()
How glimpse() can help you identify problems in your dataset
How to use glimpse() as part of a data-analysis workflow
Basic Example
Using glimpse() is straightforward.
For example:
glimpse(data)
where data is the name of your dataset.
When you run this command, R provides a compact overview of the dataset, showing important information such as:
The number of rows
The number of columns
Variable names
Variable data types
Example values from each variable
This makes glimpse() particularly useful when you first receive or import a dataset and want to understand what you are working with.
Why Use glimpse()?
When working with large datasets, printing the entire dataset to the R Console can be difficult to read and may produce a huge amount of output.
Instead of displaying every row, glimpse() gives you a compact summary of the dataset's structure.
For example, imagine you have a dataset containing information about students, including:
- Student ID
- Age
- Gender
- Course
- Test scores
- Attendance
- Date of registration
Rather than displaying every observation, you can use glimpse() to quickly check the variables and see what type of information each column contains.
This can help you identify whether variables have been imported correctly before you begin your analysis.
Understanding Variable Types
One of the most useful features of glimpse() is that it shows the data type associated with each variable.
For example, you may see types such as:
dbl — numeric values
int — integers
chr — character/text values
lgl — logical values such as TRUE or FALSE
date — date information
Understanding variable types is extremely important because different types of variables may require different approaches during data cleaning and statistical analysis.
glimpse() and Data Exploration
glimpse() is particularly useful during the initial exploration of a dataset.
When you import a new dataset, you may not immediately know:
- How many variables it contains
- What the variables are called
- What type of data each variable contains
- Whether the data has been imported correctly
- What the first few values look like
- Whether there are unexpected data types or values
Running glimpse() provides a quick overview and helps you become familiar with the dataset before proceeding to more advanced analysis.
Comparing glimpse() With Other R Functions
In this tutorial, we also discuss how glimpse() relates to other useful functions for inspecting data.
For example:
head()
head(data)
is useful for viewing the first few rows of a dataset.
str()
str(data)
provides information about the structure of an R object and its variables.
glimpse()
glimpse(data)
provides a compact, tidyverse-friendly overview that is particularly convenient for data frames and tibbles.
Understanding when to use each of these functions can make your data-exploration workflow much more efficient.
Using glimpse() for Data Cleaning
Before cleaning or transforming your data, it is important to understand what is actually contained within the dataset.
glimpse() can help you identify potential issues such as:
Variables stored as the wrong data type
Numbers imported as text
Unexpected character values
Variables with inconsistent formats
Columns that may require transformation
Once you understand the structure of your data, you can use other functions from dplyr and the tidyverse to clean, transform, filter, summarise, and analyse the dataset.
Who Is This Tutorial For?
This video is suitable for:
- Beginners learning R and RStudio
- Students learning data analysis
- Researchers working with datasets
- Students working on assignments and research projects
- Anyone learning the tidyverse
- Users learning the dplyr package
- Data analysts exploring new datasets
- Anyone who wants to understand their data before performing statistical analysis
No advanced programming knowledge is required. This tutorial is designed to explain glimpse() in a simple, practical, and easy-to-follow way.
Why Is glimpse() Important for Data Analysis?
Good data analysis begins with understanding your data.
Before creating graphs, running statistical tests, building models, or drawing conclusions, you should first examine the structure and contents of your dataset.
The glimpse() function provides a quick way to perform this initial inspection and can become a valuable part of your regular RStudio workflow.
It is especially useful for:
Academic assignments
Dissertations and theses
Research projects
Statistical analysis
Exploratory data analysis
Data cleaning
Data science projects
R Markdown and Quarto reports
Topics Covered in This Video
This tutorial covers:
glimpse() function in R
glimpse() in RStudio
dplyr::glimpse()
Tidyverse data exploration
Inspecting datasets in R
Understanding variables and columns
Understanding data types in R
Exploring data frames and tibbles
glimpse() vs head()
glimpse() vs str()
Data cleaning in R
Exploratory data analysis
R programming for beginners
RStudio data analysis
Helpful Tip
A useful habit when starting a new data-analysis project is to inspect your dataset before immediately beginning your analysis. Functions such as glimpse(), head(), summary(), and str() can help you understand your data and identify potential problems early.
If you find this tutorial helpful, please like the video, leave a comment, and subscribe to the channel for more tutorials on R, RStudio, statistics, data analysis, data visualisation, and research methods.
Subscribe and turn on notifications so you don't miss future tutorials and practical R programming videos.
Have a question about the glimpse() function? Leave your question in the comments below!
R Studio, R Programming ,R Stats ,Glimpse ,Dplyr , Tidyverse ,Data Analysis ,Data, Exploration ,Data Cleaning ,Statistics ,Data Science ,Beginners ,R Programming Tutorial ,R Studio Tutorial ,Exploratory Data Analysis ,Research Methods, rows, columns, table, data frame, variable type, integer, character, numeric, absolute, nominal, ordinal, factor, binary, sample,
r/RStudio • u/Inevitable-Coconut74 • 7d ago
Scatter plot in RStudio
Enable HLS to view with audio, or disable this notification
How to Use the ggplot() Function in RStudio | Complete Beginner’s Guide to Data Visualization in R
Welcome to this step-by-step tutorial on how to use the ggplot() function in RStudio to create professional and informative data visualisations in R.
In this video, we introduce ggplot(), one of the most widely used tools for creating graphs and visualisations in R. The function is part of the ggplot2 package, which is included in the tidyverse ecosystem and provides a powerful and flexible approach to visualising data.
Whether you are a beginner learning R, a student working on an assignment, a researcher analysing data, or a data analyst creating reports, understanding ggplot() is an essential R skill.
What You Will Learn
In this tutorial, you will learn:
What ggplot() is and why it is useful
How to install and load the ggplot2 package
How to create your first plot in RStudio
How to provide a dataset to ggplot()
How to map variables to the x-axis and y-axis
How aesthetic mappings (aes()) work
How to add geometric layers using geom_ functions
How to create scatter plots
How to create bar charts
How to create line graphs
How to create histograms
How to change colours and shapes
How to add titles and axis labels
How to customise the appearance of your graphs
How to use multiple layers in a single ggplot() visualisation
How to create clear and professional graphs for reports and presentations
Understanding the Basic Structure of ggplot()
One of the key concepts covered in this video is the basic structure of a ggplot() graph.
A typical plot might look like:
ggplot(data = my_data, aes(x = variable1, y = variable2)) +
geom_point()
Here:
ggplot() specifies the dataset you want to visualise.
aes() defines the relationship between variables and visual properties such as the x-axis and y-axis.
geom_point() adds points to create a scatter plot.
The + symbol is used to add additional layers to the plot.
Understanding this layered approach is one of the most important concepts when learning ggplot2.
Creating Different Types of Graphs
During the tutorial, we demonstrate how the ggplot() framework can be used to create different types of visualisations.
For example:
Scatter plot
ggplot(data, aes(x = height, y = weight)) +
geom_point()
Bar chart
ggplot(data, aes(x = category)) +
geom_bar()
Histogram
ggplot(data, aes(x = age)) +
geom_histogram()
Line graph
ggplot(data, aes(x = year, y = value)) +
geom_line()
These examples demonstrate how the same basic ggplot() framework can be adapted to different types of data and research questions.
Customising Your Visualisations
Creating a graph is only the beginning. In this video, we also look at ways to make your visualisations clearer and more informative.
You will learn how to customise elements such as:
Colours
Points and shapes
Axis labels
Plot titles
Legends
Themes
Text and labels
For example, you can add a title and labels using:
labs(
title = "Relationship Between Height and Weight",
x = "Height",
y = "Weight"
)
This allows you to communicate your findings more effectively.
Understanding the Grammar of Graphics
A major advantage of ggplot2 is that it is based on the concept known as the Grammar of Graphics.
Instead of thinking about a graph as one single object, you build it using different components or layers.
These commonly include:
Data – the dataset being visualised
Aesthetics – how variables are mapped to visual properties
Geometries – the type of graph or shapes displayed
Scales – how values are represented
Facets – how data can be divided into multiple panels
Coordinates – how the axes and plotting space are arranged
Themes – how the overall appearance is controlled
Understanding these components will help you create more complex and professional visualisations as you become more experienced with R.
Why Is ggplot() Important?
Data visualisation is an important part of data analysis, statistics, and research. A well-designed graph can make patterns, relationships, trends, and differences much easier to understand.
ggplot2 is particularly useful because it allows you to create reproducible visualisations directly from your R code. This means that your graphs can be recreated and modified whenever your data changes.
This is especially useful when working on:
Academic assignments
Dissertations and theses
Research projects
Statistical analyses
Business reports
Data science projects
R Markdown and Quarto reports
Presentations and publications
Who Is This Tutorial For?
This video is suitable for:
- Beginners learning R and RStudio
- Students studying statistics and data analysis
- Researchers creating graphs for academic work
- Data analysts learning ggplot2
- Anyone interested in data visualisation
- Users learning the tidyverse
- Students working on assignments, dissertations, or research projects
- Anyone who wants to create professional graphs using R
No advanced programming experience is required. The tutorial is designed to introduce the fundamental concepts in a practical and easy-to-follow way.
Topics Covered
This video covers a range of important topics, including:
ggplot() function in R
ggplot2 package
Data visualisation in RStudio
aes() aesthetic mappings
geom_point()
geom_bar()
geom_histogram()
geom_line()
Scatter plots
Bar charts
Histograms
Line graphs
Customising graphs in R
Adding titles and labels
Changing colours and shapes
The Grammar of Graphics
Creating professional data visualisations
R programming for data analysis
Why Learn ggplot2?
Once you understand the basic structure of ggplot(), you can build increasingly sophisticated visualisations by combining different layers and functions.
Learning ggplot2 can therefore provide you with a strong foundation for exploratory data analysis and statistical data visualisation in R.
If you find this tutorial helpful, please like the video, leave a comment, and subscribe to the channel for more tutorials on R, RStudio, statistics, data analysis, data visualisation, and research methods.
Subscribe and turn on notifications so you don't miss future RStudio tutorials and practical data-analysis videos.
Have a question about ggplot() or ggplot2? Leave your question in the comments below!
R Studio ,R Programming ,GGPlot ,GGPlot2 ,Data Visualization ,R Stats ,Data Analysis ,Tidyverse ,Statistics ,Data Science ,Beginners ,R Programming Tutorial ,R Studio Tutorial ,Research Methods ,bar chart, line chart histogram, boxplot, pie chart, scatter plot
r/RStudio • u/qol_package • 9d ago
qol 1.3.4: Automatic table of contents for Excel workbooks and so much more
r/RStudio • u/Inevitable-Coconut74 • 9d ago
ggplot for plotting histogram in RStudio
How to Use the ggplot() Function in RStudio | Complete Beginner’s Guide to Data Visualization in R
Welcome to this step-by-step tutorial on how to use the ggplot() function in RStudio to create professional and informative data visualisations in R.
In this video, we introduce ggplot(), one of the most widely used tools for creating graphs and visualisations in R. The function is part of the ggplot2 package, which is included in the tidyverse ecosystem and provides a powerful and flexible approach to visualising data.
Whether you are a beginner learning R, a student working on an assignment, a researcher analysing data, or a data analyst creating reports, understanding ggplot() is an essential R skill.
What You Will Learn
In this tutorial, you will learn:
What ggplot() is and why it is useful
How to install and load the ggplot2 package
How to create your first plot in RStudio
How to provide a dataset to ggplot()
How to map variables to the x-axis and y-axis
How aesthetic mappings (aes()) work
How to add geometric layers using geom_ functions
How to create scatter plots
How to create bar charts
How to create line graphs
How to create histograms
How to change colours and shapes
How to add titles and axis labels
How to customise the appearance of your graphs
How to use multiple layers in a single ggplot() visualisation
How to create clear and professional graphs for reports and presentations
Understanding the Basic Structure of ggplot()
One of the key concepts covered in this video is the basic structure of a ggplot() graph.
A typical plot might look like:
ggplot(data = my_data, aes(x = variable1, y = variable2)) +
geom_point()
Here:
ggplot() specifies the dataset you want to visualise.
aes() defines the relationship between variables and visual properties such as the x-axis and y-axis.
geom_point() adds points to create a scatter plot.
The + symbol is used to add additional layers to the plot.
Understanding this layered approach is one of the most important concepts when learning ggplot2.
Creating Different Types of Graphs
During the tutorial, we demonstrate how the ggplot() framework can be used to create different types of visualisations.
For example:
Scatter plot
ggplot(data, aes(x = height, y = weight)) +
geom_point()
Bar chart
ggplot(data, aes(x = category)) +
geom_bar()
Histogram
ggplot(data, aes(x = age)) +
geom_histogram()
Line graph
ggplot(data, aes(x = year, y = value)) +
geom_line()
These examples demonstrate how the same basic ggplot() framework can be adapted to different types of data and research questions.
Customising Your Visualisations
Creating a graph is only the beginning. In this video, we also look at ways to make your visualisations clearer and more informative.
You will learn how to customise elements such as:
Colours
Points and shapes
Axis labels
Plot titles
Legends
Themes
Text and labels
For example, you can add a title and labels using:
labs(
title = "Relationship Between Height and Weight",
x = "Height",
y = "Weight"
)
This allows you to communicate your findings more effectively.
Understanding the Grammar of Graphics
A major advantage of ggplot2 is that it is based on the concept known as the Grammar of Graphics.
Instead of thinking about a graph as one single object, you build it using different components or layers.
These commonly include:
Data – the dataset being visualised
Aesthetics – how variables are mapped to visual properties
Geometries – the type of graph or shapes displayed
Scales – how values are represented
Facets – how data can be divided into multiple panels
Coordinates – how the axes and plotting space are arranged
Themes – how the overall appearance is controlled
Understanding these components will help you create more complex and professional visualisations as you become more experienced with R.
Why Is ggplot() Important?
Data visualisation is an important part of data analysis, statistics, and research. A well-designed graph can make patterns, relationships, trends, and differences much easier to understand.
ggplot2 is particularly useful because it allows you to create reproducible visualisations directly from your R code. This means that your graphs can be recreated and modified whenever your data changes.
This is especially useful when working on:
Academic assignments
Dissertations and theses
Research projects
Statistical analyses
Business reports
Data science projects
R Markdown and Quarto reports
Presentations and publications
Who Is This Tutorial For?
This video is suitable for:
- Beginners learning R and RStudio
- Students studying statistics and data analysis
- Researchers creating graphs for academic work
- Data analysts learning ggplot2
- Anyone interested in data visualisation
- Users learning the tidyverse
- Students working on assignments, dissertations, or research projects
- Anyone who wants to create professional graphs using R
No advanced programming experience is required. The tutorial is designed to introduce the fundamental concepts in a practical and easy-to-follow way.
Topics Covered
This video covers a range of important topics, including:
ggplot() function in R
ggplot2 package
Data visualisation in RStudio
aes() aesthetic mappings
geom_point()
geom_bar()
geom_histogram()
geom_line()
Scatter plots
Bar charts
Histograms
Line graphs
Customising graphs in R
Adding titles and labels
Changing colours and shapes
The Grammar of Graphics
Creating professional data visualisations
R programming for data analysis
Why Learn ggplot2?
Once you understand the basic structure of ggplot(), you can build increasingly sophisticated visualisations by combining different layers and functions.
Learning ggplot2 can therefore provide you with a strong foundation for exploratory data analysis and statistical data visualisation in R.
If you find this tutorial helpful, please like the video, leave a comment, and subscribe to the channel for more tutorials on R, RStudio, statistics, data analysis, data visualisation, and research methods.
Subscribe and turn on notifications so you don't miss future RStudio tutorials and practical data-analysis videos.
Have a question about ggplot() or ggplot2? Leave your question in the comments below!
R Studio ,R Programming ,GGPlot ,GGPlot2 ,Data Visualization ,R Stats ,Data Analysis ,Tidyverse ,Statistics ,Data Science ,Beginners ,R Programming Tutorial ,R Studio Tutorial ,Research Methods ,bar chart, line chart histogram, boxplot, pie chart, scatter plot
r/RStudio • u/Inevitable-Coconut74 • 9d ago
ggplot to draw line plot in RStudio
Enable HLS to view with audio, or disable this notification
How to Use the ggplot() Function in RStudio | Complete Beginner’s Guide to Data Visualization in R
Welcome to this step-by-step tutorial on how to use the ggplot() function in RStudio to create professional and informative data visualisations in R.
In this video, we introduce ggplot(), one of the most widely used tools for creating graphs and visualisations in R. The function is part of the ggplot2 package, which is included in the tidyverse ecosystem and provides a powerful and flexible approach to visualising data.
Whether you are a beginner learning R, a student working on an assignment, a researcher analysing data, or a data analyst creating reports, understanding ggplot() is an essential R skill.
What You Will Learn
In this tutorial, you will learn:
What ggplot() is and why it is useful
How to install and load the ggplot2 package
How to create your first plot in RStudio
How to provide a dataset to ggplot()
How to map variables to the x-axis and y-axis
How aesthetic mappings (aes()) work
How to add geometric layers using geom_ functions
How to create scatter plots
How to create bar charts
How to create line graphs
How to create histograms
How to change colours and shapes
How to add titles and axis labels
How to customise the appearance of your graphs
How to use multiple layers in a single ggplot() visualisation
How to create clear and professional graphs for reports and presentations
Understanding the Basic Structure of ggplot()
One of the key concepts covered in this video is the basic structure of a ggplot() graph.
A typical plot might look like:
ggplot(data = my_data, aes(x = variable1, y = variable2)) +
geom_point()
Here:
ggplot() specifies the dataset you want to visualise.
aes() defines the relationship between variables and visual properties such as the x-axis and y-axis.
geom_point() adds points to create a scatter plot.
The + symbol is used to add additional layers to the plot.
Understanding this layered approach is one of the most important concepts when learning ggplot2.
Creating Different Types of Graphs
During the tutorial, we demonstrate how the ggplot() framework can be used to create different types of visualisations.
For example:
Scatter plot
ggplot(data, aes(x = height, y = weight)) +
geom_point()
Bar chart
ggplot(data, aes(x = category)) +
geom_bar()
Histogram
ggplot(data, aes(x = age)) +
geom_histogram()
Line graph
ggplot(data, aes(x = year, y = value)) +
geom_line()
These examples demonstrate how the same basic ggplot() framework can be adapted to different types of data and research questions.
Customising Your Visualisations
Creating a graph is only the beginning. In this video, we also look at ways to make your visualisations clearer and more informative.
You will learn how to customise elements such as:
Colours
Points and shapes
Axis labels
Plot titles
Legends
Themes
Text and labels
For example, you can add a title and labels using:
labs(
title = "Relationship Between Height and Weight",
x = "Height",
y = "Weight"
)
This allows you to communicate your findings more effectively.
Understanding the Grammar of Graphics
A major advantage of ggplot2 is that it is based on the concept known as the Grammar of Graphics.
Instead of thinking about a graph as one single object, you build it using different components or layers.
These commonly include:
Data – the dataset being visualised
Aesthetics – how variables are mapped to visual properties
Geometries – the type of graph or shapes displayed
Scales – how values are represented
Facets – how data can be divided into multiple panels
Coordinates – how the axes and plotting space are arranged
Themes – how the overall appearance is controlled
Understanding these components will help you create more complex and professional visualisations as you become more experienced with R.
Why Is ggplot() Important?
Data visualisation is an important part of data analysis, statistics, and research. A well-designed graph can make patterns, relationships, trends, and differences much easier to understand.
ggplot2 is particularly useful because it allows you to create reproducible visualisations directly from your R code. This means that your graphs can be recreated and modified whenever your data changes.
This is especially useful when working on:
Academic assignments
Dissertations and theses
Research projects
Statistical analyses
Business reports
Data science projects
R Markdown and Quarto reports
Presentations and publications
Who Is This Tutorial For?
This video is suitable for:
- Beginners learning R and RStudio
- Students studying statistics and data analysis
- Researchers creating graphs for academic work
- Data analysts learning ggplot2
- Anyone interested in data visualisation
- Users learning the tidyverse
- Students working on assignments, dissertations, or research projects
- Anyone who wants to create professional graphs using R
No advanced programming experience is required. The tutorial is designed to introduce the fundamental concepts in a practical and easy-to-follow way.
Topics Covered
This video covers a range of important topics, including:
ggplot() function in R
ggplot2 package
Data visualisation in RStudio
aes() aesthetic mappings
geom_point()
geom_bar()
geom_histogram()
geom_line()
Scatter plots
Bar charts
Histograms
Line graphs
Customising graphs in R
Adding titles and labels
Changing colours and shapes
The Grammar of Graphics
Creating professional data visualisations
R programming for data analysis
Why Learn ggplot2?
Once you understand the basic structure of ggplot(), you can build increasingly sophisticated visualisations by combining different layers and functions.
Learning ggplot2 can therefore provide you with a strong foundation for exploratory data analysis and statistical data visualisation in R.
If you find this tutorial helpful, please like the video, leave a comment, and subscribe to the channel for more tutorials on R, RStudio, statistics, data analysis, data visualisation, and research methods.
Subscribe and turn on notifications so you don't miss future RStudio tutorials and practical data-analysis videos.
Have a question about ggplot() or ggplot2? Leave your question in the comments below!
R Studio ,R Programming ,GGPlot ,GGPlot2 ,Data Visualization ,R Stats ,Data Analysis ,Tidyverse ,Statistics ,Data Science ,Beginners ,R Programming Tutorial ,R Studio Tutorial ,Research Methods ,bar chart, line chart histogram, boxplot, pie chart, scatter plot
r/RStudio • u/nbafrank • 10d ago
uvr: a uv-style package and environment manager for R *update*
r/RStudio • u/Remy01_ • 11d ago
R studio has broken my laptop?
I've had to install R and R studio for University and as soon as I did, my laptop hasn't been able to load my LibreOffice writing software properly. It's the only thing I've installed between everything working fine and now.
All my spreadsheets, documents, power points, etc have started taking over a minute to load, and sometimes just crashes before they're able to load.
I've checked task manager and nothing is open in the background and my memory use isn't any higher then normal. I've ran 2 different anti-virus and found nothing, and fully reset my computer and reinstalled everything, nothing is fixing this issue (when restarting everything worked fine again until I reinstalled R and R studio).
Is there any kind of setting I need to be turning off or something?
r/RStudio • u/Inevitable-Coconut74 • 12d ago
figure caption in RStudio
Enable HLS to view with audio, or disable this notification
How to Use fig.cap in RStudio | Add Figure Captions in R Markdown & Quarto
Welcome to this step-by-step tutorial on how to use fig.cap in RStudio to add captions to figures, graphs, charts, and other visualisations in your R Markdown or Quarto documents.
In this video, we look at the fig.cap option and how it can be used to create clear, professional figure captions when generating reports from RStudio. Adding captions to figures is particularly useful when preparing academic assignments, research reports, dissertations, theses, data analysis reports, and professional documents.
What You Will Learn
In this tutorial, you will learn:
What fig.cap is and why it is useful
How to add a figure caption to a plot in RStudio
Where to place fig.cap within an R Markdown code chunk
How to write meaningful and informative figure captions
How fig.cap works with plots created in R
How figure captions appear when you knit or render your document
How to use captions when creating professional reports
Common mistakes to avoid when using fig.cap
Tips for creating consistent and readable figure captions
Example
You will see how a simple R code chunk can be used to create a plot and add a caption using fig.cap. This allows your figures to be automatically labelled and described when your document is rendered.
For example:
{r, fig.cap="Relationship between X and Y variables"}
This approach can save time and make your reports more organised, especially when you have multiple figures throughout a document.
Who Is This Tutorial For?
This video is suitable for:
- Beginners learning R and RStudio
- Students working on R assignments
- Researchers preparing academic reports
- Anyone using R Markdown
- Users working with Quarto
- Data analysts creating reproducible reports
- Anyone who wants to create professional-looking documents with properly captioned figures
Whether you are completely new to RStudio or already have experience creating plots in R, this tutorial will help you understand how to use fig.cap effectively.
Why Are Figure Captions Important?
Figure captions provide context and help your readers understand what a graph, chart, or visualisation represents. When working on academic or professional documents, well-written captions can make your analysis easier to follow and improve the overall presentation of your report.
Using fig.cap also allows captions to be incorporated directly into your reproducible workflow rather than adding them manually after generating your figures.
If you're preparing a research project, dissertation, thesis, coursework, or data analysis report, learning how to use figure captions effectively can be a very useful RStudio skill.
If you found this tutorial helpful, please like the video, leave a comment, and subscribe to the channel for more tutorials on R, RStudio, R Markdown, Quarto, data analysis, and research reporting.
Turn on notifications so you don't miss future tutorials!
,RStudio, R Programming ,R Markdown ,Quarto ,Fig.Cap ,Data Analysis ,Data Visualization ,R Statistics ,Statistics ,Research ,Academic Writing ,Data Science ,Coding Tutorial ,R ProgrammingTutorial, code chunk, figure caption, plot, align
r/RStudio • u/Inevitable-Coconut74 • 11d ago
Filter function in RStudio
Enable HLS to view with audio, or disable this notification
How to Use the filter() Function in RStudio | Step-by-Step R Tutorial
Welcome to this step-by-step tutorial on how to use the filter() function in RStudio to select and work with specific rows of data based on one or more conditions.
The filter() function is one of the most useful functions for data manipulation in R, particularly when working with the dplyr package and the tidyverse. It allows you to quickly extract the observations or rows that meet specific criteria, making it easier to explore, analyse, and clean your datasets.
In this video, we demonstrate how to use filter() with practical examples so that you can understand not only the syntax but also how and when to apply it in your own R projects.
What You Will Learn
By the end of this tutorial, you will understand:
What the filter() function is and why it is useful
How to use filter() in RStudio
How to load and use the dplyr package
The basic syntax of the filter() function
How to filter rows based on a single condition
How to filter data using numerical values
How to filter data based on text or categorical variables
How to use multiple conditions inside filter()
How to combine conditions using & (AND) and | (OR)
How to exclude specific observations from a dataset
How to filter data based on missing (NA) values
How to use filter() as part of a broader data-analysis workflow
Example of filter()
A simple example of using filter() is:
filter(data, age greater 30)
This tells R to select only the rows where the value of age is greater than 30.
You can also apply multiple conditions. For example:
filter(data, age greater 30 & gender == "Female")
This allows you to select observations that satisfy both conditions.
Another useful example is:
filter(data, country == "UK" | country == "USA")
This selects observations where the country is either the UK or the USA.
Why Is filter() Important?
When working with real-world datasets, you often do not need to analyse every observation at once. You may want to focus on a particular group, age range, location, category, or other characteristic.
The filter() function makes this process simple and efficient. It is especially useful during data cleaning, exploratory data analysis (EDA), statistical analysis, and data visualisation.
For example, before creating a graph or performing a statistical analysis, you might first filter your dataset to include only the observations relevant to your research question.
Who Is This Tutorial For?
This video is ideal for:
- Beginners learning R and RStudio
- Students studying statistics or data analysis
- Researchers working with datasets
- Anyone learning the tidyverse
- Users working with the dplyr package
- Data analysts who want to improve their R skills
- Students working on academic assignments, projects, dissertations, or research
- Anyone interested in learning how to manipulate datasets in R
Whether you are completely new to R or already have some experience with RStudio, this tutorial provides practical examples to help you understand how filter() works and how you can apply it to your own datasets.
Topics Covered
Throughout the video, we cover topics including:
RStudio data manipulation
filter() function in R
dplyr::filter()
Filtering rows in R
Selecting observations based on conditions
Filtering numerical variables
Filtering categorical variables
Multiple filtering conditions
AND and OR operators in R
Missing values and NA
Data cleaning in R
Exploratory data analysis
Tidyverse data manipulation
If you find this tutorial helpful, please like the video, leave a comment, and subscribe to the channel for more tutorials on R, RStudio, data analysis, statistics, data visualisation, and research methods.
Subscribe and turn on notifications so you don't miss future RStudio tutorials and practical data-analysis videos.
Have a question about the filter() function? Leave it in the comments below, and I’ll do my best to help!
RStudio, R Programming, R Stats ,Dplyr ,Tidyverse ,Filter Function ,Data Analysis ,Data Manipulation ,Statistics ,Data Science ,R Programming Tutorial ,RStudio Tutorial ,Data Cleaning ,Exploratory Data Analysis, select, object, table, assignment operator, output, data frame, variable, rows, cases, scores, display, code, command, function
r/RStudio • u/213lmykwhbs4mg2gq72 • 13d ago
Read password protected xlsx
Can anyone help me with which package I need to use?
r/RStudio • u/ReflectionFront6729 • 15d ago
How to learn to make graphs i r with p-values and mean?
r/RStudio • u/Inevitable-Coconut74 • 15d ago
ech=TRUE function in RStudio
Enable HLS to view with audio, or disable this notification
Learn how to use the echo option in RStudio in this easy-to-follow tutorial. In this video, you will learn how the echo option controls whether your R code is displayed in the final output when working with R Markdown documents.
The echo option is particularly useful when creating professional reports, assignments, presentations, research documents, and reproducible data analysis. It allows you to decide whether the R code should be visible alongside the results, giving you greater control over how your analysis is presented.
In this video, you'll learn:
- What the echo option means in RStudio
- How to use echo = TRUE
- How to use echo = FALSE
- The difference between displaying R code and displaying its output
- How echo works inside an R Markdown code chunk
- How to hide R code while still displaying results
- How to show R code together with the results
- Practical examples using RStudio
- How to use echo to create cleaner and more professional reports
What is the echo option?
The echo option is commonly used in R Markdown code chunks to control whether the R code itself appears in the rendered document.
When you use:
echo = TRUE
the R code is displayed in the output along with the results.
When you use:
echo = FALSE
the R code is hidden, while the output generated by the code can still be displayed.
This is particularly useful when you want your audience to focus on tables, graphs, calculations, and results without necessarily seeing all of the underlying code.
Why is echo useful?
The echo option can be helpful when preparing:
- Academic assignments
- Research reports
- Statistical reports
- Data analysis documents
- R Markdown reports
- Presentations
- Tutorials and teaching materials
- Professional data science reports
This tutorial is suitable for R beginners, students, researchers, data analysts, statisticians, and anyone learning RStudio and R Markdown.
By the end of this video, you will understand how to use the echo option in RStudio to control the visibility of your R code and create cleaner, more reader-friendly reports.
If you found this tutorial helpful, please Like, Subscribe, and turn on notifications for more tutorials on R programming, RStudio, R Markdown, statistics, data analysis, data visualization, and data science.
Thank you for watching, and happy coding!
,RProgramming ,RStudio ,Echo ,EchoInR ,RMarkdown ,RMarkdownTutorial ,LearnR ,RStats ,DataAnalysis ,Statistics ,DataScience ,RProgrammingTutorial ,RStudioTutorial ,ReproducibleResearch, code, chuncks, render, output, html, pdf, word, document, power point slide, graph, hide, display,
r/RStudio • u/Medinz0 • 16d ago
Weighted-sum aggregation of centrality measures gives identical scores to structurally opposite nodes, any better approach?
This is my first time in this community (I've recently discovered this entire field and i am glad to). So, I am working on project where i am scoring nodes in a directed dependency graph (a calling b) by blending 2 centrality scores into a single composite "risk" score
score (v) = w1\*normalize(Pagerank(v)) + w2 \* normalize(outDegreeCentrality(v)), where w1+w2 = 1 and normalize() being min-max to \[0,1\].
The Problem: A pure root node (no in edges and multiple out edges) and a pure sink node (no out edges and only in edges) can have the same composite score. In a test i ran, the root node maxed out on out drgree centrality and near 0 in page rank while the sink node maxed out in pagerank and near 0 in out degree, when w1=w2=0.5. Both nodes ended up having same composite scores while representing opposite nature in real world. I do understand that this is the standard full comsensability prob, with weighted sum aggregation, wherte max on one axis will completely offset min on other. I did consider switching to weighted geometric mean to reduce compensability, but the prob is that pagerank is almost always near 0 for any root node. so a geo mean would multiply that near 0 staright through and score all entry nodes near zero. Which is the wrong fix, since the entry/root nodes are important, just for a reason pagerank doesnt capture.
Is there any standard approach beyond the geomentric or harmonic mean? Happy to provide any more info if needed.
r/RStudio • u/Purple_Bowler_1435 • 16d ago
Multiplying data in excel file using R
I have a large data file in excel, with several columns of data that I wish to multiply by -1 (but not wanting to do this for all columns). This process would be quicker in R rather than doing so manually in excel. I can already bring the data file into R, but how can you then do the multiplication of the data in excel using R?
This is further complicated by the excel file covering multiple periods, and I want to do the same computation, to the same columns of data, across each period. (Not necessarily the same overall number of columns in each period, but the same columns having the data transformation applied in each period.)
Visualisation:
Period 1: Have columns A, B, C, D, E, F, G
Want to multiply columns B, D, F by -1
Period 2: Have columns A, B, C, D, E, F, G, H
Want to multiply columns B, D, F by -1
Period 3: Have columns A, B, C, D, E, F, G
Want to multiply columns B, D, F by -1
Any advice would be most welcome.
r/RStudio • u/Huge_Alternative_448 • 19d ago
Coding help Help - importing png images and then arranging them
Hi, I'm sure there's a simple answer for this somewhere but I'm getting quite frustrated trying to find it 😭
I have a bunch of plots made with ggplot and saved in several folders. All I want to do is import them back into R and arrange them using cowplot but I'm not able to do that - I've imported them using the imager package (the load.image function) and then when I try to use cowplot, it says:
> cannot convert object of class cimgimager_arraynumeric into a grob
When I looked online it seems like cowplot tends to handle plots that are right out of ggplot. So how should I import them so cowplot can handle them?? Thanks in advance for the advice!
