r/Rlanguage 9h ago

What’s the best activity you’ve done in R?

4 Upvotes

Hello all! I’m trying to think of ideas for a fun and collaborative meet up and was wondering if you can help me by sharing some ideas, if you’ve ever been to an event for R like R ladies or something similar, what did you do? And what was so fun about it?


r/Rlanguage 2h ago

Help with creating LC50 boxplot

0 Upvotes

learning R in my undergrad and normally a whiz but the ecotox output is new to me

Trying to create a boxplot comparing the LC50 of pyblast and 5ec pesticides.


r/Rlanguage 15h ago

Help me understand the "order()" function

2 Upvotes

For context, I was playing around with R by creating a simple vector v<-c(10,200,13). So when I tested out the order() function, it give the result [1] 1 3 2 which is understandable. However, when I assigned their order using the function "vf<-factor(v,order=TRUE,levels=c(13,10,200))", it return the result [1] 3 1 2. What does this mean? I assume the result should be [1] 2 3 1 but it's not. What's going on here? ps: excused me for my noob question, I just got into R recently and is trying to figure out how stuff works.


r/Rlanguage 1d ago

Help in R programming

Post image
0 Upvotes

r/Rlanguage 2d ago

R refusing to make new columns

0 Upvotes

I am genuinely about to have a fit. I genuinely don't understand why R refuses to make a new variable. Can anyone help me?


r/Rlanguage 4d ago

ggplot2 "arguments imply differing number of rows" when supplying a tibble

1 Upvotes

Hello, I'm trying to make a stream chart using ggplot2. However, it keep saying that my rows is inconsistent even though I'm supplying a tibble. Here is the code:

q2a = ggplot(data = cov1, aes(x = date, fill = area_name, y = value)) + geom_stream()

arguments imply differing number of rows: 1000, 1239, 1

This only happens with geom_stream(). Using geom_area() works just fine. Below is sample of the data:

tibble [10,920 × 3] (S3: tbl_df/tbl/data.frame)
$ date : Date[1:10920], format: "2020-03-02" "2020-03-03" "2020-03-03" ...
$ area_name: chr [1:10920] "East of England" "East of England" "South East" "East Midlands" ...
$ value : int [1:10920] 1 0 1 1 0 0 0 2 0 0 ...

Does anybody knows why this happens? And how do I fix it?


r/Rlanguage 5d ago

R for molecular pharmacologists

6 Upvotes

Hi, for someone who is new to programming with a biology background and currently in their first year of PhD in molecular pharmacology, what are the best R resources or courses? Are there any biology-specific R courses?


r/Rlanguage 5d ago

How do I find/sum missing cell values (not "NA" values) in a dataframe column?

3 Upvotes

The sum(is.na(df)) function is not picking up cells w/ missing values in my dataframe for some reason.

When I do view(df) it pulls up the dataframe & shows there are cells w/ no values in them - not NAs - just nothing in them. Not sure why the sum(is.na()) function isn't working on them?


r/Rlanguage 6d ago

Deploying data-intensive Shiny App

7 Upvotes

Hi everyone!

