naja
December 13, 2019, 12:50pm
1
Hi there!
I have a matrix showing percentage values of people who have paid their bills, i want to convert these values so that the percentages of people who have not paid their bill is shown instead. In this way if a cell says 0.72 then I want it to change that cell to 0.28.
The data looks as follows
I know this is probably an easy fix, but i'm having some trouble and hoping someone kind will help
hi @naja
It more easy to help with a REProductible EXample. see here:
Why reprex?
Getting unstuck is hard. Your first step here is usually to create a reprex, or reproducible example. The goal of a reprex is to package your code, and information about your problem so that others can run it and feel your pain. Then, hopefully, folks can more easily provide a solution.
What's in a Reproducible Example?
Parts of a reproducible example:
background information - Describe what you are trying to do. What have you already done?
complete set up - include any library() calls and data to reproduce your issue.
data for a reprex: Here's a discussion on setting up data for a reprex
make it run - include the minimal code required to reproduce your error on the dataβ¦
I test with an example of 2*2 numeric matrix. I've just done 1 - mymatrix
mat <- matrix(c(0.9,0.7,0.3,0.4), nrow = 2)
mat
#> [,1] [,2]
#> [1,] 0.9 0.3
#> [2,] 0.7 0.4
1-mat
#> [,1] [,2]
#> [1,] 0.1 0.7
#> [2,] 0.3 0.6
Created on 2019-12-13 by the reprex package (v0.3.0)
Hope it help
2 Likes
naja
December 13, 2019, 1:19pm
3
Rodrigue:
1-mat
Thank you! that was an easy fix indeed!
If your issue solve can u mark the solution please. (see the faq below)
Having questions checked as resolved makes it a bit easier to navigate the site visually and see which threads still need help.
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( β’β’β’ ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
β¦
1 Like
system
Closed
December 20, 2019, 1:23pm
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.