r/RStudio

Which LLM Integration to use?

Hi everyone,

I’m looking to see if anyone has experience integrating AI models directly in RStudio. I really want something that works natively inside RStudio and can access the loaded dataframes, libraries, and variables, so I don’t have to keep explaining what each variable is called, like I need to do when using the LLM in the browser.

- I’ve used Autopilot before, but I found the autocompletes unhelpful.

- chattr just seems to be a chat window inside RStudio without access to the current script or dataframes

- I recently saw that RStudio offers a new native AI, but it’s $20 a month, which is pretty pricey—especially as opposed to other LLMs you can't use it for other tasks like text or image generation.

- ClaudeR seems to do what I'm looking for. Any experience on how fast the tokens of the pro model are maxed out using this?

So: is there something that natively integrates into RStudio? A big plus would be if it integrates with Gemini, since that’s currently my favorite model.

Extra: I’d also love to hear if there is something like fully autonomous models—ones that just analyze the data on their own without a lot of guardrails. You give it the dataframe, information on key variables and what your hypothesis is and it iterates and debugs the code, tries out various tests and so on. When seeing reports on openclaw I just thought, this would be something viable today?

reddit.com
u/gordgostoso — 2 days ago

Help with R code!!!

https://preview.redd.it/3hg1pzxci52h1.png?width=1094&format=png&auto=webp&s=bdec36e242db6aa1232374fdd0146a813541c0e2

Hi all,

I am trying to make a histogram of some data I collected. I am trying to stratify my "baseline" data by biological replicate and all other data (a separate category called ExM) by gel. I want it to look something like what I've drawn below. This is the code I am currently working with and the current output. Any recommendations will be greatly appreciated!

# mean + SD per gel × tissue_type

gel_stats <- DAPI_Quant %>%

group_by(gel, tissue_type) %>%

summarise(

mean_avg = mean(ratio, na.rm = TRUE),

sd_avg = sd(ratio, na.rm = TRUE),

.groups = "drop"

)

# Convert gel to character

gel_stats$gel <- as.character(gel_stats$gel)

# Create color palette

unique_gels <- unique(gel_stats$gel)

# ExM palette (Dark2)

exm_palette <- scales::brewer_pal(type = "qual", palette = "Dark2")(length(unique_gels))

gel_colors <- setNames(exm_palette, unique_gels)

# Baseline override (curve color)

gel_colors["baseline"] <- "grey30"

# plot styling + axes

p <- ggplot() +

theme_classic(base_size = 10) +

theme(

legend.position = "right",

axis.title = element_text(size = 10),

axis.text = element_text(size = 10),

plot.margin = margin(10, 10, 10, 10)

) +

xlim(0.75,1.35) + ylim(0, 15)+

labs(

x = "XY Ratio",

y = "Density"

)

# histogram per gel

for (g in unique_gels) {

df_gel <- DAPI_Quant %>% filter(gel == g)

# Baseline bars grey, ExM bars keep their original color

hist_fill <- ifelse(g == "baseline", "grey30", gel_colors[g])

p <- p +

geom_histogram(

data = df_gel,

aes(x = ratio, y = after_stat(density)),

bins = 150,

fill = hist_fill,

alpha = 0.25,

color = NA

)

}

for (i in 1:nrow(gel_stats)) {

row <- gel_stats[i, ]

g <- row$gel

# Baseline curve grey, ExM curves keep their colors

curve_col <- ifelse(row$tissue_type == "baseline", "grey30", gel_colors[g])

p <- p + stat_function(

fun = dnorm,

args = list(mean = row$mean_avg, sd = row$sd_avg),

color = curve_col,

linewidth = ifelse(row$tissue_type == "baseline", 1.4, 1.1),

lineend = "round",

inherit.aes = FALSE

)

}

p

https://preview.redd.it/nhd1e4poh52h1.png?width=1132&format=png&auto=webp&s=2c9832379f59bc7543282334da02870e7623a6ad

reddit.com
u/ashwithasmile — 3 days ago
▲ 14 r/RStudio+1 crossposts

qol 1.3.1 &amp; printify 1.0.1 - Update with detailed refinements

qol is a package which can be used as its own ecosystem concerning descriptive evaluations, data wrangling, tabulation and much more. It offers over a hundret high level functions which make the coding life easier. While the last updates implemented many entirely new functions, this update focuses more on refining the existing ones.

printify is the base R zero dependency message system which is directly implemented in qol, but can also be used as a stand alone lightweight package.

A detailed overview for both packages can be seen here:

qol: https://github.com/s3rdia/qol

printify: https://github.com/s3rdia/printify

So what is in the update?

Renamed functions

