Displaying 4 results from an estimated 4 matches for "sploc".
Did you mean:
sloc
2020 Oct 27
2
Creating unique code
...I need to create a 'couple identifier', which gives a unique code for every couple/triple/... in a household. So, I can identify couples. To do this, I should use 4 variables:
* SERIAL = a unique numeric code for each household
* PERNUM = a unique numeric code for each person
* SPLOC = the numeric code of the spouse in the household, it is equal to the PERNUM code of the spouse
* SPRULE = rules for linking a spouse, numeric code from 00 to 06
To create the couple identifier, I need these conditions:
* SERIAL needs to be equal for these persons in the couples
* SP...
2020 Oct 30
3
Error: variable not found
...ouple_id) : object 'couple_id' not found. What can I do about this?
R-script:
attach(ipumsi_00008_dta)
library(tinytex)
library(dplyr)
library(ggplot2)
library(tidyr)
library(knitr)
library(forcats)
library(mice)
library(pander)
library(ggcorrplot)
library(lubridate)
# true/false code when sploc is greater than zero and sprule is equal to 1 or 2
ipumsi_00008_dta <- mutate(ipumsi_00008_dta, rule_union = sploc>0 & (sprule==1 | sprule==2))
## creating numeric code for rule_union & rule_unionn: 1 when sploc is greater than zero and sprule is equal to 1 or 2, 0 if not.
## This is...
2020 Oct 29
0
Creating unique code
...tner(s). The household number can accommodate up
to three relationship partners as long as there are a maximum of 9 people
per household. Given these constraints, I think this may do what you want:
ipumsi_00008_dta<-
read.table(
text="country year sample serial hhwt pernum perwt resident sploc sprule
204 2013 204201301 4000 10 1 10 1 5 2
204 2013 204201301 4000 10 2 10 1 0 2
204 2013 204201301 4000 10 3 10 1 0 2
204 2013 204201301 4000 10 4 10 1 0 2
204 2013 204201301 4000 10 5 10 1 1 2
204 2013 204201301 4000 10 6 10 1 1 2
204 2013 204201301 4000 10 7 10 1 0 2
204 2013 204201301 4000 10...
2020 Oct 30
0
Error: variable not found
...before, you can append the partner codes to the
household code. I apologize, but I don't know how to use the
dplyr/tidyr/... stuff so this is written in straight R code using logic
statements.
ipumsi_00008_dta<-
read.table(
text="country year sample serial hhwt pernum perwt resident sploc sprule
204 2013 204201301 4000 10 1 10 1 5 2
204 2013 204201301 4000 10 2 10 1 0 2
204 2013 204201301 4000 10 3 10 1 0 2
204 2013 204201301 4000 10 4 10 1 0 2
204 2013 204201301 4000 10 5 10 1 1 2
204 2013 204201301 4000 10 6 10 1 1 2
204 2013 204201301 4000 10 7 10 1 0 2
204 2013 204201301 4000 10...