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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:13:57+00:00 2026-06-01T23:13:57+00:00

The graph, I have down. The challenge is I have the _exact_same_code_ for graphing

  • 0

The graph, I have down.
The challenge is I have the _exact_same_code_ for graphing multiple data sets (rather, subsets of one LARGE data set), but I can’t seem to get the looping code right to substitute the $ correctly.

Data sets, df1, df2, df3… of the form:

OBSDATE     REGION  AVG_RESP  P10  P90
2012-02-01  APAC    1.276     0.78 3.45
2012-02-01  EMEA    2.341     1.23 5.67
2012-02-02  APAC    1.343     0.89 3.21
2012-02-02  EMEA    2.473     1.37 5.98

The graph is more complex, but like this:

avgMx <- quantile(df1$P90,0.95)
ggplot(df1,aes(x=OBSDATE,y=AVG_RESP))+coord_cartesian(ylim=c(0,avgMx))+geom_ribbon(aes(ymin=P10,ymax=P90),fill="gray60",alpha=0.33)+geom_line(aes(x=OBSDATE,y=AVG_RESP),color="#007DB1",size=0.5)+facet_wrap(~REGION)

if I define a vector or list (both seem to fail with the same error messages) with the data set names I can’t get the loop to work to find any descriptive values (like the quantile above or even a max!)

filenames <- c("df1","df2","df3")

I would like to get something like this to work

for (i in filenames) {
   quantile(i$AVG_RESP,0.95)
   max(i$AVG_RESP)
}

But I get errors about $ is invalid for atomic vectors. Upon investigation, that doesn’t seem to yield any usable results.

So, I can get this to work:

max(df1$AVG_RESP) or max(df1['AVG_RESP'])

they both would output 2.473 from above. However, this doesn’t fly:

for (i in pagesC) max(i['AVG_RESP'])

It does nothing. Changing it to this:

for (i in pagesC) print(max(i['AVG_RESP']))

Gives instances of NA.

I’m completely stuck. Any help would be tremendously appreciated!

EDIT: I fixed the data that was causing errors – should be reproducible now.

  • 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-01T23:13:58+00:00Added an answer on June 1, 2026 at 11:13 pm

    i is a character string; you want the object which has the name that is held in i. That is the get() function. (untested since what you gave was not reproducible.)

    for (filename in filenames) {
       i <- get(filename)
       quantile(i$AVG_RESP,0.95)
       max(i$AVG_RESP)
    }
    

    This is probably not the best way to solve your problem, though. Putting all the data frames in a list and looping over that list with lapply might be a better approach (what Tyler described in his answer). Furthermore, if these are subsets you’ve made of a bigger, single data frame you have, then an even better approach would be to use something from the plyr package to define how to split the big data frame up and what to do with each part.

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

Sidebar

Related Questions

I have a data set which is a large unweighted cyclic graph The cycles
I have a datafile listing bandwidth for each machine on a network, but down
I have a Core-Plot Graph within a Mac Application. But the inside table is
I have a table with a large amount of data and need to do
I have a directed graph data structure, where I am trying to implement individual
Sorry I am very new to open graph and have been having difficulty to
I have a graph representing users and some articles they wrote. I need to
I have a graph that contains nodes (groups) composed by inner nodes and when
I have 6 graph bars with the prices. Each price number will represent its
I have a graph (organigram) how this: digraph G { nodesep=0.3; ranksep=0.2; margin=0.1; node

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.