Can I assign colors to MASS::parcoord() based on a logical condition?How do I vary colors on a non-grouping factor in R's lattice barcharts?plot functions with filled point symbols and legendParallel Co-ordinates Plot in RPoint Pattern AnalysisHow to get data from adjusted quantile plot in R?Multiple variables on same barplot in R with ifelse col statementFind scatterplot area where ~50% of points have one of 2 valuesUsing multiple color scales in stacked bar plots with ggplotggplot2 confusion matrix conditional fillMaking a grouped bar chart using a matrix in R
How do I handle a DM that plays favorites with certain players?
How to win against ants
Make lens aperture in Tikz
How does Rust's 128-bit integer `i128` work on a 64-bit system?
What is it exactly about flying a Flyboard across the English channel that made Zapata's thighs burn?
Is it uncompelling to continue the story with lower stakes?
Can attackers change the public key of certificate during the SSL handshake
Are valid inequalities worth the effort given modern solver preprocessing options?
Is there a general term for the items in a directory?
Properties: Left of the colon
Does a humanoid possessed by a ghost register as undead to a paladin's Divine Sense?
When using the Proficiency Dice optional rule, how should they be used in determining a character's Spell Save DC?
Pronouns when writing from the point of view of a robot
Is it okay to use different fingers every time while playing a song on keyboard? Is it considered a bad practice?
How does Geralt transport his swords?
How do the surviving Asgardians get to Earth?
What could prevent players from leaving an island?
Why is it to say 'paucis post diebus'?
split inside flalign
Glue-up for butcher block-style countertop
Plotting Autoregressive Functions / Linear Difference Equations
Why are there yellow dot stickers on the front doors of businesses in Russia?
Write The Shortest Program to Calculate Height of a Binary Tree
Is being a sunni or having sunni toughts a reason not to be reliable as a hadith narrator (shi'a hadith)?
Can I assign colors to MASS::parcoord() based on a logical condition?
How do I vary colors on a non-grouping factor in R's lattice barcharts?plot functions with filled point symbols and legendParallel Co-ordinates Plot in RPoint Pattern AnalysisHow to get data from adjusted quantile plot in R?Multiple variables on same barplot in R with ifelse col statementFind scatterplot area where ~50% of points have one of 2 valuesUsing multiple color scales in stacked bar plots with ggplotggplot2 confusion matrix conditional fillMaking a grouped bar chart using a matrix in R
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Here's the code to generate a parallel coordinate plot:
require(MASS)
shoes <- data.frame(shoes)
parcoord(shoes)
The shoes
data set is used to show the power of a paired t-test, which is just background info. There are two columns in shoes, A and B, which represent wear from two sole materials. Analyzed correctly, there is a tremendous difference between the materials.
A good way to show paired data is with the parallel coordinate plot, but as you can see it's pretty much nothing without some color. I'd like to add two colors, say, red when A > B
and green when A < B
. Both situations occur:
> shoes$A > shoes$B
[1] FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE
My problem is that parcoord()
cycles through colors as it goes through observations, so I'm not sure how to specify the color based on the logical test. I've tried
parcoord(shoes, col = ifelse(shoes$A > shoes$B, "red", "green"))
and various playing around with numbers (lots aside from just adding 26) in
my_colors <- colors()[as.numeric(shoes$A > shoes$B) + 26]
parcoord(shoes, col = my_colors)
but nothing seems to work. I either get a spectrum of colors, all one color, or all one color except for the top and bottom entries. I'd like the FALSE
to generate one color, TRUE
to generate another.
r
add a comment |
Here's the code to generate a parallel coordinate plot:
require(MASS)
shoes <- data.frame(shoes)
parcoord(shoes)
The shoes
data set is used to show the power of a paired t-test, which is just background info. There are two columns in shoes, A and B, which represent wear from two sole materials. Analyzed correctly, there is a tremendous difference between the materials.
A good way to show paired data is with the parallel coordinate plot, but as you can see it's pretty much nothing without some color. I'd like to add two colors, say, red when A > B
and green when A < B
. Both situations occur:
> shoes$A > shoes$B
[1] FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE
My problem is that parcoord()
cycles through colors as it goes through observations, so I'm not sure how to specify the color based on the logical test. I've tried
parcoord(shoes, col = ifelse(shoes$A > shoes$B, "red", "green"))
and various playing around with numbers (lots aside from just adding 26) in
my_colors <- colors()[as.numeric(shoes$A > shoes$B) + 26]
parcoord(shoes, col = my_colors)
but nothing seems to work. I either get a spectrum of colors, all one color, or all one color except for the top and bottom entries. I'd like the FALSE
to generate one color, TRUE
to generate another.
r
add a comment |
Here's the code to generate a parallel coordinate plot:
require(MASS)
shoes <- data.frame(shoes)
parcoord(shoes)
The shoes
data set is used to show the power of a paired t-test, which is just background info. There are two columns in shoes, A and B, which represent wear from two sole materials. Analyzed correctly, there is a tremendous difference between the materials.
A good way to show paired data is with the parallel coordinate plot, but as you can see it's pretty much nothing without some color. I'd like to add two colors, say, red when A > B
and green when A < B
. Both situations occur:
> shoes$A > shoes$B
[1] FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE
My problem is that parcoord()
cycles through colors as it goes through observations, so I'm not sure how to specify the color based on the logical test. I've tried
parcoord(shoes, col = ifelse(shoes$A > shoes$B, "red", "green"))
and various playing around with numbers (lots aside from just adding 26) in
my_colors <- colors()[as.numeric(shoes$A > shoes$B) + 26]
parcoord(shoes, col = my_colors)
but nothing seems to work. I either get a spectrum of colors, all one color, or all one color except for the top and bottom entries. I'd like the FALSE
to generate one color, TRUE
to generate another.
r
Here's the code to generate a parallel coordinate plot:
require(MASS)
shoes <- data.frame(shoes)
parcoord(shoes)
The shoes
data set is used to show the power of a paired t-test, which is just background info. There are two columns in shoes, A and B, which represent wear from two sole materials. Analyzed correctly, there is a tremendous difference between the materials.
A good way to show paired data is with the parallel coordinate plot, but as you can see it's pretty much nothing without some color. I'd like to add two colors, say, red when A > B
and green when A < B
. Both situations occur:
> shoes$A > shoes$B
[1] FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE
My problem is that parcoord()
cycles through colors as it goes through observations, so I'm not sure how to specify the color based on the logical test. I've tried
parcoord(shoes, col = ifelse(shoes$A > shoes$B, "red", "green"))
and various playing around with numbers (lots aside from just adding 26) in
my_colors <- colors()[as.numeric(shoes$A > shoes$B) + 26]
parcoord(shoes, col = my_colors)
but nothing seems to work. I either get a spectrum of colors, all one color, or all one color except for the top and bottom entries. I'd like the FALSE
to generate one color, TRUE
to generate another.
r
r
asked Mar 27 at 2:32
Sciolism ApparentlySciolism Apparently
2191 silver badge10 bronze badges
2191 silver badge10 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I'm not sure if I'm getting this straight, but your condition A > B
is only true for the maximum and minimum of shoes
.
shoes <- within(shoes, criterium <- ifelse(A > B, "bigger", "smaller"))
A B criterium
1 13.2 14.0 smaller
2 8.2 8.8 smaller
3 10.9 11.2 smaller
4 14.3 14.2 bigger
5 10.7 11.8 smaller
6 6.6 6.4 bigger
7 9.5 9.8 smaller
8 10.8 11.3 smaller
9 8.8 9.3 smaller
10 13.3 13.6 smaller
minmax <- c(min(min(shoes$A), min(shoes$B)), max(max(shoes$A), max(shoes$B)))
> minmax
[1] 6.4 14.3
So your parallel coordinates plot will show only the top and bottom entries in "red". In other words: Your solution is correct.
Chapeaux @Humpelstielzchen! Looks like I chose an unfortunate example for my paired t-test analysis and plot. You've shown me that the two A>B rows are a very small difference, making them appear as nearly straight lines. I think I can still salvage a pedagogically valuable plot by highlighting one of the pairs. Maybe all pairs plotted in light gray except one pair shown in black—probably point 5, the largest difference—which illustrates what the plot shows, but isn't as boring as the default, all-black plot.
– Sciolism Apparently
Mar 27 at 17:48
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368915%2fcan-i-assign-colors-to-massparcoord-based-on-a-logical-condition%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm not sure if I'm getting this straight, but your condition A > B
is only true for the maximum and minimum of shoes
.
shoes <- within(shoes, criterium <- ifelse(A > B, "bigger", "smaller"))
A B criterium
1 13.2 14.0 smaller
2 8.2 8.8 smaller
3 10.9 11.2 smaller
4 14.3 14.2 bigger
5 10.7 11.8 smaller
6 6.6 6.4 bigger
7 9.5 9.8 smaller
8 10.8 11.3 smaller
9 8.8 9.3 smaller
10 13.3 13.6 smaller
minmax <- c(min(min(shoes$A), min(shoes$B)), max(max(shoes$A), max(shoes$B)))
> minmax
[1] 6.4 14.3
So your parallel coordinates plot will show only the top and bottom entries in "red". In other words: Your solution is correct.
Chapeaux @Humpelstielzchen! Looks like I chose an unfortunate example for my paired t-test analysis and plot. You've shown me that the two A>B rows are a very small difference, making them appear as nearly straight lines. I think I can still salvage a pedagogically valuable plot by highlighting one of the pairs. Maybe all pairs plotted in light gray except one pair shown in black—probably point 5, the largest difference—which illustrates what the plot shows, but isn't as boring as the default, all-black plot.
– Sciolism Apparently
Mar 27 at 17:48
add a comment |
I'm not sure if I'm getting this straight, but your condition A > B
is only true for the maximum and minimum of shoes
.
shoes <- within(shoes, criterium <- ifelse(A > B, "bigger", "smaller"))
A B criterium
1 13.2 14.0 smaller
2 8.2 8.8 smaller
3 10.9 11.2 smaller
4 14.3 14.2 bigger
5 10.7 11.8 smaller
6 6.6 6.4 bigger
7 9.5 9.8 smaller
8 10.8 11.3 smaller
9 8.8 9.3 smaller
10 13.3 13.6 smaller
minmax <- c(min(min(shoes$A), min(shoes$B)), max(max(shoes$A), max(shoes$B)))
> minmax
[1] 6.4 14.3
So your parallel coordinates plot will show only the top and bottom entries in "red". In other words: Your solution is correct.
Chapeaux @Humpelstielzchen! Looks like I chose an unfortunate example for my paired t-test analysis and plot. You've shown me that the two A>B rows are a very small difference, making them appear as nearly straight lines. I think I can still salvage a pedagogically valuable plot by highlighting one of the pairs. Maybe all pairs plotted in light gray except one pair shown in black—probably point 5, the largest difference—which illustrates what the plot shows, but isn't as boring as the default, all-black plot.
– Sciolism Apparently
Mar 27 at 17:48
add a comment |
I'm not sure if I'm getting this straight, but your condition A > B
is only true for the maximum and minimum of shoes
.
shoes <- within(shoes, criterium <- ifelse(A > B, "bigger", "smaller"))
A B criterium
1 13.2 14.0 smaller
2 8.2 8.8 smaller
3 10.9 11.2 smaller
4 14.3 14.2 bigger
5 10.7 11.8 smaller
6 6.6 6.4 bigger
7 9.5 9.8 smaller
8 10.8 11.3 smaller
9 8.8 9.3 smaller
10 13.3 13.6 smaller
minmax <- c(min(min(shoes$A), min(shoes$B)), max(max(shoes$A), max(shoes$B)))
> minmax
[1] 6.4 14.3
So your parallel coordinates plot will show only the top and bottom entries in "red". In other words: Your solution is correct.
I'm not sure if I'm getting this straight, but your condition A > B
is only true for the maximum and minimum of shoes
.
shoes <- within(shoes, criterium <- ifelse(A > B, "bigger", "smaller"))
A B criterium
1 13.2 14.0 smaller
2 8.2 8.8 smaller
3 10.9 11.2 smaller
4 14.3 14.2 bigger
5 10.7 11.8 smaller
6 6.6 6.4 bigger
7 9.5 9.8 smaller
8 10.8 11.3 smaller
9 8.8 9.3 smaller
10 13.3 13.6 smaller
minmax <- c(min(min(shoes$A), min(shoes$B)), max(max(shoes$A), max(shoes$B)))
> minmax
[1] 6.4 14.3
So your parallel coordinates plot will show only the top and bottom entries in "red". In other words: Your solution is correct.
edited Mar 27 at 9:29
answered Mar 27 at 6:59
HumpelstielzchenHumpelstielzchen
3,6302 gold badges5 silver badges26 bronze badges
3,6302 gold badges5 silver badges26 bronze badges
Chapeaux @Humpelstielzchen! Looks like I chose an unfortunate example for my paired t-test analysis and plot. You've shown me that the two A>B rows are a very small difference, making them appear as nearly straight lines. I think I can still salvage a pedagogically valuable plot by highlighting one of the pairs. Maybe all pairs plotted in light gray except one pair shown in black—probably point 5, the largest difference—which illustrates what the plot shows, but isn't as boring as the default, all-black plot.
– Sciolism Apparently
Mar 27 at 17:48
add a comment |
Chapeaux @Humpelstielzchen! Looks like I chose an unfortunate example for my paired t-test analysis and plot. You've shown me that the two A>B rows are a very small difference, making them appear as nearly straight lines. I think I can still salvage a pedagogically valuable plot by highlighting one of the pairs. Maybe all pairs plotted in light gray except one pair shown in black—probably point 5, the largest difference—which illustrates what the plot shows, but isn't as boring as the default, all-black plot.
– Sciolism Apparently
Mar 27 at 17:48
Chapeaux @Humpelstielzchen! Looks like I chose an unfortunate example for my paired t-test analysis and plot. You've shown me that the two A>B rows are a very small difference, making them appear as nearly straight lines. I think I can still salvage a pedagogically valuable plot by highlighting one of the pairs. Maybe all pairs plotted in light gray except one pair shown in black—probably point 5, the largest difference—which illustrates what the plot shows, but isn't as boring as the default, all-black plot.
– Sciolism Apparently
Mar 27 at 17:48
Chapeaux @Humpelstielzchen! Looks like I chose an unfortunate example for my paired t-test analysis and plot. You've shown me that the two A>B rows are a very small difference, making them appear as nearly straight lines. I think I can still salvage a pedagogically valuable plot by highlighting one of the pairs. Maybe all pairs plotted in light gray except one pair shown in black—probably point 5, the largest difference—which illustrates what the plot shows, but isn't as boring as the default, all-black plot.
– Sciolism Apparently
Mar 27 at 17:48
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368915%2fcan-i-assign-colors-to-massparcoord-based-on-a-logical-condition%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown