Skip to content
Prev 370803 / 398498 Next

Fill in empty spaces modified

Hi Ek,
As I may have mentioned previously, if you don't mind stepping through
the data frame row by row you can do it like this:

eedf<-read.table(text="nam,val
mandy,1
,2
John,3
,4
,5
,6
Zara,7
,8",sep=",",header=TRUE,stringsAsFactors=FALSE)
for(row in 1:nrow(eedf))
 if(eedf$nam[row] == "")
  eedf$nam[row]<-eedf$nam[row-1]

Jim
On Thu, Aug 10, 2017 at 7:20 AM, Ek Esawi <esawiek at gmail.com> wrote: