I want to write a for loop that "grabs" data from already existing data frames, and stores them in a vector. However, I cannot determine how to use the paste function to get R to access column ohm.2 row 37 in the dataframe.
Here is my best attempt:
for(i in 6:18){
vec = numeric(4)
for(n in 1:4){
path <- paste("dat_",i,"_",n,"$ohm.2[37]")
val <- path
vec[n] <- val
}
assign(paste0("dat_",i),vec)
}
In this attempt, I get vectors correctly named, but instead of storing the number in row 37 column ohm.2 for each dataframe, it just stores the text:
[1] "dat_ 10 _ 1 $ohm.2[37]" "dat_ 10 _ 2 $ohm.2[37]"
[3] "dat_ 10 _ 3 $ohm.2[37]" "dat_ 10 _ 4 $ohm.2[37]"