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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:09:41+00:00 2026-06-11T02:09:41+00:00

I am working with a rarefaction output from mothur , which basically gives me

  • 0

I am working with a rarefaction output from mothur, which basically gives me a dataset containing the number of sequences sampled and the number of unique sequences in several samples. I would like to use ggplot2 to visualize this data and therefore need to use melt to go from a wide to a long format.

The problem is that I find no way to make this work due to an error of melt. Which basically states

Error: id variables not found in data: 1,3,6, (… and so on)

Because of the size of the original dataset it would be impractcal to share it here nonetheless one should be able to recreate the same problem using the following code:

a<-seq(0,300,3)
b<-runif(length(a))
c<-runif(length(a))
d<-as.data.frame(cbind(a,b,c))
d$a<-as.factor(d$a)
melt(d,d$a)

Which gives exactly the same error:

Error: id variables not found in data: 0,3,6,9, (…)

I fail to see what I am doing wrong. I am using R 2.15.1 on ubuntu server 12.04. Both the function reshape::melt and reshape2::melt result in the same error.

  • 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-11T02:09:42+00:00Added an answer on June 11, 2026 at 2:09 am

    You should use:

    melt(d, id.vars="a")
          a variable       value
    1     0        b 0.019199459
    2     3        b 0.693699677
    3     6        b 0.937592641
    4     9        b 0.299259963
    5    12        b 0.485403439
    ...
    

    From the help of ?melt.data.frame:

    data
    data frame to melt

    id.vars
    vector of id variables. Can be integer (variable position) or
    string (variable name)If blank, will use all non-measured variables

    Thus your id.vars argument should be a character vector of names, e.g. “a” or a numeric vector, e.g. 1. The length of this vector should equal the number of columns you want as your id.

    Instead, you used a factor that contained far more elements than you have columns in your data.

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

Sidebar

Related Questions

Working with an undisclosed API, I found a function that can set the number
Working on game where plates will be falling from top to bottom. Some plates
Working on calling a C function from my asm project. I'm trying to push
Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
Working in Scala-IDE, I have a Java library, in which one of the methods
Working of foreach: As I know, foreach is a loop which iterates through a
Working with COM interop, I can call a managed function from within unmanaged code.
Working with python interactively, it's sometimes necessary to display a result which is some
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
Working in iOS 5 I have read a list of file names from my

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.