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
1 answer

How to recode a character Outcome variable in a dichtomous Outcome (0,1) in R

I have a data set with cancer patients and different Outcomes TypeofOutcome DateStageIV NA 01.04.2014 Died from melanoma 01.06.2011 Died from melanoma 01.11.2013 I want a new column called "Outcome" with all patients…
Feli
  • 11
  • 1
  • 5
0
votes
0 answers

wrong scaling on graph due to structure change recoding values

Does anyone have any idea why when I recode the data using the psych package my structure changes? How can I keep it the same? (I have tried quite a few things I omitted so the output was cleaner) I believe this change is responsible for the second…
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
0
votes
2 answers

R: Sum variable values conditional on value of other variable

I have a data frame which looks like this: year country inhabitants 1 1 A 15 2 2 A 10 3 3 A 24 4 1 B 76 5 2 B 69 6 3 B 58 7 1 C …
Theresa
  • 3
  • 2
0
votes
1 answer

recode into same variable

I have a big set of survey data containing 110 variables. Some answers range from 1 to 5, where 1 is best and 5 is worst. For analysis I would like to invert that, where 5=1, 4=2, 3=3, 2=4, and 1=5. If I put it into an object it works: x_inv <-…
Frieda
  • 3
  • 2
0
votes
0 answers

recode multiple variables with missing levels

I have a data frame with many columns of integer variables, each representing a particular question on a food frequency questionnaire. I want to recode these columns to numerical variables representing the number of servings of that food eaten per…
Alex P.
  • 1
  • 1
0
votes
3 answers

How to recode variables in R

I am trying to recode variables in an R dataframe. Example - variable X from my dataset contains 1's and 0's. I want to create another variables Y which recodes 1's & 0's from X into Yes & No respectively. I tried this to create the recoded Y…
kyg
  • 105
  • 5
0
votes
0 answers

How to recode numeric values into NA values across vectors in a data frame

I have a data frame which contains several numeric variables. I have written a sorting algorithm that sorts the rows by comparing the values in the columns containing the numeric values I'm interested in. The values are YYYYMMDD in numeric format.…
WykoW
  • 181
  • 5
0
votes
1 answer

Track panel identifier name changes over time

I have a panel identifier that is a firm's name stored as an alphanumeric code and I would like to track name changes throughout the panel. For example, firm A is renamed to B on on May 25, 2001. Then firm B is renamed to C on May 25, 2003. Then…
Richard Herron
  • 9,760
  • 12
  • 69
  • 116
0
votes
3 answers

Recode continuous into continuous variables (without split function) in R

I am trying to recode a set of data that cannot be easily done with the split function or ifelse function. How would I recode the following data? 1 --> 1 2 --> 0 3 --> 0 4 --> 1 5 --> 1 7 --> 0 8 --> 1 Thank you for your time!
Tawk_Tomahawk
  • 139
  • 2
  • 8
0
votes
1 answer

How to collapse/recode a variable in R

I am only in an introductory R class, so this is probably quite basic. I am using the Outlook on Life dataset and am interested in Income. Respondents had to choose one of the following 19 choices: Less than $5,000 $5,000 to $7,499 $7,500…
Katherine
  • 51
  • 1
  • 3
0
votes
0 answers

recoding multiple variables in the same way

I am looking for the shortest way to recode many variables in the same way. For example I have data frame where columns a,b,c are names of items of survey and rows are observations. d <- data.frame(a=c(1,2,3), b=c(1,3,2), c=c(1,2,1)) I want to…
Tomasz Wojtas
  • 756
  • 2
  • 6
  • 12
0
votes
2 answers

Recoding dataframe by transformation table

I have a dataframe that contains 3 columns. One of the columns (items) includes long strings (some include special characters such as semicolon ; for simplicity it is written here as Tx) that might repeat. I would like to find all the unique values…
Avi
  • 2,247
  • 4
  • 30
  • 52
0
votes
3 answers

convert only some factors into a different factor

I'm trying to build a factor column that relates to two other factor columns with completely different factor levels. Here's example…
slap-a-da-bias
  • 376
  • 1
  • 6
  • 25
0
votes
1 answer

r recode a string variable based on a condition

I know this could be simple, but I can't find the way to solve it. I want to recode a string variable (into the same variable), based on a condition of another variable, but I'm getting an error. A working example: …
Oscar Benitez
  • 255
  • 3
  • 13
0
votes
1 answer

Recursively recode all project files excluding some directories and preserving permissions

How to recursively recode all project files excluding some directories and preserving permissions?
a1111exe
  • 641
  • 4
  • 18