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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:12:15+00:00 2026-06-15T00:12:15+00:00

R version 2.14.1 Platform: i386-apple-darwin9.8.0/i386 (32-bit) Objective: Use function dens() of library lessR to

  • 0

R version 2.14.1    Platform: i386-apple-darwin9.8.0/i386 (32-bit)

Objective:
Use function dens() of library lessR to plot a normal density curve and a general density curve superimposed over a histogram.

Problem:
While generating the data using e.g. rnorm() or rbinom() works well, running it on data generated by sample() returns this error:

Error in if (from == to) rep.int(from, length.out) else as.vector(c(from,  : 
  argument is of length zero

MWE:

library(lessR)
data <- data.frame(col=sample(20))
y <- data$col
dens(y)

Question:
What causes the problem and what do I have to do if I want to have a data frame with a single column, let us say, which would contain twenty rows of values generated by the sample() function and use them as an input for the dens()?

Update (2012-11-17):
I have updated R to version 2.15.2 and lessR to version 2.6 (both are the latest available).

Using the data provided by @Roland, the error is now:

Error in seq.default(x.min, x.max, length = 200) : 
  'from' must be of length 1 

I can understand why it does happen and allowing sample() to use a single value more than one leads to a correct result.

  • 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-15T00:12:16+00:00Added an answer on June 15, 2026 at 12:12 am

    The current version of lessR appears not to provide a function dens anymore, instead there is a function Density.

    Would you consider updating your R version and the package? Why are you using the 32-bit version of R? On a Mac you should be able to use the 64-bit version.

    I had a look at function dens from lessR_2.1.1. I could not reproduce your error (because you did not use set.seed to make your code reproducible). Instead I got Error in seq(min.x, max.x, length = 200) : Object 'min.x' not found with y <- c(3, 4, 8, 1, 6, 14, 20, 5, 13, 17, 19, 10, 2, 12, 7, 9, 18, 11, 15, 16).

    Here is an excerpt from the function code:

    d.gen <- suppressWarnings(density(x, bw, ...))
    
            mx <- mean(x)
    
            # min and max x coordinates for graph, make symmetric
            min.dev.x <- min(d.gen$x) - mx
            max.dev.x <- max(d.gen$x) - mx
            if (abs(min.dev.x) > abs(max.dev.x)) {
              min.x <- min(d.gen$x)
              max.x <- mx + abs(min.dev.x)
            }
            if (abs(max.dev.x) > abs(min.dev.x)) {
              min.x <- mx - abs(max.dev.x)
              max.x <- max(d.gen$x)
            }
    

    Note that the code does not define min.x and max.x, if abs(min.dev.x) == abs(max.dev.x), which is a bug. Of course that is easily fixed by changing the second if condition to if (abs(max.dev.x) >= abs(min.dev.x)) {.

    There might be other bugs, but it’s not worth fixing a function from an archived version of a utility package. Of course, I get a similar error with the new Density function and indeed it contains the same bug.

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

Sidebar

Related Questions

I want to use NSCalendarDate, which exists in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/ System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSCalendarDate.h but is not present
Platform: CentOS release 5.5 (Final) SVN, version 1.4.2 (r22196) Apache httpd.i386 2.2.3-43.el5.centos.3 I have
Ld /Users/rajeshmedampudi/Library/Developer/Xcode/DerivedData/sampleResource-flngddqnaawregcrrshzpianssjc/Build/Products/Debug-iphonesimulator/sampleResource.app/sampleResource normal i386 cd /Users/rajeshmedampudi/Dropbox/Work/iphone/sampleResource setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch
Context Language: C# Platform Version: Microsoft .Net Framework 4.0 Operating System: Windows 7 Professional
I have downloaded the ASP.NET MVC 2 Release version (using Web Platform Installer) as
When I go to the directory C:/programfiles/android/android-sdk/platform/<version>/ I couldn't find the samples directory. I
On all others versions of platform I use this: BrowserFieldConfig cfg = new BrowserFieldConfig();
I have experiencing a weird problem with the 'plot' function of the 'raster' package.
I've set my default ruby version with rvm use 1.9.3 --default When opening a
I have copy JSON.framework in my Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/System/Library/Frameworks /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks both folder and importing #import <JSON/SBJsonParser.h>

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.