0
Whereas I have a dataframe called page
whose number of lines varies regularly, I wrote this code so that it fits the number of lines that my page$id
owns and wrote this while
so that he manages a "g_com[numero]"
for each of these lines.
meu page$id contém:
[1] "1793398447353793"
[2] "1792916894068615"
[3] "1792013524158952"
[4] "1791520780874893"
continua...
This is the script I’m running:
binds <- as.data.frame(page$id)
contador <- 1
while (contador <= length(page$id)) {
binds[contador] <- paste0 ("g_com", contador)
contador <- contador + 1
}
b <- binds [1,]
It is returning a table with 17 columns and a row in each:
> print(binds)
page$id V2 V3 V4 V5
1 g_com1, g_com2, g_com3, g_com4, g_com5,
However, I need to automatically group all these "g_com"
in a sentence, so that it is without a comma after the last element and can be presented in a single row, and not in columns, I need to run a rbind on them, so I need it to return something like
g_com1, g_com2, g_com3, ..., g_com17
If anyone can help me, I’d appreciate it.
As I mentioned in your previous question, it is very difficult to help you with such a general question. Try to put yourself in the place of those who are reading the question, who do not know
page
,page$id
and everything else. It’s complicated to test our solution proposals without a data set to apply it. See this list of answered questions about R and realize that the people who made them were objective, giving necessary information to those who were willing to help.– Marcus Nunes
@Marcus Nunes, I tried to improve the question and the description of the data. Got better? Thanks again for the tips!
– Falves