Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread PIKAL Petr
ek > Sent: Sunday, June 25, 2017 5:26 PM > To: Boris Steipe > Cc: r-help@r-project.org > Subject: Re: [R] Fill in empty cell in data.frame from previous value > > Excellent Boris, thx – this helps > > From: Boris Steipe > Sent: June 25, 2017 11:23 AM > To: Christophe Elek &

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Jim Lemon
t; > Cheers > > > > *From: *Jim Lemon > *Sent: *June 25, 2017 3:11 AM > *To: *Christophe Elek > *Cc: *r-help@r-project.org > *Subject: *Re: [R] Fill in empty cell in data.frame from previous value > > > > Hi Chris, > > You may know about the *apply family of funct

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Christophe Elek
Excellent Boris, thx – this helps From: Boris Steipe Sent: June 25, 2017 11:23 AM To: Christophe Elek Cc: r-help@r-project.org Subject: Re: [R] Fill in empty cell in data.frame from previous value Run it through a loop. I assume the cell contents is NA (Not Available). Test for it with is.na

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Christophe Elek
Perfect Jim, that Is exactly what I needed – let me check that ... Cheers From: Jim Lemon Sent: June 25, 2017 3:11 AM To: Christophe Elek Cc: r-help@r-project.org Subject: Re: [R] Fill in empty cell in data.frame from previous value Hi Chris, You may know about the *apply family of functions

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Göran Broström
> 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 John2 4 2 I want to read the r

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Boris Steipe
Run it through a loop. I assume the cell contents is NA (Not Available). Test for it with is.na(). Whenever that returns TRUE, replace the NA value with the value from the previous row. Cheers, B. > On Jun 24, 2017, at 1:49 PM, Christophe Elek > wrote: > > Hello Total newbie here... I hope

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Bert Gunter
You need to go through some tutorials, not expect us to tutor you here. That is not the purpose of this list (although we do some of this indirectly of course). There are many good online tutorials -- search or see here: https://www.rstudio.com/online-learning/#R . Or start by going through the I

Re: [R] Fill in empty cell in data.frame from previous value

2017-06-25 Thread Jim Lemon
Hi Chris, You may know about the *apply family of functions. These slice various data structures and "apply" a specified function to each slice, usually returning a list of return values. As far as I am aware, you can't access adjacent rows unless you reformat the data structure. There is a way to

[R] Fill in empty cell in data.frame from previous value

2017-06-24 Thread Christophe Elek
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 John2 4 2 I want to read the row number 2, but I want the first column to be “Mandy” and not null print (fra