If I have this dataframe:
df <- data.frame(col1 = c(NA,NA,NA,"Doggy",NA,NA,"Pound"),col2 = c(1:7))
Let's say I want to check if there is not a NA-value in col1 and add the corresponding number from the other column if that is true, I'd write this:
for (i in 1:nrow(df)){
if (is.na(df[i,1]) == FALSE){
#add the df[i,2] number to the df[i,1] string.
}
How should I go about concatenating the string with the numeric?