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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:34:15+00:00 2026-06-14T14:34:15+00:00

I have a huge table and I want to make a plot of lets

  • 0

I have a huge table and I want to make a plot of lets say two different rows in this table.

Below you can see a small overview of my data set.

I want to plot now for country 4 the production of the years 1,2 and 3 so that someone can see the change over time

The same with country 6

On the X axis shoud be the years and on the Y axis should be the values.

Can somebody help me?

Thanks in advance!

   country    year1        unit        year2        unit    year3
    1          5.1         tonnes       1.4         tonnes   5
    2          4.9         tonnes       1.4         tonnes   2
    3          4.7         tonnes       1.3         tonnes   3.5
    4          4.6         tonnes       1.5         tonnes   8
    5          5.0         tonnes       1.4         tonnes   8
    6          5.4         tonnes       1.7         tonnes   6
  • 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-14T14:34:16+00:00Added an answer on June 14, 2026 at 2:34 pm

    These are the steps to create the plot.

    The data:

    dat <- read.table(text="country    year1      unit      year2      unit    year3
       1          5.1         tonnes       1.4         tonnes   5
       2          4.9         tonnes       1.4         tonnes   2
       3          4.7         tonnes       1.3         tonnes   3.5
       4          4.6         tonnes       1.5         tonnes   8
       5          5.0         tonnes       1.4         tonnes   8
       6          5.4         tonnes       1.7         tonnes   6", header = TRUE)
    
    1. Choose a subset of the data:

      subdat <- dat[dat$country == 4, c("year1", "year2", "year3")]
      
    2. Arrange the data in the long format:

      subdat_l <- data.frame(Value = unlist(subdat), Year = factor(1:3))
      
    3. Plot:

      plot(Value ~ Year, subdat_l)
      

    enter image description here


    If the actual data frame consists of the data of more than three years, you can use this general approach:

    years <- grep("^year", names(dat), value = TRUE) # find the columns with the data
    subdat <- dat[dat$country == 4, years]
    subdat_l <- data.frame(Value = unlist(subdat),
                           Year = substr(years, 5, nchar(years)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge table and I want simple sorting. It could be so
I have a huge table from one mysql db, I want to create a
I have a scripts that retrieves huge data on a table. I want to
I have a huge MySQL table which has its rows encoded in UTF-8 twice.
So I have this (huge) table , classed with css (big_conv_tbl) . All empty
We are using mysql. We have a huge table which contains 1 billion rows.
I have a huge record in a user table and I want to show
I have huge db, and in one table i want to set somefield to
I have a huge table, which has 3 columns and about 333,000 rows. The
I have a huge html table that I am building dynamically, and I want

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.