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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:37:46+00:00 2026-05-19T14:37:46+00:00

I am using a data set like: 1 48434 14566 1 56711 6289 1

  • 0

I am using a data set like:

1  48434  14566
1  56711  6289
1  58826  4174
2  56626  6374
2  58888  4112
2  59549  3451
2  60020  2980
2  60468  2532
3  56586  6414
3  58691  4309
3  59360  3640
3  59941  3059
.
.
.
10  56757  6243
10  58895  4105
10  59565  3435
10  60120  2880
10  60634  2366

I need a plot in R of 3rd column for each value of first column i.e. for above data there would be 10 different plots of (each group 1-10) of values of 3rd column. x-axis is number of Iterations and Y-axis is the values with max 63000. I also need to connect the dots with a line in color red.
I am new to R and have been reading documentation but that confused me more. could any body plz help.

EDIT: I actually want line graph of V3 values. the number of rows of v3 column would be on x-axis and v3 values on y-axis. And I want different graphs each for a group indicated by v1. Chase’s solution works except that I want the axis shifted, the V3 values should be on y-axis.here is example
alt text

EDIT2: @Roman, Here is the code I am executing.

library(lattice)
d <- read.delim("c:\\proj58\\positions23.txt",sep="")
d <- do.call(rbind, lapply(split(d, d$V1), function(x) {
    x$iterations <- order(x$V3, decreasing=TRUE)
    x
}))
xyplot(V3 ~ iterations | V1, type="l", data=d)

This is the error I get,

    > 
>  source("C:\\proj58\\plots2.R")
> d
       V1    V2    V3 iterations
1.1     1 48434 14566          1
1.2     1 56711  6289          2
1.3     1 58826  4174          3
1.4     1 59528  3472          4

I am not getting any plot?? what am I missing
OK: Got It. don’t know what was wrong. Here it is,

alt text

2 more things, how to change V1 labels on the boxes to actual numbers like 1,2,…
secondly I have files that contain 100 groups, I tried one and it made all graphs on a single page (unreadable obviously), can I make these on more than one windows?

  • 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-19T14:37:46+00:00Added an answer on May 19, 2026 at 2:37 pm

    Well, first you need to create a variable with the row number, for each subset of the first variable separately. Here’s one way to do it, by splitting the data set by the first variable, making a new variable that has the row number, and recombining.

    You also probably want V1 to be a factor (a categorical variable).

    d <- do.call(rbind, lapply(split(d, d$V1), function(x) {
        x$iterations <- 1:nrow(x)
        x
    }))
    d$V1 <- factor(d$V1)
    

    Then using the lattice library, you’d do something like

    xyplot(V3 ~ iterations | V1, type="l", data=d)
    

    To make the plots appear on more than one page, limit the number of plots on a page using the layout option. You’ll need to save the plot to a file that supports multi-page output to do that. For example, for 5 rows and 5 columns:

    trellis.device("pdf", file="myplot.pdf")
    p <- xyplot(V3 ~ iterations | V1, type="l", data=d, layout=c(5,5))
    plot(p)
    dev.off()
    

    Also, to make the plot appear when running the code using source, you need to specifically plot the output from the xyplot command, like

    p <- xyplot(...)
    plot(p)
    

    When running at the console, this is not necessary as the plot (well, actually, the print function) is called on it by default.

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

Sidebar

Related Questions

Using jmeter, I have a variable passed from CSV file (using CSV Data Set
I'm using Flot to plot a line graph and my data set is a
I'm using sqlite as temporary storage to calculate statistic about moderately large data set.
I'm loading data into a DataSet from an XML file using the ReadXml method.
I have a problem with binding data using BindingSource, typed dataset and DataGridView. My
I have a very simple WPF application in which I am using data binding
I have the following data set, which represents nodes in a directed graph. CREATE
I have a function like this defined in one class: using System; using System.Collections.Generic;
I have a data set that I am reporting on. However, some of the
Im just starting to get the hang of using json and Id like to

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.