I'm pretty new to loops in R/in general and couldn't find an answer elsewhere.
I am using a nested loop to paste values of two vectors into a hyperlink. While I would like to only have three output strings, I am receiving nine strings in total. Maybe this is really easy, but any input is highly appreciated.
**Example:**
start <- c("Value1", "Value2", "Value3")
end <- c("Value1.1", "Value2.1", "Value3.1")
summary <- c()
for (i in start) {
for(j in end) {
summary[i] <- print(paste('This is a Hyperlink Text',
i, 'here it continues', j ,'here it ends'))
}
}
**Actual Output:**
[1] "This is a Hyperlink Text **Value1** here it continues **Value1.1** here it ends"
[1] "This is a Hyperlink Text **Value1** here it continues **Value2.1** here it ends"
[1] "This is a Hyperlink Text **Value1** here it continues **Value3.1** here it ends"
[1] "This is a Hyperlink Text **Value2** here it continues **Value1.1** here it ends"
[1] "This is a Hyperlink Text **Value2** here it continues **Value2.1** here it ends"
[1] "This is a Hyperlink Text **Value2** here it continues **Value3.1** here it ends"
[1] "This is a Hyperlink Text **Value3** here it continues **Value1.1** here it ends"
[1] "This is a Hyperlink Text **Value3** here it continues **Value2.1** here it ends"
[1] "This is a Hyperlink Text **Value3** here it continues **Value3.1** here it ends"
**Desired ouput:**
"This is a Hyperlink Text **Value1** here it continues **Value1.1** here it ends"
"This is a Hyperlink Text **Value1** here it continues **Value2.1** here it ends"
"This is a Hyperlink Text **Value1** here it continues **Value3.1** here it ends"