I need to sample a dataframe by one column and then take the sampled values and the values beside the chosen one for further calculations.
For example, below is some code. Let's say I sample on the first column (unused) and it selects a value. I then want to output that value and one two columns over (carryover), and in the same row..
dat <- data.frame(cbind(rnorm(30,600,sd=100),rnorm(30,300,sd=50),rnorm(30,200,sd=50),rnorm(30,200,sd=200)))
colnames(dat) <- c("unused","deduct","carryover","used")
unused <- dat$unused
for (i in 1:10) {
unused[i] <-matrix(sample(unused,size=1,replace=TRUE))
}