下面是我的df
我无法弄清楚如何仅在每个区域和扇区内对数字列进行基本操作 我想(max(区域中的Colonne 3和X的扇区) - 例如X
我用
开始了我的代码df2<-
df1 %>%
groupe_by(Region,Sector) %>%
但是我不知道如何在所有其他列上进行操作
答案 0 :(得分:0)
对于这个“Colonne 3”,我认为它是第4列。
df2=df1 %>% group_by(Region,Sector) %>%slice(which.max(BEST_EPS_YOY_GTH))
答案 1 :(得分:0)
对不起,我没有找到如何分享我的df ... 在下面,只是我的df的第一列 我想要计算并保存在新的df中的是例如第一行:
max(BEST_EPS_YOY_GTH,如果Region = Japan&amp;&amp; Sector =医疗保健) - (-0.12543111)
第二行: max(BEST_EPS_YOY_GTH,如果Region = The Americas&amp;&amp; Sector = Consumer discretionary) - (0.02846056)
并为我所有其他列中的所有行执行此操作(我有12个像BEST_EPS_YOY_GTH
不确定它是否清楚,但非常感谢您的帮助。
<html><style><!--
/* Font Definitions */
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"\@MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:"Lucida Console";
panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"Pr\00E9format\00E9 HTML Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Texte de bulles Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.TextedebullesCar
{mso-style-name:"Texte de bulles Car";
mso-style-priority:99;
mso-style-link:"Texte de bulles";
font-family:"Tahoma","sans-serif";}
span.PrformatHTMLCar
{mso-style-name:"Pr\00E9format\00E9 HTML Car";
mso-style-priority:99;
mso-style-link:"Pr\00E9format\00E9 HTML";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>Ticker Sector Region BEST_EPS_YOY_GTH<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>A US Equity A US Equity Health Care Japan -0.12543111<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>AAP US Equity AAP US Equity Consumer Discretionary The Americas 0.02846056<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>ABBV US Equity ABBV US Equity Health Care The Americas -0.03884949<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>ABT US Equity ABT US Equity Health Care The Americas -0.15789776<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>ACN US Equity ACN US Equity Information Technology The Americas -0.19914068<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>ADBE US Equity ADBE US Equity Information Technology The Americas 0.14954818<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>AEM CN Equity AEM CN Equity Materials Japan 0.12508785<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>AES US Equity AES US Equity Utilities The Americas -0.06861536<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>AET US Equity AET US Equity Health Care The Americas -0.17615952<o:p></o:p></span></p><p class=MsoNormal style='line-height:10.25pt;background:#0B0A09;word-break:break-all'><span lang=EN-US style='font-size:10.0pt;font-family:"Lucida Console";color:#FCFFE0'>AFL US Equity AFL US Equity Financials Asia Pacific -0.31764175<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>
&#13;