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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:19:51+00:00 2026-06-13T01:19:51+00:00

For the data frame: exampleDF <- structure(list(val1 = structure(c(1L, 2L, 1L, 3L), .Label =

  • 0

For the data frame:

exampleDF <- structure(list(val1 = structure(c(1L, 2L, 1L, 3L), .Label = c("MX", 
"SS", "VF"), class = "factor"), var2 = c(1, 2, 3, 4)), .Names = c("val1", 
"var2"), row.names = c(NA, -4L), class = "data.frame")

instead of doing:

ddply(exampleDF, .(val1), summarize, sum(as.numeric(var2)))

Is it possible to parameterize the ddply call (something as follows, though I tried it and didn’t work):

colname <- 'var2'
ddply(exampleDF, .(val1), summarize, sum(as.numeric(colname)))

which results in ..

  val1 ..1
1   MX  NA
2   SS  NA
3   VF  NA
Warning messages:
1: In eval(expr, envir, enclos) : NAs introduced by coercion
2: In eval(expr, envir, enclos) : NAs introduced by coercion
3: In eval(expr, envir, enclos) : NAs introduced by coercion

We have to call ddply for a set of columns in the data frame and generate plots for each result of ddply. Hence we wanted to parameterize the ddply call instead of repeating the same line for n number of columns

  • 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-13T01:19:52+00:00Added an answer on June 13, 2026 at 1:19 am

    This is actually a challenge with summarize, not ddply. You could try and do something with parse and eval, but in general this is not a good idea. I would do something like:

    colname <- 'var2'
    ddply(exampleDF, .(val1), function(sub_dat) sum(as.numeric(sub_dat[[colname]])))
    

    You say you want to create multiple plots like this, however, I’ve almost always been able to create such a set of plots using facetting in ggplot2 (created by the same author as plyr). See e.g. the documentation of facet_wrap and facet_grid.

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

Sidebar

Related Questions

I have a melted data.frame, dput(x), below: ## dput(x) x <- structure(list(variable = structure(c(1L,
I have a list within a data frame (in this example, df$candpct ), and
I have many data.frames, for example: df1 = data.frame(names=c('a','b','c','c','d'),data1=c(1,2,3,4,5)) df2 = data.frame(names=c('a','e','e','c','c','d'),data2=c(1,2,3,4,5,6)) df3 =
I have a data frame like below (20,000 rows by 49 cols). Each row
Here is a short part of my data: dat <-structure(list(sex = structure(c(1L, 1L, 1L,
I have data similar to this: dt <- structure(list(fct = structure(c(1L, 2L, 3L, 4L,
I'm trying to access $a using the following example: df<-data.frame(a=c(x,x,y,y),b=c(1,2,3,4)) > df a b
How can I subset the following example data frame to only return one observation
Here is some example data: data = data.frame(series = c(1a, 1b, 1e), reading =
I would like to identify binary columns in a data.frame. For example, this table

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.