2

I have a data.frame with 10-15 entries which looks like this:

      group time1     time2    time3 
1      F18  4394.500  21043.50 14949.00 
2      F25  4678.000  23727.65 15683.12 
3      F30  4909.775  23487.60 16724.40 

I plot this with:

plot(variable[,2:4]) 

so that a plot with 3 rows and 3 lines for time1, time2 and time3 appears.

Is it somehow possible to label the data points with the values stored in group (F18, F25...)?

Rodrigo Guedes
  • 1,169
  • 2
  • 13
  • 27
Denise
  • 340
  • 3
  • 10

1 Answers1

1

I also recommend using ggplot2 (or lattice).

However, you can

  • use text to display the label texts at the given location

  • use colours according to the group (makes sense only if there are relatively few groups compared to

  • Note that plot (data.frame) actually uses pairs.

Put together:

df <- data.frame (group = sample (LETTERS[1:3], 10, replace=TRUE), 
                  x = rnorm (10), y = runif (10), z = rnorm (10))

panel.text <- function(x, y, text, ...)
  text (x, y, labels = text)

pairs (df[-1], text = df$group, lower.panel = panel.text, # label with name
    pch = 20, col = as.numeric (df$group))                # label with color

pairs panel function

cbeleites unhappy with SX
  • 13,717
  • 5
  • 45
  • 57
  • God damn thank you so much!!! I used lower.panel and upper.panel both with panel.text to display all the variables. – Denise Aug 17 '12 at 15:56