I have a big data set with columns Id, Vg, Device, Die, W ,L and others (not relevant to this question). I want to interpolate Vg at a given value of Id but this operation has to be performed on data grouped by column Device and Die.
My sample data looks like
Die Device Id Vg W L
1 Device1 1 0 10 1
1 Device1 1.2 0.1 10 1
1 Device1 1.3 0.2 10 1
1 Device2 1 0 10 2
1 Device2 1.2 0.1 10 2
1 Device2 1.3 0.2 10 2
1 Device3 1 0 10 3
1 Device3 1.2 0.1 10 3
1 Device3 1.3 0.2 10 3
Each die has 22 unique devices. There are 67 dies and 22 Device names on each die are the same. Therefore if I interpolate Vg for Id=1.25, I expect to get 22*67 values of Vg for Id=1.25.
Here is the code I am trying
data_tidy%>%
group_by(Die,Device)%>% #Die is numeric, Device is factor
mutate(Vt=approx(x=log10(Id),y=Vg,xout=log10(3e-8*W/L))$y)
This is similar to what is suggested here and I am copying the suggested code from the link below
df %>%
group_by(variable) %>%
arrange(variable, event.date) %>%
mutate(time=seq(1,n())) %>%
mutate(ip.value=approx(time,value,time)$y) %>%
select(-time)
However, when I execute my code above I get an error message saying
Error: impossible to replicate vector of size 18