Oh thanks! It worked now, however, the variable wasn't added to the dataframe for some reason
> mutate1 %>%
+ group_by(PUF_FACILITY_ID) %>%
+ distinct(Z_TXT) %>%
+ spread(Z_TXT, Z_TXT, sep="_") %>%
+ mutate_all(~ifelse(is.na(.),0,1)) %>%
+ transmute(Avail_TXT_F=paste0(Z_TXT_1, Z_TXT_2,Z_TXT_3)) %>%
+ right_join(mutate1, by="PUF_FACILITY_ID")
`mutate_all()` ignored the following grouping variables:
Column `PUF_FACILITY_ID`
Use `mutate_at(df, vars(-group_cols()), myoperation)` to silence the message.
# A tibble: 13,086 x 221
# Groups: PUF_FACILITY_ID [339]
PUF_FACILITY_ID Avail_TXT_F AGE ANALYTIC_STAGE_~ BEHAVIOR CDCC_TOTAL CLASS_OF_CASE CROWFLY CS_EXTENSION CS_METS_AT_DX
<fct> <chr> <int> <int> <int> <int> <int> <fct> <int> <int>
1 ULWONRBEXR 111 52 1 3 0 20 194.0 220 0
2 LVMXOQOZBB 101 45 2 3 0 10 21.0 440 0
3 OVRRTAMUER 101 62 9 3 0 20 55.2 999 0
4 RGHKVWHTVZ 101 55 1 3 0 10 20.6 300 0
5 RGHKVWHTVZ 101 49 2 3 0 20 80.6 440 0
6 ULWONRBEXR 111 55 2 3 0 20 515.0 420 0
7 LVMXOQOZBB 101 69 3 3 0 14 22.6 405 0
8 CYMEVTQFDL 101 68 2 3 0 10 94.4 440 0
9 HAIFFICRAQ 101 65 2 3 0 12 30.7 255 0
10 TNKUIMHWRA 101 72 1 3 0 22 43.2 205 0
# ... with 13,076 more rows, and 211 more variables: CS_METS_DX_BONE <int>, CS_METS_DX_BRAIN <int>, CS_METS_DX_LIVER <int>,
# CS_METS_DX_LUNG <int>, CS_METS_EVAL <int>, CS_SITESPECIFIC_FACTOR_1 <int>, CS_SITESPECIFIC_FACTOR_10 <fct>,
# CS_SITESPECIFIC_FACTOR_11 <fct>, CS_SITESPECIFIC_FACTOR_12 <fct>, CS_SITESPECIFIC_FACTOR_13 <fct>,
# CS_SITESPECIFIC_FACTOR_14 <fct>, CS_SITESPECIFIC_FACTOR_15 <fct>, CS_SITESPECIFIC_FACTOR_16 <fct>,
# CS_SITESPECIFIC_FACTOR_17 <fct>, CS_SITESPECIFIC_FACTOR_18 <fct>, CS_SITESPECIFIC_FACTOR_19 <fct>,
# CS_SITESPECIFIC_FACTOR_2 <int>, CS_SITESPECIFIC_FACTOR_20 <fct>, CS_SITESPECIFIC_FACTOR_21 <fct>,
# CS_SITESPECIFIC_FACTOR_22 <fct>, CS_SITESPECIFIC_FACTOR_23 <fct>, CS_SITESPECIFIC_FACTOR_24 <fct>,
# CS_SITESPECIFIC_FACTOR_25 <fct>, CS_SITESPECIFIC_FACTOR_3 <int>, CS_SITESPECIFIC_FACTOR_4 <int>,
# CS_SITESPECIFIC_FACTOR_5 <int>, CS_SITESPECIFIC_FACTOR_6 <int>, CS_SITESPECIFIC_FACTOR_7 <fct>,
# CS_SITESPECIFIC_FACTOR_8 <fct>, CS_SITESPECIFIC_FACTOR_9 <fct>, CS_TUMOR_SIZEEXT_EVAL <int>, CS_VERSION_LATEST <fct>,
# DIAGNOSTIC_CONFIRMATION <int>, DX_CHEMO_STARTED_DAYS <fct>, DX_DEFSURG_STARTED_DAYS <fct>, DX_HORMONE_STARTED_DAYS <fct>,
# DX_IMMUNO_STARTED_DAYS <fct>, DX_LASTCONTACT_DEATH_MONTHS <fct>, DX_OTHER_STARTED_DAYS <fct>, DX_RAD_STARTED_DAYS <fct>,
# DX_RX_STARTED_DAYS <fct>, DX_STAGING_PROC_DAYS <fct>, DX_SURG_STARTED_DAYS <fct>, DX_SYSTEMIC_STARTED_DAYS <fct>,
# Dist_Mets <int>, FACILITY_LOCATION_CD <fct>, FACILITY_TYPE_CD <fct>, GRADE <int>, HISTOLOGY <int>, INSURANCE_STATUS <int>,
# LATERALITY <int>, LYMPH_VASCULAR_INVASION <int>, MED_INC_QUAR_00 <fct>, MED_INC_QUAR_12 <fct>, M_ACADMC <int>,
# M_DIST_60 <int>, M_EOE_C_T_6 <int>, M_EOE_C_T_7 <int>, M_EOE_Max <int>, M_HS <int>, M_INSURANCE <int>, M_MED_INC <int>,
# M_RACE_W <int>, M_RURAL_250 <int>, M_SZ_C_T_6 <int>, NO_HSD_QUAR_00 <fct>, NO_HSD_QUAR_12 <fct>, O_SZ_COMS_OLD <int>,
# O_SZ_COMS_new <int>, O_SZ_C_T_6 <int>, O_SZ_C_T_7 <int>, O_SZ_MAX_new_stage <int>, O_SZ_MAX_old_stage <int>,
# O_SZ_P_T_6 <int>, O_SZ_P_T_7 <int>, PALLIATIVE_CARE <int>, PALLIATIVE_CARE_HOSP <int>, PRIMARY_SITE <fct>,
# PUF_30_DAY_MORT_CD <fct>, PUF_90_DAY_MORT_CD <fct>, PUF_CASE_ID <fct>, PUF_MULT_SOURCE <int>, PUF_VITAL_STATUS <fct>,
# RACE <int>, RAD_BOOST_DOSE_CGY <int>, RAD_BOOST_RX_MODALITY <int>, RAD_ELAPSED_RX_DAYS <int>, RAD_LOCATION_OF_RX <int>,
# RAD_NUM_TREAT_VOL <fct>, RAD_REGIONAL_DOSE_CGY <int>, RAD_REGIONAL_RX_MODALITY <int>, RAD_TREAT_VOL <int>,
# READM_HOSP_30_DAYS <int>, REASON_FOR_NO_RADIATION <int>, REASON_FOR_NO_SURGERY <int>, REFERENCE_DATE_FLAG <int>,
# REGIONAL_NODES_EXAMINED <int>, REGIONAL_NODES_POSITIVE <int>, RX_HOSP_CHEMO <int>, RX_HOSP_DXSTG_PROC <int>, ...
I tried to run the following operation, and it gave me an error message
with(mutate1, table(Z_TXT, Z_SZ_class, Avail_TXT_F))
Error in table(Z_TXT, Z_SZ_class, Avail_TXT_F) :
object 'Avail_TXT_F' not found