[R] Plot data inside matrix

alcesgabbo alcesgabbo at hotmail.com
Mon Nov 29 14:46:08 CET 2010


yes, this is a zoo object.

First off all I have:

procProperty: "sensor3" "sensor3" "sensor3" "sensor3" "sensor3" "sensor3"
"sensor3" "sensor3"
property:  "A" "B" "B" "A" "B" "B" "A" "A" "A"
data:  40 20 31 32 15 33 15 12  4

I create a matrix with this objects:

data<-cbind(data,property)
data<-cbind(data,procProperty)

now data is:

data:
 data property procProperty
 [1,] "40" "A"      "sensor3"  
 [2,] "20" "B"      "sensor3"  
 [3,] "31" "B"      "sensor3"  
 [4,] "32" "A"      "sensor3"  
 [5,] "15" "B"      "sensor3"  
 [6,] "33" "B"      "sensor3"  
 [7,] "15" "A"      "sensor3"  
 [8,] "12" "A"      "sensor3"  
 [9,] "4"  "A"      "sensor3"  

"index" contains the date :  "2010-10-1 7:32:00"  "2010-10-3 4:33:21" 
"2010-10-5 7:32:00"  "2010-10-2 7:32:00"  "2010-10-5 7:32:00"
 "2010-10-3 4:33:21"  "2010-10-1 17:32:00" "2010-10-3 14:33:21" "2010-10-6
17:32:00"

I modifed with this function: index<-as.POSIXlt(index)

then I do:

sensor<-zoo(data,index)

sensor is:
                               data property procProperty
2010-10-01 07:32:00 40   A        sensor3    
2010-10-01 17:32:00 15   A        sensor3    
2010-10-02 07:32:00 32   A        sensor3    
2010-10-03 04:33:21 20   B        sensor3    
2010-10-03 04:33:21 33   B        sensor3    
2010-10-03 14:33:21 12   A        sensor3    
2010-10-05 07:32:00 31   B        sensor3    
2010-10-05 07:32:00 15   B        sensor3    
2010-10-06 17:32:00 4    A        sensor3   

str(sensor) is:
 str(sensor)
‘zoo’ series from 2010-10-01 07:32:00 to 2010-10-06 17:32:00
  Data: chr [1:9, 1:3] "40" "15" "32" "20" "33" "12" "31" "15" "4" "A" "A"
"A" "B" "B" "A" ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:3] "data" "property" "procProperty"
  Index:  POSIXlt[1:9], format: "2010-10-01 07:32:00" "2010-10-01 17:32:00"
"2010-10-02 07:32:00" "2010-10-03 04:33:21" ...

it doesn't matter the type of the plot, the problem is how can i manage all
the data in order to visualize the plot?

How can I "tell" to the pc that I want one plot for each "property" (A and
B) and a line for each "procProperty"??

Maybe I should use the function "tapply"?? (in order to have an object like
this:)

table for A:
              sensor1  sensor2  sensor3
2010:....   40              32         20
2011:....   30               30       15


table for B:
              sensor1  sensor2  sensor3
2010:....   14              3         12
2011:....   10               30       15
-- 
View this message in context: http://r.789695.n4.nabble.com/Plot-data-inside-matrix-tp3063417p3063600.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list