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 7886039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:13:18+00:00 2026-06-03T05:13:18+00:00

I am getting an error when I trying to use the str function in

  • 0

I am getting an error when I trying to use the str function in R.
Here is the data:

> dput(data1)
data1<- structure(list(Year = 1990:2010, Counts = c(1401L, 1290L, 1168L,1260L, 1252L, 1381L, 1330L, 1275L, 1235L, 1248L, 1237L, 1206L, 1175L, 1172L, 1055L, 1030L, 1002L, 987L, 915L, 806L, 868L)), .Names = c("Year", "Counts"), class = "data.frame", row.names = c(NA, -21L))

I do not know why R is giving me the following error with str while class function is clearly saying that data1 is a data.frame.

> class(data1)
[1] "data.frame"
> str(data1)
Error in str(data1) : 
  unable to find a non-generic version of function "str"

I am using R version 2.15.0 (2012-03-30) for Windows.

Any help will be greatly appreciated.

EDIT:
With a clean R session it worked. But why does this kind of problem occur? Is it possible to know this?

  • 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-03T05:13:19+00:00Added an answer on June 3, 2026 at 5:13 am

    Ok, I’ll bite.

    Why does this kind of problem occur?

    Object (i.e. function, variable) masking is one of the most common sources of errors or bugs in R code. Why can this happen?

    Well, there’s a list of reserved words in R’s parser located at ?Reserved:

    The reserved words in R’s parser are:

    if else repeat while function for in next break

    TRUE FALSE NULL Inf NaN NA NA_integer_ NA_real_ NA_complex_
    NA_character_

    ... and ..1, ..2 etc, which are used to refer to arguments passed down
    from an enclosing function.

    That means you, the user, can’t reassign the value of these names. But pretty much anything else (assuming its syntactically valid) is in bounds.

    For example, data is actually a function in the utils package, which is why people generally recommend not naming your data frame data. You will have masked the function data and any code that depends on it will choke.

    Honestly, I commonly use df for a data frame, even though that is a function that computes the distribution function for an F distribution. (I don’t need the F distribution functions much. But I still shouldn’t do that.)

    A particularly devious example of this issue is the common joke among R users about setting:

    T <- FALSE
    F <- TRUE
    

    Many people are lazy and use T and F for TRUE and FALSE, and now we see exactly why this is a really, really bad idea. (It’s pretty likely that someone is going to assign some other value to T or F.)

    Indeed, anytime you load a package you’re likely to see a bunch of warnings, where R is telling you that by loading that package you’ve just masked a bunch of functions because they have common names.

    How can I know that this has happened?

    This is much easier. As Ben said in the comments, you identify this sort of thing using conflicts().

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

Sidebar

Related Questions

I'm trying to use function with foreach but getting error. Here is my code:
I am trying to use a function pointer and I am getting this error:
I'm getting an error while trying to use the action_mailer_tls plugin to communicate with
Im trying to use Date Formatters (NSDateFormatter), but I keep getting this error: Program
I'm trying to use defmacro in ClojureScript, but I'm getting a console error: TypeError:
I'm getting a Can't use an undefined value as a HASH reference error trying
I'm getting a 'module object has no attribute ... error when trying to use
I am getting a weird error when trying to use a Java map in
I'm getting the following Error when trying to use OOP (for the first time),
I am getting the following error when trying to use the WCF Test Client

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.