Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8470411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:30:39+00:00 2026-06-10T16:30:39+00:00

I’m working on a data.frame with about 700 000 rows. It’s containing the ids

  • 0

I’m working on a data.frame with about 700 000 rows. It’s containing the ids of statusupdates and corresponding usernames from twitter. I just want to know how many different users are in there and how many times they’ve tweeted. So I thought this was a very simple task using tables. But know I noticed that I’m getting different results.

recently I did it converting the column to character like this

>freqs <- as.data.frame(table(as.character(w_dup$from_user))
>nrow(freqs)
[1] 239678

2 months ago I did it like that

>freqs <- as.data.frame(table(w_dup$from_user)
>nrow(freqs)
[1] 253594

I noticed that this way the data frame contains usernames with a Frequency 0. How can that be? If the username is in the dataset it must occur at least one time.

?table didn’t help me. Neither was I able to reproduce this issue on smaller datasets.

What I’m doing wrong. Or am I missunderstanding the use of tables?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:30:41+00:00Added an answer on June 10, 2026 at 4:30 pm

    The type of the column is the problem here and also keep in mind that levels of factors stay the same when subsetting the data frame:

    # Full data frame
    (df <- data.frame(x = letters[1:3], y = 1:3))
      x y
    1 a 1
    2 b 2
    3 c 3
    # Its structure - all three levels as it should be
    str(df)
    'data.frame':   3 obs. of  2 variables:
     $ x: Factor w/ 3 levels "a","b","c": 1 2 3
     $ y: int  1 2 3
    # A smaller data frame
    (newDf <- df[1:2, ])
      x y
    1 a 1
    2 b 2
    # But the same three levels
    str(newDf)
    'data.frame':   2 obs. of  2 variables:
     $ x: Factor w/ 3 levels "a","b","c": 1 2
     $ y: int  1 2
    

    so the first column contains factors. In this case:

    table(newDf$x)
    
    a b c 
    1 1 0 
    

    all the levels ("a","b","c") are taken into consideration. And here

    table(as.character(newDf$x))
    
    a b 
    1 1 
    

    they are not factors anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.