I need to replace every id with unique values in an ascending order.
Data
df = DataFrame(id=[1,1,1,3,3,3,4,4,4,7,7,7],
time=[0,1,2,0,1,2,0,1,2,0,1,2],
conc=[missing,100,70,missing,60,40, missing,90,80, missing,99,70])
Output
df1 = DataFrame(id=[1,1,1,2,2,2,3,3,3,4,4,4],
time=[0,1,2,0,1,2,0,1,2,0,1,2],
conc=[missing,100,70,missing,60,40, missing,90,80, missing,99,70])
I tried using this loop but when I try to weave the document this loop fails.
f = 0
df.id = 0
for b = 1:nrow(df)
if df.time[b] == 0
f = f + 1
df.id[b] = f
else
df.id[b] = f
end
end