I have 3 dataframes with different number of rows available on this link
https://drive.google.com/drive/folders/1vPno03j3YtcAARgKssibAcUX177GmF_r?usp=sharing
What I want is the like this Untitled spreadsheet - Google Sheets
I want those rows in conf11_pos
where particlei
and particlej
of conf11_particles are present and paste their values in conf11_particles
columns. Process should be repititive so I have used a for loop.
What I have tried till now.
shear2_ft <- read_csv("~/Documents/For_Shah/3D/ShearTest-2/2-ShearTest_DEM/sheartest-2_ft_fn.csv") %>% na.omit() %>% filter(type ==0) %>% select(-c(isub,jsub))
spheres <- read_csv("~/Documents/For_Shah/3D/ShearTest-2/2-ShearTest_DEM/sheartest-2_spheres.csv") %>% na.omit() %>% select(-c(group)) %>% select(-c(shapeName))
conf_filing <- data.frame(conf=c("conf11","conf12"))
pos <- function(spheres,shear2_ft,conf_filing){
conf11_pos <- spheres %>% filter(V1 == c(conf_filing$conf[1])) %>% select(V1,cluster,position.x,position.y,position.z)
conf12_pos <- spheres %>% filter(V1 == c(conf_filing$conf[2])) %>% select(V1,cluster,position.x,position.y,position.z)
conf11_particles <- shear2_ft %>% filter(V1 == c(conf_filing$conf[1])) %>% select(1:11)
conf12_particles <- shear2_ft %>% filter(V1 == c(conf_filing$conf[2])) %>% select(1:11)
dx<- conf12_pos$position.x-conf11_pos$position.x
dy <- conf12_pos$position.y-conf11_pos$position.y
dz <- conf12_pos$position.z-conf11_pos$position.z
x <- cbind(conf11_pos$cluster,dx,dy,dz) %>% data.frame()
x <- x %>% arrange(V1)
for(i in seq(conf11_particles)){
if (conf11_particles[i,2]==conf11_pos$cluster[i]){
conf11_particles[i,4] <- paste(conf11_pos$position.x[i])
conf11_particles[i,5] <- paste(conf11_pos$position.y[i])
conf11_particles[i,6] <- paste(conf11_pos$position.z[i])
if (conf11_particles[i,3]==conf11_pos$cluster[i]){
conf11_particles[i,7] <- paste(conf11_pos$position.x[i])
conf11_particles[i,8] <- paste(conf11_pos$position.y[i])
conf11_particles[i,9] <- paste(conf11_pos$position.z[i])
}
}
}