I have a dateset with student names collected in first round. There are few names which were collected in second survey. I have merged the first name and second names. But the problem is with the blank columns that appear as NA NA. I have to coalesce the new merged names and make it appear in the column "child_name" in the place of "91". So I have two steps:
1.Merge the first and second names.
2. The merged names must appear in the column "child_name" in place of "91".
library(tidyverse)
library(janitor)
#>
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#>
#> chisq.test, fisher.test
data<-tibble::tribble(
~child_name, ~first_name, ~last_name,
"Banashri M Madanabhavi", NA, NA,
"91", "Chaitra", "Bajantri",
"91", "Manoj", "Koppad",
"Gangamma Sangoli", NA, NA,
"91", "soujanya", "Kampli",
"91", "Praveen", "Badiger",
"Shreedevi Ningappa Bijalli", NA, NA,
"91", "Preethi", "Ashok",
"91", "Bhavya", "Kolar"
)
(data<-data %>%
mutate(merged_name=paste(first_name,last_name,sep=" ")))
#> # A tibble: 9 x 4
#> child_name first_name last_name merged_name
#> <chr> <chr> <chr> <chr>
#> 1 Banashri M Madanabhavi <NA> <NA> NA NA
#> 2 91 Chaitra Bajantri Chaitra Bajantri
#> 3 91 Manoj Koppad Manoj Koppad
#> 4 Gangamma Sangoli <NA> <NA> NA NA
#> 5 91 soujanya Kampli soujanya Kampli
#> 6 91 Praveen Badiger Praveen Badiger
#> 7 Shreedevi Ningappa Bijalli <NA> <NA> NA NA
#> 8 91 Preethi Ashok Preethi Ashok
#> 9 91 Bhavya Kolar Bhavya Kolar
Created on 2022-05-02 by the reprex package (v2.0.1)