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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:21:54+00:00 2026-06-08T05:21:54+00:00

I would like to have a small function displaying basic data statistics for eachnumeric

  • 0

I would like to have a small function displaying basic data statistics for eachnumeric variable in a given dataset. So far I have the following:

AnalyzeNumericData <- function(x,GroupVar=NA) {

VarList <- names(x)  
NumVars <- length(VarList)  

for (i in (1:NumVars)) {
     if (is.numeric(x[,VarList[i]])) {
       par(mfrow=c(2,2))
         hist(x[,VarList[i]],main=paste("Histogram of ",VarList[i]),xlab=NA)
         boxplot(x[,VarList[i]],main=paste("Boxplot of ",VarList[i]))
      if (!is.na(GroupVar)) {
        boxplot(x[,VarList[i]]~x[,GroupVar],main=paste("Boxplot of ",VarList[i]," by ", GroupVar))
      }   
        # Add some text to bottom right
        # I've tried plot(1)
        # and then text(1,"MyText"), but this only alows me to put text on one place (in the middle of the plot)
    }
  }
}

AnalyzeNumericData(mtcars,"cyl")

The function will create three charts for each numeric variable. I would like to add some text instead of the 4th chart to the bottom right area. I know of text(), however I have to create something like empty chart first in order to use this.

Any ideas appreciated.

  • 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-08T05:21:55+00:00Added an answer on June 8, 2026 at 5:21 am
    AnalyzeNumericData <- function(x,GroupVar=NA) {
        VarList <- names(x)
        NumVars <- length(VarList)
    
        for (i in 1) {
            if (is.numeric(x[,VarList[i]])) {
                par(mfrow=c(2,2))
                hist(x[,VarList[i]],main=paste("Histogram of ",VarList[i]),xlab=NA)
                boxplot(x[,VarList[i]],main=paste("Boxplot of ",VarList[i]))
                if (!is.na(GroupVar)) {
                    boxplot(x[,VarList[i]]~x[,GroupVar],main=paste("Boxplot of ",VarList[i]," by ", GroupVar))
                }
                plot(NA,NA,axes=F,xlim=c(0,10),ylim=c(0,10),xlab="",ylab="")
                text(5,5,labels="MyText")
            }
        }
    }
    
    AnalyzeNumericData(mtcars,"cyl")
    

    You can change x and y of text(x,y,labels="MyText") to adjust position of the text according to xlim and ylim.

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

Sidebar

Related Questions

We have a small data set and would like to search through it in
I have a small class hierarchy where I would like to have a child
I have a small JSF app and would like to keep some state on
We have a small work group that I would like to encourage to adopt
I have a small problem with url rewriting on apache. I would like it
I am working toward a small webapp that I would like to have a
I have a relatively small database that I would like to generate a diagram
I have made a small application in Java and I would like to make
Hey guys, I have developed a small site that i would like to embed
I have a well div, and I would like to attach a small text/image

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.