Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot type=heat y-axis order #87

Open
technoautotroph opened this issue Apr 3, 2018 · 2 comments
Open

Plot type=heat y-axis order #87

technoautotroph opened this issue Apr 3, 2018 · 2 comments

Comments

@technoautotroph
Copy link

I've been trying to work from the following example to generate a heat plot:

http://rcompanion.org/handbook/E_03.html

However, my y-axis will not order no matter how I input the data.

Example:
>Result

Item      1      2      3
P1       4.0   2.1     3.2
P2       4.1   6.1     3.4
P3       1.9   2.5     3.9
...
P12      3.9   4.5     6.7

The heat plot y-axis for P1-P12 goes in the following order: P1, P10, P11, P12, P2, P3, P4, P5, P6, P7, P8, P9

How do I get this to arrange in the proper order? I tried the following:

plot(Result,
      order=c("P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11", "P12"), 
      type="heat",
      low.color = "white", 
      high.color = "blue",
      text.color = "black", 
      text.size = 4, 
      wrap = 50,
      )

Does not give me the result I am seeking.

@technoautotroph
Copy link
Author

heatplot

@technoautotroph
Copy link
Author

The example data I provide above is dummy data, but that shouldn't matter (I don't think). Here is an actual summary of my data:

> str(Result)
List of 7
 $ results :'data.frame':	12 obs. of  11 variables:
  ..$ Item: Factor w/ 12 levels "P1","P10","P11",..: 1 5 6 7 8 9 10 11 12 2 ...
  ..$ 1   : num [1:12] 5.26 0 0 0 0 ...
  ..$ 2   : num [1:12] 0 0 0 0 0 ...
  ..$ 3   : num [1:12] 0 10.5 0 0 0 ...
  ..$ 4   : num [1:12] 0 5.26 0 10.53 0 ...
  ..$ 5   : num [1:12] 5.26 5.26 5.26 15.79 10.53 ...
  ..$ 6   : num [1:12] 10.53 5.26 10.53 5.26 5.26 ...
  ..$ 7   : num [1:12] 0 5.26 21.05 5.26 0 ...
  ..$ 8   : num [1:12] 26.3 42.1 26.3 21.1 31.6 ...
  ..$ 9   : num [1:12] 31.58 5.26 21.05 15.79 10.53 ...
  ..$ 10  : num [1:12] 21.1 21.1 15.8 26.3 42.1 ...
 $ items   :'data.frame':	19 obs. of  12 variables:
  ..$ P1 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 10 9 6 9 5 9 1 8 10 9 ...
  ..$ P2 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 10 8 4 8 8 8 5 8 10 9 ...
  ..$ P3 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 7 7 9 8 7 9 5 10 10 8 ...
  ..$ P4 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 9 10 8 10 4 9 5 5 10 8 ...
  ..$ P5 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 6 10 5 8 10 9 5 10 10 8 ...
  ..$ P6 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 8 1 6 10 5 4 1 10 10 8 ...
  ..$ P7 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: NA 10 5 9 10 3 5 7 10 8 ...
  ..$ P8 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 9 10 10 6 2 4 1 5 10 8 ...
  ..$ P9 : Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 10 10 4 5 7 9 1 5 10 9 ...
  ..$ P10: Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 9 10 7 9 10 9 1 10 10 8 ...
  ..$ P11: Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 10 10 10 10 9 9 1 8 10 8 ...
  ..$ P12: Ord.factor w/ 10 levels "1"<"2"<"3"<"4"<..: 5 6 1 7 10 9 1 7 10 8 ...
 $ grouping: NULL
 $ factors : NULL
 $ nlevels : int 10
 $ levels  : chr [1:10] "1" "2" "3" "4" ...
 $ Item    : Ord.factor w/ 12 levels "P1"<"P2"<"P3"<..: 
 - attr(*, "class")= chr "likert"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant