for loop - Iterating a function based on data.frame cell values -
i have been beating head against problem , have made little progress.
i have data.frame 4 columns , 8 rows. table shows column names not row names.
5 10 20 40 1 1 2 4 1 2 4 8 2 3 6 12 2 4 8 16 3 5 10 20 3 6 12 24 4 7 14 40 4 8 16 40
i need calculate function, y <- (c-(i-1))/((k/2)*(1+k)), • c number in data.frame cell • k value of column name • iteration number loop through function c times.
for example, cell [8,1], need iterate function 4 times, = 1:4.
i new r, , each piece of has been challenge, iteration portion has me stumped. how can use cell value data.frame control iterations such through loop?
i have set nested loops move through data.frame column, row, iterate function based on cell value, latter loop not working.
perhaps there more simple approach, apply , dplyr approaches have not worked me either.
thanks much.
Comments
Post a Comment