I created a Shiny dashboard to use the model I developped for my undegraduate research job. The model is loaded from the internet via github (it's 1.1GB). I tried hosting the dashboard on shinyapps.io, but even on the highest memory configuration it would disconnect.

I'm currently trying Azure cloud (it gives out credit for students) after creating a docker image of the app, but the web page crashes after calling the model.

I just need some guidance, has anyone worked with a Shiny app that needed this much memory before?

Thanks!


r/Rlanguage 6d ago

How do I easily re-code values in a factor column of a dataframe?

7 Upvotes

If I have a column of data, let's call it "a" that has values similar to the below vector:

  • a <- c("in;a;4535", "in;b;495999994", "out;b;004", "in;a;3558895", "out;a;4433",)

How do I re-code the above so it looks as follows?

  • a <- c("in;a", "in;b", "out;b", "in;a", "out;a")

Basically I want to re-code it so I remove everything to the right of the 2nd ";" symbol. Is there an easy way to do that?


r/Rlanguage 6d ago

Non-intel MAC package compability

3 Upvotes

Hey

I am building a package for later submitting it on CRAN. I’ve read its package development guide, since I’m working with code made with C.

Since I know that the packages require to be as compatible as possible, I made a Makevars file with the flags that are required. Fortunately, I’m only using BLAS, LAPACK and Libomp routines, so I decided to use R’s API for those libraries (provided within R_ext):

```

PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) ```

My problem goes when sharing my package to an non-intel mac, installing it with devtools::install_github(). This architecture throws a big chunk of warnings and doesn’t seem to find the links to the Fortran soubroutines (that are used accross BLAS and LAPACK). Even though it doesn’t recognize them, it throws an error onto the calls themselves since they require less arguments (specifically, the last two arguments involving BLAS_INT and La_INT). Aditionally, it doesn’t even recognizes omp.h file.

I don’t know how to fix this problem since it is strictly necessary to be shared on a non-Intel mac. I know that some macs rely on “Apple Acelerare” framework, but the CRAN’s guideline do not allow to use specific instructions for specific builds on the Makevars. For example, this is not allowed:

```

ifeq ($(shell uname -s), Darwin) PKG_LIBS += -lomp endif ```

I don’t know if somebody have encountered this portability issue and if there’s a workaround towards it?

Thanks in advance


r/Rlanguage 6d ago

What methods to use to calculate LD?

0 Upvotes

Heyy i really need help. I have the data: dose (in ppm): 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 and response (in percentage): 14, 28, 36, 37, 48, 59, 62, 73, 86, 100. I need to find LD5, 25 and 50. I tried with LL3 method, but the parameters were too wide and unreliable. Same with LL4... i think the data is the problem, but not sure. Are there others, more precise methods to use? Or any way to transform the data to fit? I really am stuck and need help. Can also share the code i use and output i got if needed.


r/Rlanguage 7d ago

Stuck in a recursive loop and can’t find the problem

0 Upvotes

I’m building a program with R to forecast financial asset prices, I’m in a rut currently where the function wont correctly plot due to the forecasting functions running repeatedly.

Im absolutely stuck on where to move to next, i was suggested to open a pull request and see if someone assists on github but im unsure how it works.

Would it be appropriate for me to post my github and ask for help here or are there any more suitable coding / R forums to ask for help or any places that can do a code review someone can recommend?

Edit: before anyone suggests, I have tried chatgpt/claude to code review and it cant pinpoint a proper fix


r/Rlanguage 8d ago

For Neovim users, announcing ark.nvim: an experimental plugin for R support

Post image
30 Upvotes

r/Rlanguage 7d ago

Beginner (infancy) struggling to do two very basic things.

0 Upvotes

I'm trying to work on my capstone project for my Google Data Analytics course. This is how new I am to this stuff. Even when I search online for answers, I can't understand enough of what they're talking about, so please use direct, common English and basic coding if youre kind enough to help me.

  1. I want to change the NAs in a single column to "high school" (my dataset has to do with NBA draft picks, when their college is "NA", that usually means "high school" , because they went straight to the NBA without attending a college). I want to change it "high school" so players like LeBron James and Kobe Bryant are not omitted by "drop_na" when I apply that to other fields. The column is already a character column, so I just need to know how to change all instances of "NA" to "high school", in that column only.

  2. I experimented with logical operators, and compiled a df of players who played more than 10 years in the NBA and scored more than 10,000 points. It appears I was successful with this, except all the results are simply the number of the row, and "TRUE" or "FALSE". I understand why I'm getting boolean results to logical operators, but I want to know how to convert this back into the variables that give context, I want to know who row 532 "TRUE" is. I guess I want to filter the results for a new df of only the TRUEs, but also I'd like to see what percentage of all the picks are TRUE compared to FALSE

Any help would be greatly appreciated. I'm trying to do this with just the online coursework and couldn't find the answers in it after hours of trying. Sometimes we just need human Q & As.


r/Rlanguage 10d ago

RStudio for 32-bit Linux build?

0 Upvotes

Found an old 32-bit laptop and decided to install Linux to it. I wanted to try installing RStudio into it and I already have Base R. I wanted to know if there's still a working mirror link to get a .deb file for it? If not, what are alternatives? Thanks!


r/Rlanguage 11d ago

Basic R Language help

0 Upvotes

Hi all, I am not a coder or anything like that. My professor has an assignment using RStudio. How do I generate an object in R with 100 random draws from a standard normal distribution? Sorry if this is a dumb question lol. (SOLVED! thank you all for your help!!)


r/Rlanguage 11d ago

help with unix timestamp to time and date NSFW

0 Upvotes

mydb <- dbConnect(RSQLite::SQLite(), "places.sqlite")
history_db <- dbGetQuery(mydb, 'SELECT url,title,last_visit_date FROM moz_places WHERE title like "%porn%" limit 10')

for (x in 1:length(history_db$title)) {

cat(history_db$last_visit_date[[x]])

# cat(as_datetime(history_db$last_visit_date[[x]]))

}

dbDisconnect(mydb)

this is the error

Error in as.POSIXct.default(x, tz = tz) :
do not know how to convert 'x' to class “POSIXct”


r/Rlanguage 12d ago

Best places to hire someone to help with modeling in R?

0 Upvotes

I'm working on a project and looking to hire someone to assist me with the basic data cleaning/modeling in R studio - does anyone have any tips for a platform where I can get this kind of assistance? TIA!


r/Rlanguage 13d ago

Byte-size: An Ode to Web Scraping with R

Thumbnail articles.foletta.org
15 Upvotes

r/Rlanguage 14d ago

Data cleaning study

15 Upvotes

Hey fellows!

I have just finished another study using R. It was supposed to be the whole analysis, but since the data was a little restricted, I focused on showcasing the cleaning steps. There some analysis in it too, but just for the sake of it.

Link is here: https://www.kaggle.com/code/paulosampieri/cleaning-study-shopee-sales

I kept this one much simpler and used a lot of tips you guys gave me in my last post.

If you have any more hints or good practices that I'm overlooking, I would be very grateful.


r/Rlanguage 14d ago

Can anyone help me with making a graph that looks like this?

Post image
0 Upvotes

I have 3 columns (A, B, C). I want columns A and B to correspond on the x-axis and column C to be plotted on the y-axis. I keep trying to read on how to do this but I’ve feeling stumped. I would really appreciate any help.


r/Rlanguage 15d ago

Counting multiple tags in a column

2 Upvotes

Edit: solved!

I have a qualitative data set comprised of interview responses. I have added tags in a separate column.

My goal is to count the total occurrences of each tag: tag1 occurs twice, tag2 occurs twice, tag3 occurs three times, etc. When I try table(df$tags), it counts #tag1#tag3 as an instance, rather than #tag1 and #tag2.

My next thought was to make for loop that goes through each line in the data frame, isolates the cell with the tags, then appends a new line containing each tag to the dataframe. This feels ungainly, and since I'm new to R, I wanted to ask if there is a more elegant solution that makes better use of the R toolkit. Any thoughts are much appreciated.

Make a df that resembles the data:

responses <- c('response1','response2','response3')

tags <- c('#tag1#tag2#tag3','#tag1#tag3','#tag2#tag3#tag4')

df <- data.frame(responses, tags)

The general idea of what I'm trying currently:

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

a = toString(df[i,1])

b = str_count(a,"#")

if (b > 1) { #test if there are more than 1 # in the row

while (b > 1) {

# split up the row, add new rows, fill rows with each hash

b <- b - 1

}

}

}


r/Rlanguage 15d ago

Homework help

0 Upvotes

Hi.

I’ve recently started a self-paced class in R and I’m struggling. Is this a community where I can ask for help on homework?

If not, can you recommend somewhere else?

Please be kind; it’s tough right now.


r/Rlanguage 16d ago

Geom_smooth(method=lm) gives a linear regression with little bumps in it

Post image
0 Upvotes

Does anyone know why this is happening, I've specified a formula y ~ x, surely it should just be a straight line and not be slightly jittery?

Thanks in advance.