Hello together,
i have a litte problem. Maybe anyone can help me.
I have to calculate a new column in dependence of a target value.
As a example: My target value is 100.000
At the moment I have a data.frame with the following values.
ID VALUE
1 11 10000
2 12 50000
3 13 30000
4 14 20000
The new column ("MARGE") should be calculated with the following
graduation:
Until the VALUE reach 50% of the target value (50.000) = 2%
Until the VALUE reach 75% of the target value (75.000) = 4%
Until the VALUE reach 100% of the target value (<100.000) = 8%
If the VALUE goes above 100% of the value (>100.000) = 10%
The result looks like this one:
ID VALUE MARGE
1 11 10000 200 (result of 10.000 * 2%)
2 12 50000 1200 (result of 40.000 * 2% + 10.000 * 4%)
3 13 30000 1800 (result of 15.000 * 4% + 15.000 * 8%)
4 14 20000 1800 (result of 10.000 * 8% + 10.000 * 10%)
Is there anyway to calculate the column "MARGE" automatically in R?
Thanks a lot for your help.
Best regards.
Mat
________________________________
This e-mail may contain trade secrets, privileged, undisclosed or otherwise
confidential information. If you have received this e-mail in error, you are
hereby notified that any review, copying or distribution of it is strictly
prohibited. Please inform us immediately and destroy the original transmittal.
Thank you for your cooperation.
Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich
erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfaeltigung
oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte benachrichtigen Sie
uns und vernichten Sie die empfangene E-Mail. Vielen Dank.
[[alternative HTML version deleted]]
It is very hard to figure out what you are trying to do.
1. All of the VALUEs are greater than the target of 100
2. Your description of what you want does not match your example.
Perhaps VALUE should be divided by 1000 (e.g. not 10000, but 10)?
Perhaps your targets do not apply to VALUE, but to cumulative VALUE?
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Matthias
Weber
Sent: Monday, March 9, 2015 7:46 AM
To: r-help at r-project.org
Subject: [R] calculate value in dependence of target value
Hello together,
i have a litte problem. Maybe anyone can help me.
I have to calculate a new column in dependence of a target value.
As a example: My target value is 100.000
At the moment I have a data.frame with the following values.
ID VALUE
1 11 10000
2 12 50000
3 13 30000
4 14 20000
The new column ("MARGE") should be calculated with the following
graduation:
Until the VALUE reach 50% of the target value (50.000) = 2%
Until the VALUE reach 75% of the target value (75.000) = 4%
Until the VALUE reach 100% of the target value (<100.000) = 8%
If the VALUE goes above 100% of the value (>100.000) = 10%
The result looks like this one:
ID VALUE MARGE
1 11 10000 200 (result of 10.000 * 2%)
2 12 50000 1200 (result of 40.000 * 2% + 10.000 * 4%)
3 13 30000 1800 (result of 15.000 * 4% + 15.000 * 8%)
4 14 20000 1800 (result of 10.000 * 8% + 10.000 * 10%)
Is there anyway to calculate the column "MARGE" automatically in R?
Thanks a lot for your help.
Best regards.
Mat
________________________________
This e-mail may contain trade secrets, privileged, undisclosed or otherwise
confidential information. If you have received this e-mail in error, you are
hereby notified that any review, copying or distribution of it is strictly
prohibited. Please inform us immediately and destroy the original transmittal.
Thank you for your cooperation.
Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich
erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfaeltigung
oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte benachrichtigen Sie
uns und vernichten Sie die empfangene E-Mail. Vielen Dank.
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Hi David,
thanks for the reply. My spelling of the numbers was not correct. What I mean
with 100.000 is 100000.00 !
I have corrected the values in my example below me.
Maybe you can understand it better now.
Crucially is, that the "MARGE" rises up in dependence of the ID. The
ID 11 will be count with 2% because we don't reach the 50% hurdle (50000).
The ID 12 will reach the 50% hurdle, so the ID 12 should be count with 1200
(result of 40000 * 2% + 10000 * 4%). The 10000 with 4% will be credited more,
because they exceed the 50% Target Value.
Thanks for your help.
Best regards.
Mat
-----Urspr?ngliche Nachricht-----
Von: David L Carlson [mailto:dcarlson at tamu.edu]
Gesendet: Montag, 9. M?rz 2015 16:08
An: Matthias Weber; r-help at r-project.org
Betreff: RE: calculate value in dependence of target value
It is very hard to figure out what you are trying to do.
1. All of the VALUEs are greater than the target of 100 2. Your description of
what you want does not match your example.
Perhaps VALUE should be divided by 1000 (e.g. not 10000, but 10)?
Perhaps your targets do not apply to VALUE, but to cumulative VALUE?
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Matthias
Weber
Sent: Monday, March 9, 2015 7:46 AM
To: r-help at r-project.org
Subject: [R] calculate value in dependence of target value
Hello together,
i have a litte problem. Maybe anyone can help me.
I have to calculate a new column in dependence of a target value.
As a example: My target value is 100000. At the moment I have a data.frame with
the following values.
ID VALUE
1 11 10000
2 12 50000
3 13 30000
4 14 20000
The new column ("MARGE") should be calculated with the following
graduation:
Until the VALUE reach 50% of the target value (50000) = 2%
Until the VALUE reach 75% of the target value (75000) = 4%
Until the VALUE reach 100% of the target value (<100000) = 8%
If the VALUE goes above 100% of the value (>100000) = 10%
The result looks like this one:
ID VALUE MARGE
1 11 10000 200 (result of 10000 * 2%)
2 12 50000 1200 (result of 40000 * 2% + 10000 * 4%)
3 13 30000 1800 (result of 15000 * 4% + 15000 * 8%)
4 14 20000 1800 (result of 10000 * 8% + 10000 * 10%)
Is there anyway to calculate the column "MARGE" automatically in R?
Thanks a lot for your help.
Best regards.
Mat
This e-mail may contain trade secrets, privileged, undisclosed or otherwise
confidential information. If you have received this e-mail in error, you are
hereby notified that any review, copying or distribution of it is strictly
prohibited. Please inform us immediately and destroy the original transmittal.
Thank you for your cooperation.
Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich
erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfaeltigung
oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte benachrichtigen Sie
uns und vernichten Sie die empfangene E-Mail. Vielen Dank.