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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:47:18+00:00 2026-05-16T01:47:18+00:00

Greetings, Basically, I have two vectors of data (let’s call it experimental and baseline).

  • 0

Greetings,

Basically, I have two vectors of data (let’s call it experimental and baseline). I want to use the lattice library and histogram functions of R to plot the two histograms side-by-side, just as seen at the end of this page.

I have my data in a CSV file like this:

Label1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
Label2,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
Label3,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
Label4,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
Label5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
Label6,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18

Each row should be a new pair of histograms. Columns 1-9 represents the data for the experiment (left-side histogram). Columns 10-18 represents the baseline data (right-side histogram).

Can anyone help me on this? 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-05-16T01:47:18+00:00Added an answer on May 16, 2026 at 1:47 am

    Your data is poorly formatted for faceting with lattice. You can restructure it using reshape.

    read.csv(textConnection("Label1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
    Label2,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
    Label3,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
    Label4,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
    Label5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
    Label6,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"), header = F)->data
    
    colnames(data)[1] <- "ID"
    colnames(data)[2:10] <- paste("exp",1:9, sep = "_")
    colnames(data)[11:19] <- paste("base", 1:9, sep = "_")
    
    library(reshape)
    data.m <- melt(data, id = "ID")
    data.m <- cbind(data.m, colsplit(data.m$variable, "_", names = c("Source","Measure")))
    

    data.m is now in the format you really want your data to be in for almost everything. I don’t know if each of the 9 measurements from the experiment and the baseline are meaningful or can be meaningfully compared so I kept them distinct.

    Now, you can use lattice properly.

    histogram(~value | Source + ID, data = data.m)
    

    If the measurements are meaningfully compared (that is, data[,2] and data[,11] are somehow the “same”), you could recast the data to directly compare experiment to baseline

    data.comp <- cast(data.m, ID + Measure ~ Source)  
    ## I know ggplot2 better
    library(ggplot2)
    qplot(base, exp, data = data.comp)+
      geom_abline()+
      expand_limits(x = 0, y = 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings. I'm just getting started with the boost::asio library and have run into some
Greetings I have an ajax call which: Gets an xml file of posts Populates
Greetings and salutations, I have two Android apps: one is the server and one
Greetings, I'm trying to find either a free .NET library or a command-line executable
Greetings, I have a problem which would seem to involve some kind of z-index
greetings all i have a domain class named car and i have an object
Basically, I have one div(divNew) which is being populated with content from another page(thread.php)
Greetings, I want to write a script that handles simple http requests from Google
Gretings I need to have a custom control for my application. Basically its an
greetings from Iceland! To begin with, I have searched both with google and here

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.