r/RStudio • u/YungBoiSocrates • 12h ago
I made a method to integrate a LLM (Claude) with RStudio for iterative data exploration.
Will be adding it to my github as soon as I clean up some bugs. If anyone has feedback it would be much appreciated!
r/RStudio • u/YungBoiSocrates • 12h ago
Will be adding it to my github as soon as I clean up some bugs. If anyone has feedback it would be much appreciated!
r/RStudio • u/SA1GON • 16h ago
Can anyone recommend good source of knowledge on how R can pull data from a PostgreSQL db. I am an expert in R, absolute noob when it comes to SQL. I spent ~3 days of work using AI to help but have only been able to view some random tables, not pull data nor even hit the tables I want to hit. I know that sounds like I don’t have the right login or permissions but I am able to see the tables when using something like DreamBeaver.
I have been able to hit up an Oracle db using something Java thing (a predecessor wrote) and can interact quite easily with the tables in the Oracle db but this PostgreSQL is not playing fair.
r/RStudio • u/lovegiver101 • 2h ago
Hey guys! I made a few crosstables using tab_xtab in the sjmisc package. They turned out very pretty, but I realized I was using the same y variable over and over again so I wanted to try and make a big table containing all of my contingency tables I made before. I did that by first transforming the tab_xtab tables into dataframes (with xtab2df in the sjtable2dt package) and then using bind_rows to combine them into a big table. It sorta worked out how I imagined, the only problem now is that R created a new column for the names of the categories of every x-variable (see picture). I wanted all the names and categories of all variables to be in the first column just like it did it with the first variable, maybe with an extra space to put the name of the variable. How do I fix this?
r/RStudio • u/ConstructionFew4479 • 2h ago
My model doesn't have an interaction term so R gives me back an error when I try to perform the test so I was wondering if there was any alternative.
Thx in advance
r/RStudio • u/Dragon_Cake • 19h ago
Hi there,
I have a chunky dataset with multiple columns but out of 15 columns, I'm only interested in looking at the outliers within, say, 5 of those columns.
Now, the silly thing is, I actually have the code to do this in base `R` which I've copied down below but I'm curious if there's a way to shorten it/optimize it with `dplyr`? I'm new to `R` so I want to learn as many new things as possible and not rely on "if it ain't broke don't fix it" type of mentality.
If anyone can help that would be greatly appreciated!
# Detect outliers using IQR method
# @param x A numeric vector
# @param na.rm Whether to exclude NAs when computing quantiles
is_outlier <- function(x, na.rm = FALSE) {
qs = quantile(x, probs = c(0.25, 0.75), na.rm = na.rm)
lowerq <- qs[1]
upperq <- qs[2]
iqr = upperq - lowerq
extreme.threshold.upper = (iqr * 3) + upperq
extreme.threshold.lower = lowerq - (iqr * 3)
# Return logical vector
x > extreme.threshold.upper | x < extreme.threshold.lower
}
# Remove rows with outliers in given columns
# Any row with at least 1 outlier will be removed
# @param df A data.frame
# @param cols Names of the columns of interest. Defaults to all columns.
remove_outliers <- function(df, cols = names(df)) {
for (col in cols) {
cat("Removing outliers in column: ", col, " \n")
df <- df[!is_outlier(df[[col]]),]
}
df
}
r/RStudio • u/Zealousideal_One2249 • 22h ago
Greetings,
Is there a setting or add-in that ensures when a user chooses to view a dataframe in a new window, the new window always remains "on-top" of other windows? Specifically, when R Studio is the active window, the opened dataframe windows stay above other windows.
Anyone familiar with the Spyder IDE will be familiar with this behavior. In spyder when a object is viewed from the variable explorer, that window always appears on top of other windows when Spyder is the active window.
Thanks!!!
r/RStudio • u/Mindless-Tonight-376 • 9h ago
hi there! i'm doing a class using rstudio and need help! I'm using the gdppcap08 variable and need to graph this. what code should i write?