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

  • Home
  • SEARCH
  • 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 6837353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:28:00+00:00 2026-05-26T23:28:00+00:00

I am trying to run a jack-knife using Plyr. I have a large dataset

  • 0

I am trying to run a jack-knife using Plyr. I have a large dataset (715 sites over 10 years). I have already calculated the Species Richness (count of all species present) in a square for each year but now I want to calculate new Richness values, after taking out one species at a time and have them all in one dataset.

Example data:

Site <- c(1,1,1,1,1,1)
Year <- c(96,96,96,97,97,97)
SpID <- c(1,2,3,1,2,3)
Count <- c(1,1,1,1,1,1)
data <- cbind(Site, Year, SpID)

So overall for Site 1 the species richness is 3 in both years. If I want recalculate this without one of the species it would now be 2.

I have tried using the following code:

foo<-function(z){
    data2 <- subset(data, SpID != (z))
    summaryBy(Count~ Year + Site, 
              data = data2, 
              FUN = function(x) { c(l = length(x)) } )
}

richall<- ddply(data,.(SpID),foo)

But I’m obviously making a mistake somewhere! Any thoughts?

  • 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-05-26T23:28:01+00:00Added an answer on May 26, 2026 at 11:28 pm

    With your example data and call to ddply, this is what will happen:

    • ddply will find the different values in the SpID column of your
      dataset (1, 2 and 3)
    • It will next create a data.frame for each of these unique values.
    • Each of these data.frames will hold only the rows for which the
      SpID is equal to that unique value (so: a data.frame with the first
      and fourth rows, one with the second and fifth and one with the third
      and last rows)
    • Function foo will now be called, passing each of these data.frames
      one at a time as its first argument

    So it is rather obvious now that this will not help in doing jack-knife. In fact I don’t see an obvious way of attaining that with plyr. In this particular case you’re probably better off rigging your own with similar logic. Something like:

    listOfResults <- 
        lapply(unique(data$SpID), 
               function(curID) {
                   curDF<-data[data^SpID!=curID,]
                   summaryBy(...,data=curDF)
               })
    

    You can then recombine your results with e.g. ?do.call.

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

Sidebar

Related Questions

I'm trying to write a script for a Black Jack game but have run
Trying to run my program in FreeBSD OS, I have the following results: $
When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using
When I trying run Android Emulation, i Have error message: $ tools/emulator -avd Default
I am trying run geotools on the web and have been googling around how
Trying to run the basic examples given by playn, wanting to have a go
Im trying to run a program with templates using operator < ,> methods, im
Trying to run a java test using bluecove, I got: Native Library bluecove_x64 not
Been trying to run a rails app using terminal in jruby 1.9 mode. I
Im trying to run symfony 2 app on server and i have an error:

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.