compute() and recode() have been renamed and now have a "." at the end (compute.() and recode.()) to prevent masking errors in combination with dplyr. This means existing code will break, if these functions where used.

Mesage system

* set_no_color(): Suppresses the color codes so that messages can be printed clean. The option is auto controlled on load via the system variable `NO_COLOR` but can also be set individually by this function. Console output in e.g. RStudio vs. output to a logging system should be handled automatically right now.

* set_up_custom_message(): Waiting symbols as well as the color of the time stamps can now be customized.

* print_step(): Now has a new `in_place` parameter, which prints the message on the same line as before, instead of in the next line. This can e.g. be used inside loops as follows.

new_in_place_steps &lt;- function(){
    print_start_message()
    
    print_step("MAJOR", "Let's get started...")
    
    for (i in seq_len(10)){
        print_step("Minor", "This is in place step [i] of 10", i = i, in_place = TRUE)
        Sys.sleep(0.25)
    }
    
    print_step("MAJOR", "Loop has ended")
    
    print_closing()
}

new_in_place_steps()

Tabulation workflow

any_table() and export_with_style(): If the whole result list from these functions is passed for the `workbook` parameter, the functions now are able to extract the actual workbook from the list and run without error. Additionally if a list is passed, which is not a result list containing the workbook, the functions error and abort execution.

any_table(), frequencies(), crosstabs(): If 'csv' is specified as extension in the `file name` set in the global options or the style parameter the result table will then be exported as 'csv'. Otherwise the actual workbook will be exported as `xlsx` as normal.

New way to transpose data

transpose_plus() can now in a wide to long transposition not only put results below each other, but also side by side.

# Example formats
age. &lt;- discrete_format(
    "Total"          = 0:100,
    "under 18"       = 0:17,
    "18 to under 25" = 18:24,
    "25 to under 55" = 25:54,
    "55 to under 65" = 55:64,
    "65 and older"   = 65:100)

sex. &lt;- discrete_format(
    "Total"  = 1:2,
    "Male"   = 1,
    "Female" = 2)

# Example data frame
my_data &lt;- dummy_data(1000)

# Transpose from long to wide and use a multilabel to generate additional categories
long_to_wide &lt;- my_data |&gt;
    transpose_plus(preserve = c(year, age),
                   pivot    = "sex",
                   values   = c(income, weight),
                   formats  = list(sex = sex., age = age.),
                   weight   = weight,
                   na.rm    = TRUE) |&gt;
    rename_multi("income_Total"  = "Total",
                 "income_Male"   = "Male",
                 "income_Female" = "Female")

# Transpose back from wide to long but this time put results side by side.
# To do that every list entry has to have the same name. The values parameter
# is then used to give the new value variables a name. For the expressions of
# the new categorical variable the variable names from the first pivot list
# entry are used.
wide_to_long &lt;- long_to_wide |&gt;
    transpose_plus(preserve = c(year, age),
                   values   = c(income, weight),
                   pivot    = list(sex = c("Total", "Male", "Female"),
                                   sex = c("weight_Total", "weight_Male", "weight_Female")))

if.() can now explicitly delete

If the new `delete` keyword is passed instead of a variable assignment, the provided condition deletes observations instead of keeping them.

subset_df &lt;- my_data |&gt; if.(sex == 1, delete)

# Is the same as
subset_df &lt;- my_data |&gt; if.(sex != 1)
u/qol_package — 5 days ago
▲ 58 r/RStudio

I released my first R package. It's for landscape connectivity optimization and wildlife corridors. Would love any feedback from this community

If anyone is doing ecological restoration or landscape level planning for wildlife would love any thoughts you have on my package. There's a web tool and QGIS plug-in available too if that's easier. Many thanks
TerraLink

u/BrotherBringTheSun — 9 days ago

Trying to add labels of count to my stacked bar chart

Hi everyone,

thank you everyone who has taken the time to help me before, I am really, really appreciative. Since I don't know the language that well yet and I am very much learning by doing, as I finish the project I am working on presently, I struggle with finding the errors, when I apply the answers others were given online.

I have created a stacked bar chart and I would very much like to add counts to the columns.

surveyresponses_Freizeit_Master_for_stacked %&gt;%
  pivot_longer(-Arbeit, names_to = "Group", values_to = "value") %&gt;%
  summarise(count = sum(value), .by = c("Arbeit", "Group")) %&gt;%
  ggplot(aes(Group, count, fill = Arbeit,)) +
  geom_col() +
  theme(axis.text.x = element_text(angle = 60, vjust = 1, hjust=1))

This would be my code, and it produced the graph as I need it... However, when I tried to add the count, based on this code that tackled a similar problem:

