I have the following vector:
v<-c(1,2,3,4,1,2,3,4,2)
which I want to "transform" into a 3x3 matrix:
matrix <- matrix(data=v,ncol=3)
which I then want to "flip" over (not transpose)
flip_matrix<-matrix[,3:1,drop=FALSE]
It's very easy to use the tidyverse pipe to chain all this but to cut down dependencies I would like to sort this out using base R. I could do it creating several objects and forget about the pipe, but I need to know how this would be done with the base pipe. So far, I had no luck with:
v<-c(1,2,3,4,1,2,3,4,2)
final_matrix <- matrix(data=v,ncol=3) |> .[,3:1.drop=FALSE]()
Which tells me the object "." was not found. I've tried other iterations with no luck... Thanks for your help!