Reprex issues...

I'm doing by best to submit my questions or challenges in reproducible examples but I have constant problems with reprex…

I even started retyping my excel tables or csv files in the r as assignment codes (very time consuming!) but it helped me to prepare one reproducible example (multiResponse in ufs or other easy ways of creating multiresponse sets - #2 by Slavek).
Nevertheless, I have constant errors with the second one :frowning:


Rendering reprex...
Rendered reprex is on the clipboard.
Warning message:
In utils::writeClipboard(rendered_content, format = 1) :
  unable to open the clipboard


No user-supplied code found … so we’ve made some up. You’re welcome!

Another one, after simply copying and "reprexing" this data:

D1 = c(10,10,10,-1,-1,99,-1,10,9,9,10,10,10,10,10,10,-1,-1,9,-1,10,-1)
VIN=c("TMAH3811ALJ058","NLHA851CABZ405","NLHA751AALZ555","TMAHC51AALJ015","NLHB351BALZ577","TMAH2814AKJ049","NLHA851CALZ557","TMAH3813GLJ057","TMAH2514ALJ113","NLHB351AAKZ539","TMAHC51AAKJ018","NLHA851CBLZ558","NLHB351AGLZ580","NLHB351BALZ573","TMAD151AALJ016","TMAHC51AALJ017","TMAH3513GLJ101","NLHA851CB8Z552","NLHB351AGKZ507","NLHB351BALZ573","TMAHCH1AALJ005","NLHA851CALZ557") <- data.frame(URN, D1, ModelLong, VIN)


Removing leading prompts from reprex source.
Rendering reprex...
Error in parse(text = x, keep.source = TRUE) : 
  <text>:18:11: unexpected symbol
17: #+ reprex-body
18: Rendering reprex...

What can I do? I was told that using datapasta instead makes your help difficult

I'm completely sure no one has told you that, even more, we encourage the use of datapasta to provide the sample data required to make a reprex, please read the reprex guide more carefully, since it seems like you are not understanding what a reproducible example is.

1 Like

My understanding is that reproducible example should like this: multiResponse in ufs or other easy ways of creating multiresponse sets but I have issues with using reprex again. I can describe my task as clearly as I can using the data file submitted above but I cannot generate reproducible example. All I can do easily is submitting that:

# The task is correcting values in ModelLong field in the original data.

# Step 1: Substracting variables required to adjust ModelLong

library(stringr) <- %>% 
mutate(VINChar = substring(VIN, 4, 5),
       VINYear = substring(VIN, 10, 10))

library(car)$Year <- recode($VINYear,"'B'=2011;'K'=2019;'L'=2020;8=2008")

# Step 2: Fixing incorrect or missing ModelLong information (THIS IS SOMETHING I NEED YOUR HELP WITH as it's not working) <- %>% 
  mutate_if(ModelLong="aa") # using Year to replace 'aa' by 'aa (new)' or 'aa (old)'
mutate(ModelLong = case_when(
  Year >= 2014 ~ "aa (new)",
  Year < 2014 ~ "aaa (old)"
)) %>%
  mutate_if(ModelLong="ccc") # using VINChar to replace 'ccc' by correct ModelLong code
mutate(ModelLong = case_when(
         VINChar == 'D1' ~ "ccc (2012-2015)",
         VINChar == 'H2' ~ "ccc (2016 ~ )",
         VINChar == 'H3' ~ "ccc (2016 ~ )"
       )) %>%
  mutate_if( = ModelLong)) # using VINChar to create ModelLong code for records with ModelLong code missing
mutate(ModelLong = case_when(
  VINChar == 'D1' ~ "ccc (2012-2015)",
  VINChar == 'H2' ~ "ccc (2016 ~ )",
  VINChar == 'H3' ~ "ccc (2016 ~ )",
  VINChar == 'B3' ~ "ddd",
  VINChar == 'A8' ~ "aaa"))

# Step 3: Creating new variable showing main Models <- %>% 
  mutate(ModelCat = case_when(
    ModelLong =='aa (2014 ~ )' ~ "aa (2014+)",
    ModelLong =='bb (2014 ~ )' ~ "bb (2014+)",
    ModelLong =='ccc (2016 ~ )' ~ "ccc (2016+)",
    TRUE ~ "other"

But I don't want to ask for help if the above description can be perceived as rudeness or require more time from your side.

Again, you don't necessarily need reprex package in order to make a proper reproducible example, all you need to provide is

  • A minimal dataset, necessary to reproduce the issue
  • The minimal runnable code necessary to reproduce the issue, which can be run
    on the given dataset, and including the necessary information on the used packages.

And you can use datapasta for providing the minimal dataset, so providing a reprex doesn't imply not using datapasta.

So does my description of the problem above include "The minimal runnable code necessary to reproduce the issue"? Is the description good enough to run everything and check where the issues are?

The problem is that it is not "minimal" since the "issue" is not well defined, we are here to provide help with specific coding problems not for doing your job for you, so defining your coding problems as your whole task is not OK, you have to narrow down the scope of your questions to specific coding problems and provide code that is relevant just for that specific issue.

I see. So the example above should be fine I guess because steps 1 and 2 are only two of many steps of my task and I always focus on a small part of entire work, the part I have problems with (so in this case steps 1 and 2). Can I then submit the data and steps 1 and 2 in this format as my question/request?

That would be to much unnecessary code, we only need the "minimal" code to reproduce your issue, so no previous data-wrangling steps are required and there is no need to include all your mutate statements, just the ones that reproduce the issue (which BTW you are not specifying).

1 Like

Thank you. I'll do my best and I really appreciate your help. Most of the tasks I have are tests for R tool as I could easily complete all of them in SPSS. I just find R amazing and powerful and try to challenge myself with repeating my standard SPSS calculations in R :smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.