percentage

change value to percentage of row in R [duplicate]

吃可爱长大的小学妹 提交于 2019-11-28 13:40:43
This question already has an answer here: Calculate row-wise proportions 4 answers this is my data A B C A 9 1 0 B 2 2 2 C 3 3 3 I want to get percentage of each row my expect data is A B C A 0.9 0.1 0 B 0.33 0.33 0.33 C 0.33 0.33 0.33 I made my data with 'dcast' and there is column name on A,B and C. so actually my real data is Name A B C 1 A 0.9 0.1 0 2 B 0.33 0.33 0.33 3 C 0.33 0.33 0.33 Seems a fair case for df/rowSums(df) # A B C # A 0.9000000 0.1000000 0.0000000 # B 0.3333333 0.3333333 0.3333333 # C 0.3333333 0.3333333 0.3333333 If you don't want so many digits after the dot set options

calculating in jtable with %, total

匆匆过客 提交于 2019-11-28 12:56:17
问题 I am almost at the end of my project and have some problems solving it. I m a chef who wants his own application what is relevant for his own bussines My form is called Recipes and have Qty unitprice, % used. So lets say, you have 1kg apples for 5 euro. At the end of cleaning you just have 800 grams of apples. So i have paid 20 percent more. example Item is always 100%, Qty 5, Unitprice 5, Used% 100% total = 25 Qty 5, Unitprice 5, Used% 70%, Total= 32.5 ( must increase with 30 percent) At the

Is it allowed to use any decimal value in CSS keyframe animations?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 09:49:09
I'm wondering if it's ok to use percentage values like this: @keyframes myAnimation { 0% { height: 100px; } 33.3% { height: 120px; } 66.6% { height: 140px; } 100% { height: 200px; } } It seems to work, but it I am not sure if the browsers might just "round" this? And what about values like 33.3457%? Thanks a lot! When it comes to CSS it takes notice of percentages down to 2 decimal places and then stops. So you would be able to get 33.34% but not 33.3457% for use in your keyframes I hope this helps. Yes, you can use fractional part to define more precise keyframes percentages. But such

Format number as percent in MS SQL Server

冷暖自知 提交于 2019-11-28 06:48:27
I am trying to simply format a number as a percent with two decimal places. If it is 37 divided by 38 (aka .973684210526315789), I would like it to show 97.36 % in the SQL output. I know it is recommended to do formatting in the Application, however this is for an automated export. This is using SQL Server 2008. Here is what I have now: select CONVERT(VARCHAR(50),cast(37 as decimal)/cast(38 as decimal)*100)+' %' AS [%] If you could explain what the various parameters are as well in any function that would be helpful. M.Ali's answer could be modified as select Cast(Cast((37.0/38.0)*100 as

Showing percentage in bars in ggplot

…衆ロ難τιáo~ 提交于 2019-11-28 06:47:14
问题 I have a dataset with binary variables like the one below. M4 = matrix(sample(1:2,20*5, replace=TRUE),20,5) M4 <- as.data.frame(M4) M4$id <- 1:20 I have produced a stacked bar plot using the code below library(reshape) library(ggplot2) library(scales) M5 <- melt(M4, id="id") M5$value <- as.factor(M5$value) ggplot(M5, aes(x = variable)) + geom_bar(aes(fill = value), position = 'fill') + scale_y_continuous(labels = percent_format()) Now I want the percentage for each field in each bar to be

Regular expression to match a percentage with decimal?

倖福魔咒の 提交于 2019-11-28 06:05:38
问题 I'm attempting to build a regular expression (.NET) to match a percentage with 4 decimal places. The 4 decimal places are required. The range looks like: 0.0001 to 100.0000 So far, I've come up with: (?:[^0]+[1-100]{1,3})\.(?:\d{4}) However, I'm a bit unsure on how to add a few other requirements to this expression. I need: No leading zeroes before the decimal point. 42.4214 is allowed, 042.4214 is not. 1.0000 is allowed but 001.0000 is not. Etc.. Up to 3 characters allowed before decimal

Translate X and Y percentage values based on elements height and width?

烂漫一生 提交于 2019-11-28 05:36:45
Translating an elements Y axis 50% will move it down 50% of its own height, not 50% of the parents height as I would expect. How do I tell a translating element to base it's translation percentage on the parent element? Or am I not understanding something? http://jsfiddle.net/4wqEm/2/ bowen When using percentage in translate, it refers to width or height of itself. Take a look at https://davidwalsh.name/css-vertical-center ( demo ): One interesting thing about CSS transforms is that, when applying them with percentage values, they base that value on the dimensions of the element which they are

background-position percentage not working [duplicate]

雨燕双飞 提交于 2019-11-28 03:47:06
问题 This question already has an answer here: Using percentage values with background-position on a linear gradient 1 answer Everywhere I read says this should be working fine, but for some reason it's not. This was to fix someone else's issue so fixing it doesn't matter to me, I just want to know why. The problem is on .br .bg-image . I know I'm trying to use calc() but using a simple background-position: 50% doesn't work either. http://jsfiddle.net/uLaa9fnu/2/ html { height: 100%; width: 100%;

How does CSS computation for background percentages work? [duplicate]

ε祈祈猫儿з 提交于 2019-11-28 01:53:27
This question already has an answer here: Using percentage values with background-position on a linear gradient 1 answer I'm currently playing around with CSS gradients and position, I kind of manage to do what I want but with lucky guesses but I'd like to understand how this actually all works. For instance, here's the French flag (merci): .serge_testDraw { width: 10rem; height: 10rem; border: 0.2rem solid black; background-image: linear-gradient(to right, blue 0%, blue 100%) , linear-gradient(to right, white 0%, white 100%) , linear-gradient(to right, red 0%, red 100%) ; background-size:

Percentage Based Probability

折月煮酒 提交于 2019-11-28 00:11:19
问题 I have this code snippet: Random rand = new Random(); int chance = rand.Next(1, 101); if (chance <= 25) // probability of 25% { Console.WriteLine("You win"); } else { Console.WriteLine("You lose"); } My question is, does it really calculate a 25% probability for winning here? Is the chance of winning for the player here is really 25%? Edit: I just wrote this: double total = 0; double prob = 0; Random rnd = new Random(); for (int i = 0; i < 100; i++) { double chance = rnd.Next(1, 101); if