# Source - https://stackoverflow.com/a/63656093
# Posted by stefan, modified by community. See post 'Timeline' for change history
# Retrieved 2026-05-13, License - CC BY-SA 4.0

library(ggplot2)

ggplot(mtcars, aes(cyl, fill = factor(gear))) +
  geom_bar(position = "fill") +
  geom_text(aes(label = after_stat(count)),
    stat = "count", position = "fill"
  )

I receive this result:

Browse[1]&gt; surveyresponses_Freizeit_Master_for_stacked %&gt;%
+   pivot_longer(-Arbeit, names_to = "Group", values_to = "value") %&gt;%
+   summarise(count = sum(value), .by = c("Arbeit", "Group")) %&gt;%
+   ggplot(aes(Group, fill = Arbeit, label = after_stat(count)), stat = "count") +
+   geom_col() +
+   theme(axis.text.x = element_text(angle = 60, vjust = 1, hjust=1))
Error during wrapup: Problem while mapping stat to aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error:
! Aesthetics must be valid computed stats.
✖ The following aesthetics are invalid:
• `label = after_stat(count)`
ℹ Did you map your stat in the wrong layer?

I understand the error message, but I am not sure what I ned to change to get the desired result... Again, I appreciate any help!

u/fuckpineapplepizza — 9 days ago

Creating a stacked bar chart with a complex data set - advice please

Update: Has been solved, thank you for all the responses

Hi everyone,

everyone has been so kind and helpful so I am asking one last question, that the internet, unfortunately, could not answer for me...

I would like to create a stacked bar chart with a complex dataset. My dataset looks a little like this:

Work Group 1a Group 1b Group 2a ...(up to 9)
yes 0 1 0 ...
no 1 0 0 ...
...

I have tried to use this explanation online, but I am unsure what to add for "points" in the code.

#create data frame
df &lt;- data.frame(team=rep(c('A', 'B', 'C'), each
=3),
                 position=rep(c('Guard', 'Forward', 'Center'), times
=3),
                 points=c(14, 8, 8, 16, 3, 7, 17, 22, 26))

#view data frame
df

  team position points
1    A    Guard     14
2    A  Forward      8
3    A   Center      8
4    B    Guard     16
5    B  Forward      3
6    B   Center      7
7    C    Guard     17
8    C  Forward     22
9    C   Center     26



library
(ggplot2)

ggplot(df, aes
(fill=position, y=points, x=team)) + 
  geom_bar(position='stack', stat='identity')

Further explanation:

I am trying to map which students have time for leisure so the dataset looks as follows:
'Work' answers the question "Do you work?" with Yes or no
Group 1a would be: Yes I have time for leisure and my parents support me
Group 1b would be: Yes I have time for leisure and my parents don't support me --> if a person falls into this category I assigned a 1, if they don't a 0 --> this counts for all the groups (up to 9).

I would like to have all the groups on the x-Axis and the answers to "do you work" stacked for each group.

Would the best approach be, to group the yes or no answers and count the values for each group and then based off of that do the stacked bar chart?

Unfortunately, since it has taken me a while to relearn a lot about R and there were a lot of data to present and organise, I am by now in a bit of a time crunch, so I only have today to finish all my graphs and I don't have as much time as I would like to try out different approaches. I'd appreciate any help you can give me.

reddit.com
u/fuckpineapplepizza — 10 days ago

How do you access disabled functions in R packages? I'm trying to use some functions from wehoop and hoopR

I'm doing a thesis on understudied defensive effects on win percentages and salary in the WNBA and NBA. I found an R program package called wehoop (WNBA) and hoopR (NBA) that had load functions for all the stats I wanted to use (shown in the code blocks). I went to run them today and on the women's side it says the package doesn't exist in the 3.0.0 version of wehoop and makes blank data tables in the 2.0.0 version. The hoopR version is also creating blank tables with all zeroes.

Does anyone know how to access the old functions and data? I think the functions were disabled or something in the newer versions and I can't get the old versions to work.

wnba_boxscorehustlev2

nba_leaguehustlestatsplayer
reddit.com
u/Lucky-Efficiency-644 — 9 days ago

msummary p-values different from the p-values of my models

Hi!

I'm making summary tables for a set of linear mixed models using the function msummary and the package KableExtra. My problem is that the p-values given by the msummary function I use to build my tables are not the same that the ones in my models. I understood that msummary has a different was of calculating the p-values than the summary(lmer) but I really need the p-values from my actual models and I don't manage to figure out how to get msummary to calculate/extract that. Does someone has an idea about what I could do to fix that?

Here's my code:

modeltable=msummary(models,
                    output = "kableExtra",
                    statistic = c(
                      "SE = {std.error}"),
                    stars = c('*' = .05, '**' = .01, '***' = .001),
                    coef_map = coef_map,
                    gof_map = NA,
                    add_rows = add_rows,
                    fmt = 3,
                    escape = FALSE)

Many thanks!

reddit.com
u/aNervousBiologist — 10 days ago

Pay someone to do my homework

To pass my R studio class I need to finish this project, it’s pretty straight forward but I’m too lost and it’s too far gone to learn now. Please help!! I’ll pay

reddit.com
u/Vegetable_Ad_6369 — 10 days ago

Calculating percentages

Hi everyone,

thank you for your help last time with finding the problem in my code for plotly. I am struggling with calculating the percentages and receiving a tidy usable table using the mutate() function. Unfortunately, all the tutorials online do not seem to work for me and I don't understand what I am doing wrong.

```

surveyresponses_Freizeit_Master_count=surveyresponses_Freizeit_Master%>% count(.$`Bleibt genug Zeit für Freizeit?`)

```

After this I receive a table where all the answers per group have been calculated and what I would need is an additional column in which I have the percentages adding up to 100% and I am not sure how to get there... Could anyone please help? I would really like to learn how to do it and to truly understand it, because while I could do it by hand, I do have two more datasets I need to do this for. I appreciate any help.

https://preview.redd.it/ks6vlv7xyn0h1.png?width=874&format=png&auto=webp&s=0a81cc3ef285846578dbd28c60a9f586736983d5

reddit.com
u/fuckpineapplepizza — 10 days ago
▲ 26 r/RStudio+1 crossposts

How much S7 is my R package?

Hi everyone,

I’ve been exploring the new S7 object-oriented programming system and decided to build a proper project to learn its mechanics. I created `{linkfunctions7}`, a package that implements a framework for link functions entirely using S7.

Since S7 is still relatively new and best practices are still emerging, I would love to get some feedback from developers who have more experience with it or with R package development in general.

Any critiques or suggestions are incredibly welcome. I really want to make sure I am writing actual S7 code rather than just forcing S3/R6 habits into a new syntax.

Thanks in advance for your time!

u/Pool_Imaginary — 10 days ago

How to add a trend line to a specific data series, along with the equation of the line?

hey guys, i’m writing some code to generate a trend line, but when i use this code, the line becomes misaligned and appears to be offset (idk why). i’d also like to know if there’s a command or method for creating a trend line similar to the one shown in excel. i used the next code:

lm_c1<-subset(c1,Time %in% c(2,3,6))

C1<-ggplot(c1,

aes(x=Time, y=LnOP))+geom_smooth(data=lm_c1,method ="lm", se = FALSE, color = "#082E8B", linewidth = 0.8)+geom_line(color="#8B6508")+geom_point(shape=21,fill="#EEAD0E",size=1.5,color="#CD950C",stroke=1.5)+scale_y_continuous(labels = function(x) sprintf("%.3f", x))+scale_x_continuous( breaks = seq(0, 60, by = 2))+theme_few()+theme(axis.title.y=element_text(margin=margin(r=35)), plot.margin = margin(10, 5, 5, 5),text= element_text(family = "Times New Roman"))

reddit.com
u/Ender_MQ — 12 days ago

Hi everyone,

I have tried finding out what the issue is for quite some time now, but since I am not the most proficient regarding technology, I am struggling finding something applicable.

My goal was to do a simple pie chart with plotly, but for some reason the code that I used previously and copy-pasted, always comes back with the 'unexpected symbol' error. I have tried finding a punctuation error or a misspelling, but nothing. I downloaded the new version of R Studio today and I think I might be missing some packages, but I also don't know which ones they might be and my research did not yield anything. I have installed tidyverse, plotly, dplyr, ggplot2 and readxl.

I used the code from this website and adjusted it for my dataset

https://www.geeksforgeeks.org/r-language/how-to-create-pie-chart-using-plotly-in-r/

'plotly::plot_ly(data=surveyresponses_Freizeit_Bachelor_count,values=~n,labels=~factor(Bleibt genug Zeit für Freizeit?),'

'marker=list(colors=c("green","orange","blue")),'
'type="pie") %>% layout(title="Bleibt genug Zeit für Freizeit im Bachelor?")'

I look forward to any input and thank you all in advance for your help. Maybe it's something really stupid, that I just didn't see...

u/fuckpineapplepizza — 14 days ago

Hi. I heard the company mading RStudio also made Positron. Both are free code editor. My question: how compagnies like this one is making a livibg ? What is their business model when everything seems free ?

thx

reddit.com
u/Top-Vacation4927 — 14 days ago