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

  • Home
  • SEARCH
  • 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 6842111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:03:33+00:00 2026-05-27T00:03:33+00:00

I’m having trouble doing simple functions on a data frame and am unsure whether

  • 0

I’m having trouble doing simple functions on a data frame and am unsure whether it’s the data type of the column, or bad data in the data frame.

I exported a SQL query into a CSV file, then loaded it into a data frame, then attached it.

df <-read.csv("~/Desktop/orders.csv")
Attach(df)

When I am done, and run str(df), here is what I get:

$ AccountID: Factor w/ 18093 levels "(819947 row(s) affected)",..: 10 97 167 207 207 299 299 309 352 573 ...
$ OrderID   : int  1874197767 1874197860 1874196789 1874206918 1874209100 1874207018 1874209111 1874233050 1874196791 1875081598 ...
$ OrderDate : Factor w/ 280 levels "","2010-09-24",..: 2 2 2 2 2 2 2 2 2 2 ...
$ NumofProducts  : int  16 6 4 6 10 4 2 4 6 40 ...
$ OrderTotal    : num  20.3 13.8 12.5 13.8 16.4 ...
$ SpecialOrder : int  1 1 1 1 1 1 1 1 1 1 ...   

Trying to run the following functions, here is what I get:

> length(OrderID)
[1] 0

> min(OrderTotal)
[1] NA

> min(OrderTotal, na.rm=TRUE)
[1] 5.00

> mean(NumofProducts)
[1] NA

> mean(NumofProducts, na.rm=TRUE)
[1] 3.462902

I have two questions related to this data frame:

  • Do I have the right data types for the columns? Nums versus integers versus decimals.
  • Is there a way to review the data set to find the rows that are driving the need to use na.rm=TRUE to make the function work? I’d like to know how many there are, etc.
  • 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-05-27T00:03:34+00:00Added an answer on May 27, 2026 at 12:03 am

    The difference between num and int is pretty irrelevant at this stage.

    See help(is.na) for starters on NA handling. Do things like:

    sum(is.na(foo))
    

    to see how many foo’s are NA values. Then things like:

    df[is.na(df$foo),]
    

    to see the rows of df where foo is NA.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to construct a data frame in an Rcpp function, but when I
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

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.