The simple data is:
df <- structure(list(value1 = c(-2.42288252774916), value2 = c(-1.99988470731567), value3 = c(-1.57678745345913)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -1L))
I am trying to build a code that could produce the results as this:
NEW.df <- structure(list(value1 = c(-2.42288252774916), value2 = c(-1.99988470731567), value3 = c(-1.57678745345913), NEWvalue1 = c(-2.98), NEWvalue2 = c(-1.99988470731567), NEWvalue3 = c(-1.02)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -1L))
“NEWvalue1” was created by extending “-2.42288252774916” toward ‘-2.98’, ‘NEWvalue2’ didn’t change and ‘NEWvalue3’ was created by extending ‘-1.57678745345913’ toward ‘-1.02’.
Guys, is there a code that can recognize this extensions automatically, and produce “NEW.df” as I specified it to be?
Hope the question is not confusing.