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
0
votes
0 answers

Recode factor to numeric systematically in dataframe

My question seems a pretty recurrent one in R (convert factors to numeric in dataframe). Still solutions are not straightforward. What I want is to systematically recode ordered factor variables to ordered numeric variables. I want to have your…
giac
  • 4,261
  • 5
  • 30
  • 59
0
votes
0 answers

C - segfault when I do "cmd | cmd | cmd ; exit"

I have to recode a shell in C and when i'm try to do, for example, ls | ls | ls ; exit, I have a Segmentation fault. (malloc.c:3630: _int_malloc: Assertion `(unsigned long)(size) >= (unsigned long)(nb)' failed. Aborted) My exit was running before…
Stéphane G.
  • 127
  • 1
  • 15
0
votes
1 answer

R - converting character variable as.numeric, but in descending alphabetical order

So I have a character variable called "Mark" with 3 levels "A", "B", "C" I want to convert it to numerical value for use in linear regression. When I use as.numeric(Mark), it recodes in increasing alphabetical order A=1, B=2, C=3 But what I want is…
btiger
  • 35
  • 5
0
votes
3 answers

Recoding 150+ categorical variables in R

I have a files with a bunch of cities (so far, 183) and none of them have counties mapped to them, which is something I need. For re-coding categorical variables I usually use plyr's rename() function, but I don't want to write a messy nasty piece…
HFBrowning
  • 2,196
  • 3
  • 23
  • 42
0
votes
0 answers

Recoding categorical variables based on multiple 'or' conditions

I want to recode a variable called 'booktitle', based on the presence or absence of certain strings. If the field is blank or contains specific 'negative' words, I want to code my new variable "No". If none of the negative words are present, I want…
user3614783
  • 821
  • 6
  • 12
  • 20
0
votes
1 answer

Conditionally Revalue a Factor in R

This answer may very well be obvious (I hope it is), but I kept only finding convoluted solutions. What I'd like to do is conditionally revalue a factor based on the levels of another factor. Here's an example using the mtcars…
statsRus
  • 573
  • 3
  • 13
0
votes
1 answer

SAS creating a new variable from multiple variables

I'm pretty embarrassed to be asking this because it seems simple but I can't figure it out. I'm trying to create a new variable based on multiple if-then statements. For example: if question1=1 then newvar=1; if question2=1 then newvar=2; if…
0
votes
1 answer

R: Partial Recode of Variable by Merging Values from Another Dataset

I'm actually not even quite sure how to ask this question, so please bear with me. I've noticed that there is an error in the dataset I'm working with, the ANES Cumulative File. For one of the years in the dataset (2004), the values for one…
-1
votes
0 answers

How to recode combined ethnicity variables into single ones

I ran this code to get the breakdown of ethnicities in my sample: dataset %>% group_by(ethnicity) %>% summarise(percent = 100 * n()/nrow(datset)) However, because subjects were able to select multiple ethnicity categories on their…
-1
votes
1 answer

Recode string variable to numeric variable

I have a variable in Stata which consists of letters such as A, B, AB, AC, etc. I want to change to numeric, with values numbers instead of letters, such as 1 instead of A. I tried to encode the variable and then recode but it does not work. I also…
-1
votes
2 answers

How to convert a numeric variable that counts the number of months since a certain point into a variable with an interpretable date (R)?

I have data in R that has a numeric variable that counts the number of months since Jan. 1960. Let’s say: months_since_1960 <- c(0, 1, 12, 13, 24, 25) How can I create a new date variable that will show me these dates in a valuable way? I'm hoping…
user21027866
  • 129
  • 5
-1
votes
1 answer

How do I apply an indicator to another indicator?

I have two indicators with open codes. One of them is an indicator produced by tradingview that counts the classic fixed price-based Renko bricks (or candles) and generates alarms. The other is an indicator that produces percentage-based Renko…
-1
votes
1 answer

Find all columns with null values for every record based ID field - Access VBA

Help Please, How can I show the result where all column values are null? For example, I have a table like this: (There are 51 columns/fields in this table), I want to check each record and if the records have complete null for the ID, then that…
-1
votes
3 answers

How do I recode multiple variables from string to numeric?

I am trying to recode multiple columns of data from string variables (e.g. "None of the time", "Some of the time", "Often"...) to numeric values (e.g. "None of the time" = 0). I have seen a number of different responses to similar questions but when…
-1
votes
2 answers

Recoding in R and making between group comparisons

I have a dataframe with a column that has "Yes", "No" and "Maybe" values. Here is a sample of how the dataframe looks like for context (not actual data I'm working with as that's more sensitive): State City Do you like the color…
JSON7555
  • 37
  • 3