Rstudio-replacing NA with values in the adjacent column

I have a dada frame this is a small part:

namess[270:285,]     first_name   last_name 270          R       Horne 271          T           H 272          A      McEvoy 273   Aumoitte        <NA> 274      Johin        <NA> 275  Waydelick        <NA> 276   Vigneron        <NA> 277  Sautereau        <NA> 278      Johin        <NA> 279   Aumoitte        <NA> 280    Georges Taillandier 281    Fernand        Sanz 282       John        Lake 283      Louis     Bastien 284      Louis  Hildebrand 285    Daumain        <NA> 

I would like to replace every NA value in the column named last_name with the value in the column first_name. I saw a similar post in this is the link

Replace NA in column with value in adjacent column

I tried using what they suggeted

namess$last_name[$last_name)] <- as.character(namess$last_name[$last_name)]) 

It didn't change anything, both of the columns are character type so its not a problem of being a factor type variable


Category: r Time: 2016-07-29 Views: 0
Tags: replace

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.189 (s). 12 q(s)