Message-ID: <5d06feb0-d485-eae3-a48d-8520e2083073@umu.se>
Date: 2017-06-25T16:44:21Z
From: Göran Broström
Subject: Fill in empty cell in data.frame from previous value
In-Reply-To: <594ea639.0e56240a.7719d.b58e@mx.google.com>
> library(tidyr)
> ?fill
G?ran
On 2017-06-24 19:49, Christophe Elek wrote:
> Hello Total newbie here... I hope I read the guide properly
>
> I have the following data.frame (I read it from a CSV file I cannot change)
>
> names val
> 1 Mandy 1
> 2 2
> 3 John 2
> 4 2
>
> I want to read the row number 2, but I want the first column to be ?Mandy? and not null
>
> print (frame[2,])
> 2 Mandy 2
>
> I can manipulate the data.frame once loaded
> How can I fill all cell in column ?names? with the previous value ?
> Or is there a function that will get me the row and fill the ?names? column ?
>
> NOTA BENE: I do not want the answer, I want to find it myself but I need guidance
> If there is a function, tell me the library and I will search
> If this is an algorithm, tell me generally how you would do and let me scratch my head first ?
>
> Thanks Chris
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>