Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

r issue, not sure what I'm doing wrong

  • 03-05-2017 7:10pm
    #1
    Registered Users, Registered Users 2 Posts: 752 ✭✭✭


    Bear with me with this one.

    I am using r to extract tweets using the twitter api and that works fine. I am saving my results to .csv using the write.csv2 funtion which is also fine.

    When i open the csv file, in some cases the tweet is spread over multiple rows. This is down to character returns (\n) being in the tweet text.

    I have tried using a str_replace_all but it doesn't achieve the desired results when saved to csv.

    here is a snippet of my code;
    tweets_listDB <- searchTwitter(searchString, n=750, lang = "en", resultType = 'recent')
    str_replace_all(tweets_listDB.text, "[\n]", " ")
    
    # each tweets_list element contains several attributes such as:
    tweets.df <- twListToDF(tweets_listDB)
    
    The error i am getting is 
    Error in stri_replace_all_regex(string, pattern, fix_replacement(replacement),  : 
      object 'tweets_listDB.text' not found
    

    I'm pretty new to r, and i'm sure this was working for me last night, any idea what i am doing wrong?

    By way of example, i would like to remove the '\n' from the following tweet
    ethicalpaul: Come on, @CitiBikeNYC, PLEASE get the Port Authority area figured out!!\n\nI want to #bikeNYC !! (And I'm paying to d&#226;&#8364;&#166; https://t.co/4jSbbrcRoq"
    

    my list can have multiple items, i want to remove any '\n' from all tweets in my list.


Advertisement