I'm new to R programming. I read a csv file. I want to replace certain 'NA' values in a column with values present in the same row from some other column. So I have written a 'if statement' shown below, but instead of replacing only the 'NA' values, all the values in that column are getting replaced by the values present in another column. What possibly is going wrong here? Any help is welcomed. The data looks like
Group Skill
A1 ABC
A1 ABC
A1 ABC
A1 ABC
A1
A1
A1
A1
The desired result is
Group Skill
A1 ABC
A1 ABC
A1 ABC
A1 ABC
A1 A1
A1 A1
A1 A1
A1 A1
The result I'm getting now
Group Skill
A1 A1
A1 A1
A1 A1
A1 A1
A1 A1
A1 A1
A1 A1
A1 A1
The if statement I wrote is
df<- read.csv("Data.csv",header=T,na.strings=c(""))
if (is.na(df$Skill)) {
df$Skill <- df$Group
}