2

I'm a programming and R rookie and I am strugling with the following issue. I have researched a lot but couldn't find an answer.

1) I am using twitteR to monitor some hashtags.

2)I have downloaded the hashtag I needed and then loaded it into a dataframe wich was exactly what I needed. OK.

tws <- searchTwitter(searchString = ("lula"),
                   n=1000,since="2017-07-03",retryOnRateLimit = 180) 

df <- do.call("rbind", lapply(tws, as.data.frame)) #make dataframe

print

Even when I ask for the first results of the column everything seems normal.

 [1] "RT @o_antagonista: 2018 sem Lula &gt; http/t.co/bedmpbwTnK http/t.co/yquxN7YdRN"                                                                                                                                                   
 [2] "RT @leoguime: Lula preso por 9 anos:\né réu primário: -3 \né idoso: -3\ntem bons antecedentes: -3\ntem doença grave: -4\n\nLula presidente +4 anos"                                                                                      
 [3] "@ChefPaImirinho @Mary_Mayah @Barella_SFC @alessandrosimas @AliceElenDutra3 @AriSirius @VazaTemer @maulroou… httpco/F1xl5WhZQ2"                                                                                                     
 [4] "Se eu fosse o Lula já estaria me batendo todo."                                                                                                                                                                                          
 [5] "RT @czmartins: No caso da sentença dada contra Lula não houve qualquer rastreamento de valores. Certa de que jamais existiu, a defesa fez o…"                                                                                            
 [6] "RT @AnaVilarino1: BBC diz que \"condenação de Lula visa disputa eleitoral de 2018\". \n\nSó brasileiro cheio de ódio pelo PT acredita neste jui…"                                                                                        
 [7] "RT @HunterGhostri: Olha, Lula, em geral é assim que funcionam os TCCs htt.co/dXDTimc9sM"                                                                                                                                           
 [8] "RT @blogdojefferson: Lula institucionalizou a corrupção, fez da distribuição de propinas uma política de Estado. Está pagando o preço de su…"                                                                                            
 [9] "RT @egocarioca: O Lula tem 9 dedos e meio? htcFFmbGfwgN2"                                                                                                                                                                                      

 [10] "RT @minc_rj: Sem Republica: Impeachment sem crime. Temer presidente sem voto. Aécio solto sem pleno STF. Maia cotado sem voto. Lula condena…"   

3) However, when I export this data frame into a csv file and try to impor into Excel some issues occur.

#write to csv file (or your RODBC code)
write.table(df, file = "testlula.csv", sep = ";", col.names =TRUE, row.names =TRUE,eol = "\r\n",
        qmethod = "double")

4) Some cells in the first column with text is splitted on the csv file into two or more rows depending on how the tweet is written.

Excel print

5) As I am dealing with a big dataframe I can't do this manually

It seems to be something really easy to solve but I couldn't find similar topics on the web, so if someone could help I apreciate that.

Spacedman
  • 92,590
  • 12
  • 140
  • 224

0 Answers0