A loop works iteratively, so in your code in the last iteration you overwrite the previous value in the vector asdf and assign it the new value of 28.
If you want to store both values in the vector, you first initialize an empty vector. For each iteration then, append the value of interest to the already existing vector. As detailed in the code below:
asdf <- c() #initialize empty vector
for (i in c(4,28)){
asdf <- c(asdf, i)
}
A loop works iteratively, so in your code in the last iteration you overwrite the previous value in the vector asdf and assign it the new value of 28.
If you want to store both values in the vector, you first initialize an empty vector. For each iteration then, append the value of interest to the already existing vector. As detailed in the code below:
Output: