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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:14:54+00:00 2026-06-03T02:14:54+00:00

My data is > data width variable value 1 200 mappedEnsemblTx 110 2 400

  • 0

My data is

> data
    width          variable value
1     200   mappedEnsemblTx   110
2     400   mappedEnsemblTx   392
3     600   mappedEnsemblTx  1055
4     800   mappedEnsemblTx  2615
5    1000   mappedEnsemblTx  5201
101   200 UnmappedEnsemblTx  3927
102   400 UnmappedEnsemblTx  5175
103   600 UnmappedEnsemblTx  3220
104   800 UnmappedEnsemblTx  4856
105  1000 UnmappedEnsemblTx  7130  

When I plot this, instead of two bars I can see three or probably four bars in my plot.
Minimal code is as below:

 library(ggplot2)


g = ggplot(dat.melt,aes(x=factor(width),y=value,fill=variable), format(scientific=FALSE)) 
g = g + geom_bar(stat='identity',position='dodge') 
g <- g + theme_bw()
g = g + opts(axis.text.x=theme_text(angle=-90, hjust=0, size = 16), axis.text.y=theme_text(size=16))
g <- g + opts(axis.title.x = theme_text(size=18), axis.title.y = theme_text(size=18, angle=90) )
g = g + scale_x_discrete('Total widths of the Ensembl Transcripts') + scale_y_continuous(name = 'Count') 
g = g + coord_cartesian(ylim = c(0,7000))

Thanks

  • 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-03T02:14:56+00:00Added an answer on June 3, 2026 at 2:14 am

    With

    data.melt <- structure(list(width = c(200L, 400L, 600L, 800L, 1000L, 200L, 
    400L, 600L, 800L, 1000L), variable = structure(c(1L, 1L, 1L, 
    1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("mappedEnsemblTx", "UnmappedEnsemblTx"
    ), class = "factor"), value = c(110L, 392L, 1055L, 2615L, 5201L, 
    3927L, 5175L, 3220L, 4856L, 7130L)), .Names = c("width", "variable", 
    "value"), class = "data.frame", row.names = c("1", "2", "3", 
    "4", "5", "101", "102", "103", "104", "105"))
    

    and your example

    g <- ggplot(data.melt,aes(x=factor(width),y=value,fill=variable),
                format(scientific=FALSE)) 
    g <- g + geom_bar(stat='identity',position='dodge') 
    g <- g + theme_bw()
    g <- g + opts(axis.text.x=theme_text(angle=-90, hjust=0, size = 16), 
                  axis.text.y=theme_text(size=16))
    g <- g + opts(axis.title.x = theme_text(size=18),
                  axis.title.y = theme_text(size=18, angle=90) )
    g <- g + scale_x_discrete('Total widths of the Ensembl Transcripts') +
             scale_y_continuous(name = 'Count') 
    g <- g + coord_cartesian(ylim = c(0,7000))
    g
    

    I get:

    barplot example

    which is what I would expect; 5 groups of 2 bars. 5 groups because you have 5 values of width and 2 levels in the factor variable.

    That is with:

    R> sessionInfo()
    R version 2.15.0 Patched (2012-04-16 r59049)
    Platform: x86_64-unknown-linux-gnu (64-bit)
    
    locale:
     [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C             
     [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8    
     [5] LC_MONETARY=en_GB.utf8    LC_MESSAGES=en_GB.utf8   
     [7] LC_PAPER=C                LC_NAME=C                
     [9] LC_ADDRESS=C              LC_TELEPHONE=C           
    [11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C      
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] ggplot2_0.9.0
    
    loaded via a namespace (and not attached):
     [1] colorspace_1.1-1   dichromat_1.2-4    digest_0.5.2       grid_2.15.0       
     [5] MASS_7.3-17        memoise_0.1        munsell_0.3        plyr_1.7.1        
     [9] proto_0.3-9.2      RColorBrewer_1.0-5 reshape2_1.2.1     scales_0.2.0      
    [13] stringr_0.6        tools_2.15.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame with a grouping variable 'ID' and some values ('Value'):
If core data has an object that has a specific member variable value I
I have a page-scoped component, which has an instance variable List with data, which
I have the following data. I want to take veh variable, starting with its
I have an int* of rgb data,width, height, and scanlinestride where i would like
I’m trying to import fixed width data from text file into SQL Server Express
In Oracle I've created a data type: TABLE of VARCHAR2(200) I want to have
I am building a variable resolution ruler control for a data visualization program. I
I have a data frame that's ~ 50,000 X 200. The column names are
How can I get the specified input value from an ajax request callback data?

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.