In Matlab, creating an empty vector that will later be filled looks like this:
v2 = []
How do I do the same in r? I will use this empty vector to fill it when a condition is met. I don't know its future length. For reference, here is my code in r.
dfx <- read.csv("AllDataNewConversions.csv",header = TRUE, sep =",",check.names=FALSE)
df <- na.omit(dfx) # removes NA
v2 <- {}
new_val <- {}
for (i in 1:length(df)){
if (df$Texture[i] == 'Silt Loam'){
new_val <- df$`pH 1:1`[i]}
v2[i] <- new_val
}