Hey guys.
I have an assignment due tomorrow regarding Twitter API.
I have a data set which has different tweets and their information etc.
I'm trying to find out how many total of the tweets is a retweet.
There is a column header called "is_retweet" which has values either TRUE or FALSE.
I just want to write a simple piece of a code that adds up all of the TRUE values and returns an answer.
Would really appreciate some assistance.,
Regards.
Hi @babyspitz , welcome to RStudio Community.
Let me give you a hint. R internally represents the boolean values TRUE
and FALSE
as 1 and 0 respectively. So by using the right arithmetic operator, you should be able to get your answer.
babyspitz:
tomorrow
babyspitz:
tweets
appreciate the hint.
still wouldn't know how to do it even if they were all as 1's.
have been searching google but can't find what I need.
Rather than searching Google, try and think through the problem.
You have a column is_retweet
in your data frame that is represented as 1s and 0s. What happens if you total the values across the entire column?
Hello babyspitz, please familiarise yourself with FAQ: Homework Policy for the future.
In the short term, please read and try the examples here:
Sum function in R - sum(), is used to calculate the sum of vector elements. Syntax for R sum function : sum(x, na.rm = FALSE, ...) x – numeric vector rm- ...
Est. reading time: 4 minutes
system
Closed
April 13, 2020, 10:49am
6
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.