Questions tagged [recode]

Recoding refers to the process of modifying the values of dataset, matrix, or vector according to a set of rules by which input values are changed to replacement values.

Recoding refers to the process of modifying the values of dataset, matrix, or vector according to a set of rules by which input values are changed to replacement values.

624 questions
1
vote
2 answers

Recode column values in MySQL

I am dealing with a column named UCODE130 that has values anywhere from 1-130. I would like to replace the values with ranges. For example, I want to replace any 1, 2, 3, or 4 found in that column with a string "1 - 4" instead. I do not want to do…
emismi95
  • 17
  • 4
1
vote
1 answer

How to recode multiple variables with different values for each variable

I have a survey dataset that contains 100+ variables and almost all have 1-10 code values. The code values per column is provided in another df. Example data: survey_df = structure(list(resp_id = 1:5, gender = c("1", "2", "2", "1", "1"), state =…
Vinay
  • 243
  • 2
  • 5
1
vote
0 answers

recoding problem in R Error : Can't convert to

I have this table and i want to recode it: table(d$votept) 2 3 5 7 8 10 11 13 14 15 16 17 18 59 30 2 1 4 1 1 246 1 8 224 21 1 But when i recode it with plyr::mapvalues like…
Edgar16
  • 11
  • 1
  • 3
1
vote
2 answers

Recode continuous number into continuous dates in Python

I have a variable looks like 1,1,1,1, 2,2,2,3,3,3,3,3,4,4,5,6,6,6, ,.....100,100,100 I would like to recode them into dates 1=31.12.2020 2=30.12.2020 3=29.12.2020 ... In my real case, there will be more than 1000 dates (or more) to be recoded and…
sylvia
  • 197
  • 1
  • 8
1
vote
2 answers

Create a new column from conditions

I have a dataframe with information of some countries and states like this: data.frame("state1"= c(NA,NA,"Beijing","Beijing","Schleswig-Holstein","Moskva",NA,"Moskva",NA,"Berlin"), …
sylvia
  • 197
  • 1
  • 8
1
vote
1 answer

R: expss package - "recode into" not working without do_if?

I am trying to use the recode into function using expss. When I replicate the example illustrated in https://gdemin.github.io/expss/#example_of_data_processing_with_multiple-response_variables I notice the following behaviour: code including a do_if…
1
vote
1 answer

dplyr::recode() over selected variables

I have a data set with columns associated to the same medicine over several months, in it's colnames just change the month number, eg. med1_m1,med1_m2, and so on. I need to create an indicator variable for this medicine, for all the moths, so I have…
esettecase
  • 11
  • 2
1
vote
1 answer

Error in .subset2(x, i, exact = exact) : recursive indexing failed at level 2

I am trying to recode my education variable from a factor with 18 levels to a factor with 7 levels,ranging from no qualification - GCSE D-G, GCSE A*-C- A Level -Undergraduate -Postgraduate - other. bes[[bes$education]]%>% recode('No qualification' =…
Kuddiking
  • 71
  • 1
  • 5
1
vote
2 answers

Using recode() with variable names generated through paste()

I am trying to recode a variable which contains the labels of the answers as a character into numeric values. I am using recode() from dplyr for this. To automate this I wanted to use paste() to generate the variable names but apparently recode()…
Kurtenbach
  • 13
  • 3
1
vote
4 answers

Recoding by an order in r

I have a data recoding puzzle. Here is how my sample data looks like: df <- data.frame( id = c(1,1,1,1,1,1,1, 2,2,2,2,2,2, 3,3,3,3,3,3,3), scores = c(0,1,1,0,0,-1,-1, 0,0,1,-1,-1,-1, 0,1,0,1,1,0,1), position = c(1,2,3,4,5,6,7, 1,2,3,4,5,6,…
amisos55
  • 1,913
  • 1
  • 10
  • 21
1
vote
2 answers

R: How to recode values based on first characters 0|0 vs 1|0 vs 0|1 vs 1|1

Thank you in advance for the help. I am trying to recode a genetic database that contains genotypes coded in VCF format. For context, the VCF format is coded in this format: '0|0:0,0:0:1,0,0'. The main thing I am interested in is the first…
1
vote
2 answers

What is wrong about my syntax using the mutate and recode function?

I am trying to recode the variable FamilyStatus in my dataframe na.df. The characters ("ledig", "verheiratet" and "sonstiges" should be recoded in numerics. I know, there are many similar questions and answers already but nothing fixed my problem,…
cello
  • 11
  • 2
1
vote
1 answer

Loss of the label after using mutate and recode (dplyr) of a character class variable

Again and again I have to search the internet when it comes to label my dataframe variables. For me this is not a trivial issue when doing it in the context with dplyr. Using the set_label function from sjlabelled package I have learned to create a…
TarJae
  • 72,363
  • 6
  • 19
  • 66
1
vote
2 answers

Convert integers to vector in R using Tidyverse

In my data set, a column holds integer numbers that encode whether there was "no" (0), "slight" (1), or "severe" (2) bleeding after a medical procedure. How can I turn those integer values into descriptive names? I tried to to it with factor(levels…
bovender
  • 1,838
  • 15
  • 31
1
vote
2 answers

Issue while recoding multiple variables, error - in .subset(x, j) : invalid subscript type 'list'

I have a dataframe for a likert scale questionnarie. All of the questions have a 1-10 scale, but to run some analyses I want to recode the scale to be from 1 to 5. So, I want to recode most of the variables of my data frame, excluding identification…
Gigi39
  • 45
  • 3