Select a variable in data frame

Hello,

I'm working on a code about crude oil tank contents on Rstudio. In the first part of the code, I need to select two tanks that are open for charging from the data frame of "sarjacikunitelistesi(opentankforcharging)" and write a condition.For example;
For ( opentanks=TK110&TK112) { (conditions)

But I couldnt how can i do this loop ?

A for loop is probably not a good way to do what you want to do. Can you explain how you want to change the column TK110 and TK112? Can you post your data or a small part of it? The command

dput(head(sarjacikunitelistesi))

will give output that will allow other people to work with the first six rows of your data (if sarjacikunitelistesi is the name of your data frame). Please paste the output of that function between lines with three back ticks.
```
Your output
```

Firstly thanks for kindly reply. I have an excel in my project about which tanks are open on a daily basis that I added to my code first. I collected this data in a data.frame called "sarjaacikunitelistesi". In the image I attached, you can see that Tank110 and Tank111 are on for charging for plants 2-5 and 25. First of all, I wrote the following code to determine which tank is open for charging for which unit( Columns that read only "PLT 2 + 5 + 25")

kyenj5 <- which(str_detect(sarjaacikunitelistesi, "Y.ENJ." ) & (str_detect(sarjaacikunitelistesi, "\\+5") | str_detect(sarjaacikunitelistesi, " 5")))
keenj5 <- which(str_detect(sarjaacikunitelistesi, "E.ENJ." ) & (str_detect(sarjaacikunitelistesi, "\\+5") | str_detect(sarjaacikunitelistesi, " 5")))
ksenj5 <- which(str_detect(sarjaacikunitelistesi, "SLOP" ) & (str_detect(sarjaacikunitelistesi, "\\+5") | str_detect(sarjaacikunitelistesi, " 5")))
ksarj5 <- which(str_detect(sarjaacikunitelistesi, "\\+5") | str_detect(sarjaacikunitelistesi, " 5") )


if(length(ksenj5)!=0){
  kyenj5 <- subset(kyenj5, kyenj5!= ksenj5)
  keenj5 <- subset(keenj5, keenj5!= ksenj5)
  ksarj5 <- subset(ksarj5,ksarj5!=ksenj5)
  
}

if(length(kyenj5)!=0){
  ksarj5 <- subset(ksarj5,ksarj5!=kyenj5)
}

if(length(keenj5)!=0){
  ksarj5 <- subset(ksarj5,ksarj5!=keenj5)
}

Then the output ksarj5 was " [1] 7 8 " . What I want to do is; writing different cases for the open status of two tanks from all tanks and when I run the whole code, it finds the case of which tank is open and shows me those results.

For example if TK 110 and TK111 is open,this case will happen.

for (i in sarjaacikunitelistesi[1,7]) {
  for (j in sarjaacikunitelistesi[1,8]) {
    if (TK111Flowrevv > (Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]) + (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])) {
    
    hesap2$Şarjdakioran <- ((tk111icerik)*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])*100 }

    else {
    hesap2$Şarjdakioran <- (tk111den2yeicerik+tk110dan2yeicerik) / (Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])*100
    
    hesap5$Şarjdakioran <- (tk111den5eicerik+tk110dan5eicerik) / (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])*100 }

  }
}

How can do this loop?

You didn't post your a sample of your data as suggested. You won't get much help unless you do. Have a read:

Thanks for reply. I can't share all of them because my code is too long. I am attaching the code I wrote about the open status of two different tank combinations. What I want to do: when I run the total code with 50 more cases like this, select the case with the open tanks in the code and give me the results of that case. When I run the chucks separately, I find results, but when I run the whole code, it only gives the result of TK117+TK118, which is the last case I wrote. I'm having a problem with where should I add the loop.

#TK111 2-5e gidenden fazlaysa: 2-5'e flowları oranında( Plt2 HP flowu/Plt2+Plt5+Plant25 HP flowu) giderler(içerikler aynı) Plt 5 Şarj hattını kullanır,25e de 110 ve 111içerik toplamından kalanlar gider vana6 yı  kullanarak.


for (i in sarjaacikunitelistesi[1,7]) {
  for (j in sarjaacikunitelistesi[1,8]) {
    if (TK111Flowrevv > (Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]) + (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])) {
    
    hesap2$Şarjdakioran <- ((tk111icerik)*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])*100
    
    hesap5$Şarjdakioran <- ((tk111icerik)*( Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])*100
    
    hesap25$Şarjdakioran <- (tk110icerik+tk111icerik-((((hesap2[1:19,7])*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]))/100)+(((hesap5[1:19,7])* (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))/100)))/(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,])*100 
        
    
    TK111denPlt2ye <- ((tk111icerik)*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))
    TK110danPlt2ye <- 0
    Plt2ToplamOran <- (((tk111icerik)*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant2Flowrev[1,]))*100
    
    TK111denPlt5e <- ((tk111icerik)*( Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))
    TK110danPlt5e <- 0
    Plt5ToplamOran <- (((tk111icerik)*( Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant5Flowrev[1,]))*100
    
    TK111denPlt25e <- (tk111icerik-(((hesap2[1:19,7])*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/100)+(((hesap5[1:19,7])* (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/100))))
    TK110danPlt25e <- (tk110icerik)
    Plt25ToplamOran <- (tk110icerik+tk111icerik-((((hesap2[1:19,7])*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]))/100)+(((hesap5[1:19,7])* (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))/100)))/(Plant25Flowrev[1,])*100
    
    }
  

# TK111 2-5e gidenden az ise: TK111in hepsi 2-5e gider flowları oranında.110un bir kısmı 2-5e,kalanı da 25e gider.
#TK111den2yeicerik= m3 cinsinden Plt2ye giden
#Plt2 HP akışı - tk111den 2ye gelen toplam akış = TK110dan 2ye gelen akış(m3)
#TK110dan 2ye gelen akış(m3) / Tank 110 toplam akışı(m3) * tk110 icerik(m3) = tk110dan gelen hp icerik (m3)
#tk110dan gelen hp içerik+ tk111den2yeicerik / Plt2 toplam hp akışı * 100 = % HP Şarj Hattı içeriği
#25e giden % içerik= tk110içeriği-tk110den2yegiden-tk110den5egiden/toplam Plt25 Şarj Hattı akışı * 100  
  
    else {
    tk111den2yeicerik <- ((tk111icerik)*((Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))))  
    tk111den5eicerik <- ((tk111icerik)*((Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/((Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))))   
    tk110dan2yeicerik <- (as.numeric((Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]-colSums(tk111den2yeicerik))/TK110Flowrevv)*(tk110icerik))
    tk110dan5eicerik <- (as.numeric((Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]-colSums(tk111den5eicerik))/TK110Flowrevv)*(tk110icerik))
    
    hesap2$Şarjdakioran <- (tk111den2yeicerik+tk110dan2yeicerik) / (Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])*100
    
    hesap5$Şarjdakioran <- (tk111den5eicerik+tk110dan5eicerik) / (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])*100
   
    hesap25$Şarjdakioran <- ((tk110icerik-(tk110dan2yeicerik +tk110dan5eicerik))/(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]))*100 
                                    
    
    TK111denPlt2ye <- (tk111den2yeicerik)
    TK110danPlt2ye <- (tk110dan2yeicerik)
    Plt2ToplamOran <- (tk111den2yeicerik+tk110dan2yeicerik) / (Plant2Flowrev[1,])*100
    
    TK111denPlt5e <- (tk111den5eicerik)
    TK110danPlt5e <- (tk110dan5eicerik)
    Plt5ToplamOran <- (tk111den5eicerik+tk110dan5eicerik) / (Plant5Flowrev[1,])*100
    
    TK111denPlt25e <- 0
    TK110danPlt25e <- (tk110icerik-(tk110dan2yeicerik+tk110dan5eicerik))
    Plt25ToplamOran <- (tk110icerik-(tk110dan2yeicerik+tk110dan5eicerik))/(Plant25Flowrev[1,])*100 }

    
    
hesap2son <-data.frame("CrudeName"=c(hesap2$CrudeName), "TK110dan Plt2ye İcerik(m3)"=c(TK110danPlt2ye), "TK111den Plt2ye İcerik(m3)"=c(TK111denPlt2ye), "% Şarj Hattı Akışındaki Oran"=c(hesap2$Şarjdakioran), "% Plant2 Toplam Şarjdaki Oran"=c(Plt2ToplamOran))
colnames(hesap2son)<-c("Crude Name","TK110dan Plt2ye İcerik(m3)","TK111den Plt2ye İcerik(m3)","% Şarj Hattı Akışındaki Oran","% Plant2 Toplam Şarjdaki Oran")
hesap5son <-data.frame("CrudeName"=c(hesap2$CrudeName),"TK110dan Plt5e İcerik(m3)"=c(TK110danPlt5e), "TK111den Plt5e İcerik(m3)"=c(TK111denPlt5e), "% Şarj Hattı Akışındaki Oran"=c(hesap5$Şarjdakioran), "% Plant5 Toplam Şarjdaki Oran"=c(Plt5ToplamOran))
colnames(hesap5son)<-c("Crude Name","TK110dan Plt5e İcerik(m3)","TK111den Plt5e İcerik(m3)","% Şarj Hattı Akışındaki Oran","% Plant5 Toplam Şarjdaki Oran")
hesap25son <-data.frame("CrudeName"=c(hesap2$CrudeName),"TK110dan Plt25e İcerik(m3)"=c(TK110danPlt25e), "TK111den Plt25e İcerik(m3)"=c(TK111denPlt25e), "% Şarj Hattı Akışındaki Oran"=c(hesap25$Şarjdakioran), "% Plant25 Toplam Şarjdaki Oran"=c(Plt25ToplamOran))
colnames(hesap25son)<-c("Crude Name","TK110dan Plt25e İcerik(m3)","TK111denPlt25e İcerik(m3)","% Şarj Hattı Akışındaki Oran","% Plant25 Toplam Şarjdaki Oran")

hesap2son <- hesap2son[order(-hesap2son$`% Şarj Hattı Akışındaki Oran`),]
hesap2son <- hesap2son[rowSums(hesap2son[,2:5])>0,] 
hesap2son <-round_df(hesap2son,2,rf="round")
hesap5son <- hesap5son[order(-hesap5son$`% Şarj Hattı Akışındaki Oran`),]
hesap5son <- hesap5son[rowSums(hesap5son[,2:5])>0,]
hesap5son <- round_df(hesap5son,2,rf="round")
hesap25son <- hesap25son[order(-hesap25son$`% Şarj Hattı Akışındaki Oran`),] 
hesap25son <- hesap25son[rowSums(hesap25son[,2:5])>0,]
hesap25son <- round_df(hesap25son,2,rf="round")
  }
}  

#Bu durumu günlük takip excelinde göremedim?

#TK112 2-5e gidenden fazlaysa: 2-5'e flowları oranında( Plt2 HP flowu/Plt2+Plt5+Plant25 HP flowu) giderler(içerikler aynı) Plt 5 Şarj hattını kullanır,25e de 110 ve 112içerik toplamından kalanlar gider vana6 yı  kullanarak.


for (i in sarjaacikunitelistesi[1,7]) {
  for (j in sarjaacikunitelistesi[1,9]) {
    if (TK112Flowrevv > (Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]) + (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])) {
    
    hesap2$Şarjdakioran <- ((tk112icerik)*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])*100
    
    hesap5$Şarjdakioran <- ((tk112icerik)*( Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])*100
    
    hesap25$Şarjdakioran <- (tk110icerik+tk112icerik-((((hesap2[1:19,7])*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]))/100)+(((hesap5[1:19,7])* (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))/100)))/(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,])*100 
           
    
    TK112denPlt2ye <- ((tk112icerik)*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))
    TK110danPlt2ye <- 0
    Plt2ToplamOran <- (((tk112icerik)*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant2Flowrev[1,]))*100
    
    TK112denPlt5e <- ((tk112icerik)*( Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))
    TK110danPlt5e <- 0
    Plt5ToplamOran <- (((tk112icerik)*( Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])+(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]-colSums(tk110icerik))))/(Plant5Flowrev[1,]))*100
    
    TK112denPlt25e <- (tk112icerik-(((hesap2[1:19,7])*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/100)+(((hesap5[1:19,7])* (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/100))))
    TK110danPlt25e <- (tk110icerik)
    Plt25ToplamOran <- (tk110icerik+tk112icerik-((((hesap2[1:19,7])*(Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]))/100)+(((hesap5[1:19,7])* (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))/100)))/(Plant25Flowrev[1,])*100 
    
    }
  

# TK112 2-5e gidenden az ise: TK112in hepsi 2-5e gider flowları oranında.110un bir kısmı 2-5e,kalanı da 25e gider.
#TK112den2yeicerik= m3 cinsinden Plt2ye giden
#Plt2 HP akışı - tk112den 2ye gelen toplam akış = TK110dan 2ye gelen akış(m3)
#TK110dan 2ye gelen akış(m3) / Tank 110 toplam akışı(m3) * tk110 icerik(m3) = tk110dan gelen hp icerik (m3)
#tk110dan gelen hp içerik+ tk112den2yeicerik / Plt2 toplam hp akışı * 100 = % HP Şarj Hattı içeriği
#25e giden % içerik= tk110içeriği-tk110den2yegiden-tk110den5egiden/toplam Plt25 Şarj Hattı akışı * 100  
  
    else {
    tk112den2yeicerik <- ((tk112icerik)*((Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])/(( Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))))  
    tk112den5eicerik <- ((tk112icerik)*((Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])/((Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])+(Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]))))   
    tk110dan2yeicerik <- (as.numeric((Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,]-colSums(tk112den2yeicerik))/TK110Flowrevv)*(tk110icerik))
    tk110dan5eicerik <- (as.numeric((Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,]-colSums(tk112den5eicerik))/TK110Flowrevv)*(tk110icerik))
    
    hesap2$Şarjdakioran <- (tk112den2yeicerik+tk110dan2yeicerik) / (Plant2Flowrev[1,]-EnjFlowlar[,1]-EnjFlowlar[,2]-Plant2Flowrev[8,])*100
    
    hesap5$Şarjdakioran <- (tk112den5eicerik+tk110dan5eicerik) / (Plant5Flowrev[1,]-EnjFlowlar[,3]-EnjFlowlar[,4]-Plant5Flowrev[8,])*100
   
    hesap25$Şarjdakioran <- ((tk110icerik-(tk110dan2yeicerik+tk110dan5eicerik))/(Plant25Flowrev[1,]-EnjFlowlar[,5]-EnjFlowlar[,6]-Plant25Flowrev[8,]))*100 
                                        
    
    TK112denPlt2ye <- (tk112den2yeicerik)
    TK110danPlt2ye <- (tk110dan2yeicerik)
    Plt2ToplamOran <- (tk112den2yeicerik+tk110dan2yeicerik) / (Plant2Flowrev[1,])*100
    
    TK112denPlt5e <- (tk112den5eicerik)
    TK110danPlt5e <- (tk110dan5eicerik)
    Plt5ToplamOran <- (tk112den5eicerik+tk110dan5eicerik) / (Plant5Flowrev[1,])*100
    
    TK112denPlt25e <- 0
    TK110danPlt25e <- (tk110icerik-(tk110dan2yeicerik+tk110dan5eicerik))
    Plt25ToplamOran <- (tk110icerik-(tk110dan2yeicerik+tk110dan5eicerik))/(Plant25Flowrev[1,])*100 }

    
    
hesap2son <-data.frame("CrudeName"=c(hesap2$CrudeName), "TK110dan Plt2ye İcerik(m3)"=c(TK110danPlt2ye), "TK112den Plt2ye İcerik(m3)"=c(TK112denPlt2ye), "% Şarj Hattı Akışındaki Oran"=c(hesap2$Şarjdakioran), "% Plant2 Toplam Şarjdaki Oran"=c(Plt2ToplamOran))
colnames(hesap2son)<-c("Crude Name","TK110dan Plt2ye İcerik(m3)","TK112den Plt2ye İcerik(m3)","% Şarj Hattı Akışındaki Oran","% Plant2 Toplam Şarjdaki Oran")
hesap5son <-data.frame("CrudeName"=c(hesap2$CrudeName),"TK110dan Plt5e İcerik(m3)"=c(TK110danPlt5e), "TK112den Plt5e İcerik(m3)"=c(TK112denPlt5e), "% Şarj Hattı Akışındaki Oran"=c(hesap5$Şarjdakioran), "% Plant2 Toplam Şarjdaki Oran"=c(Plt5ToplamOran))
colnames(hesap5son)<-c("Crude Name","TK110dan Plt5e İcerik(m3)","TK112denPlt5e İcerik(m3)","% Şarj Hattı Akışındaki Oran","% Plant5 Toplam Şarjdaki Oran")
hesap25son <-data.frame("CrudeName"=c(hesap2$CrudeName),"TK110dan Plt25e İcerik(m3)"=c(TK110danPlt25e), "TK112den Plt25e İcerik(m3)"=c(TK112denPlt25e), "% Şarj Hattı Akışındaki Oran"=c(hesap25$Şarjdakioran), "% Plant2 Toplam Şarjdaki Oran"=c(Plt25ToplamOran))
colnames(hesap25son)<-c("Crude Name","TK110dan Plt25e İcerik(m3)","TK112denPlt25e İcerik(m3)","% Şarj Hattı Akışındaki Oran","% Plant25 Toplam Şarjdaki Oran")

hesap2son <- hesap2son[order(-hesap2son$`% Şarj Hattı Akışındaki Oran`),]
hesap2son <- hesap2son[rowSums(hesap2son[,2:5])>0,] 
hesap2son <-round_df(hesap2son,2,rf="round")
hesap5son <- hesap5son[order(-hesap5son$`% Şarj Hattı Akışındaki Oran`),]
hesap5son <- hesap5son[rowSums(hesap5son[,2:5])>0,]
hesap5son <- round_df(hesap5son,2,rf="round")
hesap25son <- hesap25son[order(-hesap25son$`% Şarj Hattı Akışındaki Oran`),] 
hesap25son <- hesap25son[rowSums(hesap25son[,2:5])>0,]
hesap25son <- round_df(hesap25son,2,rf="round")


  }
}  

We dont have sarjaacikunitelistesi. You don't have to share all your code. Only a sample.

Firstly I import an excel document about tank contents and which thanks are open. I made this data into a organized dataframe named "islenenHPlistesi". I am sharing that. The last line of this data.frame is "sarjaacikuniteliste"

sarjaacikunitelistesi <- tail(islenenHPlistesi, 1)

No. Read the article. Code, not screenshots.

Sorry.I am sharing.

islenenHP<- read_excel("C:/Users/10486/Desktop/Çalışma kaynakları/mail.xls")

islenenHPlistesi<-data.frame("CrudeName"=c(as.character(islenenHP[12,1]),as.character(islenenHP[13,1]),as.character(islenenHP[14,1]),as.character(islenenHP[15,1]),as.character(islenenHP[16,1]),as.character(islenenHP[17,1]),as.character(islenenHP[18,1]),as.character(islenenHP[19,1]),as.character(islenenHP[20,1]),as.character(islenenHP[21,1]),as.character(islenenHP[22,1]),as.character(islenenHP[23,1]),as.character(islenenHP[24,1]),as.character(islenenHP[25,1]),as.character(islenenHP[26,1]),as.character(islenenHP[27,1]),as.character(islenenHP[28,1]),as.character(islenenHP[29,1]),as.character(islenenHP[30,1]),"Sarja acik unite"),
                             
                             "TK-104"=c(as.character(islenenHP[12,3]),as.character(islenenHP[13,3]),as.character(islenenHP[14,3]),as.character(islenenHP[15,3]),as.character(islenenHP[16,3]),as.character(islenenHP[17,3]),as.character(islenenHP[18,3]),as.character(islenenHP[19,3]),as.character(islenenHP[20,3]),as.character(islenenHP[21,3]),as.character(islenenHP[22,3]),as.character(islenenHP[23,3]),as.character(islenenHP[24,3]),as.character(islenenHP[25,3]),as.character(islenenHP[26,3]),as.character(islenenHP[27,3]),as.character(islenenHP[28,3]),as.character(islenenHP[29,3]),as.character(islenenHP[30,3]),as.character(islenenHP[10,2])),

                             "TK-105"=c(as.character(islenenHP[12,5]),as.character(islenenHP[13,5]),as.character(islenenHP[14,5]),as.character(islenenHP[15,5]),as.character(islenenHP[16,5]),as.character(islenenHP[17,5]),as.character(islenenHP[18,5]),as.character(islenenHP[19,5]),as.character(islenenHP[20,5]),as.character(islenenHP[21,5]),as.character(islenenHP[22,5]),as.character(islenenHP[23,5]),as.character(islenenHP[24,5]),as.character(islenenHP[25,5]),as.character(islenenHP[26,5]),as.character(islenenHP[27,5]),as.character(islenenHP[28,5]),as.character(islenenHP[29,5]),as.character(islenenHP[30,5]),as.character(islenenHP[10,4])),
                             
                             "TK-106"=c(as.character(islenenHP[12,7]),as.character(islenenHP[13,7]),as.character(islenenHP[14,7]),as.character(islenenHP[15,7]),as.character(islenenHP[16,7]),as.character(islenenHP[17,7]),as.character(islenenHP[18,7]),as.character(islenenHP[19,7]),as.character(islenenHP[20,7]),as.character(islenenHP[21,7]),as.character(islenenHP[22,7]),as.character(islenenHP[23,7]),as.character(islenenHP[24,7]),as.character(islenenHP[25,7]),as.character(islenenHP[26,7]),as.character(islenenHP[27,7]),as.character(islenenHP[28,7]),as.character(islenenHP[29,7]),as.character(islenenHP[30,7]),as.character(islenenHP[10,6])),
                             
                             "TK-107"=c(as.character(islenenHP[12,9]),as.character(islenenHP[13,9]),as.character(islenenHP[14,9]),as.character(islenenHP[15,9]),as.character(islenenHP[16,9]),as.character(islenenHP[17,9]),as.character(islenenHP[18,9]),as.character(islenenHP[19,9]),as.character(islenenHP[20,9]),as.character(islenenHP[21,9]),as.character(islenenHP[22,9]),as.character(islenenHP[23,9]),as.character(islenenHP[24,9]),as.character(islenenHP[25,9]),as.character(islenenHP[26,9]),as.character(islenenHP[27,9]),as.character(islenenHP[28,9]),as.character(islenenHP[29,9]),as.character(islenenHP[30,9]),as.character(islenenHP[10,8])),
                             
                             "TK-108"=c(as.character(islenenHP[12,11]),as.character(islenenHP[13,11]),as.character(islenenHP[14,11]),as.character(islenenHP[15,11]),as.character(islenenHP[16,11]),as.character(islenenHP[17,11]),as.character(islenenHP[18,11]),as.character(islenenHP[19,11]),as.character(islenenHP[20,11]),as.character(islenenHP[21,11]),as.character(islenenHP[22,11]),as.character(islenenHP[23,11]),as.character(islenenHP[24,11]),as.character(islenenHP[25,11]),as.character(islenenHP[26,11]),as.character(islenenHP[27,11]),as.character(islenenHP[28,11]),as.character(islenenHP[29,11]),as.character(islenenHP[30,11]),as.character(islenenHP[10,10])),

                             "TK-110"=c(as.character(islenenHP[12,13]),as.character(islenenHP[13,13]),as.character(islenenHP[14,13]),as.character(islenenHP[15,13]),as.character(islenenHP[16,13]),as.character(islenenHP[17,13]),as.character(islenenHP[18,13]),as.character(islenenHP[19,13]),as.character(islenenHP[20,13]),as.character(islenenHP[21,13]),as.character(islenenHP[22,13]),as.character(islenenHP[23,13]),as.character(islenenHP[24,13]),as.character(islenenHP[25,13]),as.character(islenenHP[26,13]),as.character(islenenHP[27,13]),as.character(islenenHP[28,13]),as.character(islenenHP[29,13]),as.character(islenenHP[30,13]),as.character(islenenHP[10,12])),
                             
                             "TK-111"=c(as.character(islenenHP[12,15]),as.character(islenenHP[13,15]),as.character(islenenHP[14,15]),as.character(islenenHP[15,15]),as.character(islenenHP[16,15]),as.character(islenenHP[17,15]),as.character(islenenHP[18,15]),as.character(islenenHP[19,15]),as.character(islenenHP[20,15]),as.character(islenenHP[21,15]),as.character(islenenHP[22,15]),as.character(islenenHP[23,15]),as.character(islenenHP[24,15]),as.character(islenenHP[25,15]),as.character(islenenHP[26,15]),as.character(islenenHP[27,15]),as.character(islenenHP[28,15]),as.character(islenenHP[29,15]),as.character(islenenHP[30,15]),as.character(islenenHP[10,14])),

                             "TK-112"=c(as.character(islenenHP[12,17]),as.character(islenenHP[13,17]),as.character(islenenHP[14,17]),as.character(islenenHP[15,17]),as.character(islenenHP[16,17]),as.character(islenenHP[17,17]),as.character(islenenHP[18,17]),as.character(islenenHP[19,17]),as.character(islenenHP[20,17]),as.character(islenenHP[21,17]),as.character(islenenHP[22,17]),as.character(islenenHP[23,17]),as.character(islenenHP[24,17]),as.character(islenenHP[25,17]),as.character(islenenHP[26,17]),as.character(islenenHP[27,17]),as.character(islenenHP[28,17]),as.character(islenenHP[29,17]),as.character(islenenHP[30,17]),as.character(islenenHP[10,16])),

                             "TK-113"=c(as.character(islenenHP[48,3]),as.character(islenenHP[49,3]),as.character(islenenHP[50,3]),as.character(islenenHP[51,3]),as.character(islenenHP[52,3]),as.character(islenenHP[53,3]),as.character(islenenHP[54,3]),as.character(islenenHP[55,3]),as.character(islenenHP[56,3]),as.character(islenenHP[57,3]),as.character(islenenHP[58,3]),as.character(islenenHP[59,3]),as.character(islenenHP[60,3]),as.character(islenenHP[61,3]),as.character(islenenHP[62,3]),as.character(islenenHP[63,3]),as.character(islenenHP[64,3]),as.character(islenenHP[65,3]),as.character(islenenHP[66,3]),as.character(islenenHP[46,2])),

                             "TK-114"=c(as.character(islenenHP[48,5]),as.character(islenenHP[49,5]),as.character(islenenHP[50,5]),as.character(islenenHP[51,5]),as.character(islenenHP[52,5]),as.character(islenenHP[53,5]),as.character(islenenHP[54,5]),as.character(islenenHP[55,5]),as.character(islenenHP[56,5]),as.character(islenenHP[57,5]),as.character(islenenHP[58,5]),as.character(islenenHP[59,5]),as.character(islenenHP[60,5]),as.character(islenenHP[61,5]),as.character(islenenHP[62,5]),as.character(islenenHP[63,5]),as.character(islenenHP[64,5]),as.character(islenenHP[65,5]),as.character(islenenHP[66,5]),as.character(islenenHP[46,4])),
                             
                             "TK-115"=c(as.character(islenenHP[48,7]),as.character(islenenHP[49,7]),as.character(islenenHP[50,7]),as.character(islenenHP[51,7]),as.character(islenenHP[52,7]),as.character(islenenHP[53,7]),as.character(islenenHP[54,7]),as.character(islenenHP[55,7]),as.character(islenenHP[56,7]),as.character(islenenHP[57,7]),as.character(islenenHP[58,7]),as.character(islenenHP[59,7]),as.character(islenenHP[60,7]),as.character(islenenHP[61,7]),as.character(islenenHP[62,7]),as.character(islenenHP[63,7]),as.character(islenenHP[64,7]),as.character(islenenHP[65,7]),as.character(islenenHP[66,7]),as.character(islenenHP[46,6])),
                             
                             "TK-116"=c(as.character(islenenHP[48,9]),as.character(islenenHP[49,9]),as.character(islenenHP[50,9]),as.character(islenenHP[51,9]),as.character(islenenHP[52,9]),as.character(islenenHP[53,9]),as.character(islenenHP[54,9]),as.character(islenenHP[55,9]),as.character(islenenHP[56,9]),as.character(islenenHP[57,9]),as.character(islenenHP[58,9]),as.character(islenenHP[59,9]),as.character(islenenHP[60,9]),as.character(islenenHP[61,9]),as.character(islenenHP[62,9]),as.character(islenenHP[63,9]),as.character(islenenHP[64,9]),as.character(islenenHP[65,9]),as.character(islenenHP[66,9]),as.character(islenenHP[46,8])),
                             
                             "TK-117"=c(as.character(islenenHP[48,11]),as.character(islenenHP[49,11]),as.character(islenenHP[50,11]),as.character(islenenHP[51,11]),as.character(islenenHP[52,11]),as.character(islenenHP[53,11]),as.character(islenenHP[54,11]),as.character(islenenHP[55,11]),as.character(islenenHP[56,11]),as.character(islenenHP[57,11]),as.character(islenenHP[58,11]),as.character(islenenHP[59,11]),as.character(islenenHP[60,11]),as.character(islenenHP[61,11]),as.character(islenenHP[62,11]),as.character(islenenHP[63,11]),as.character(islenenHP[64,11]),as.character(islenenHP[65,11]),as.character(islenenHP[66,11]),as.character(islenenHP[46,10])),
                             
                             "TK-118"=c(as.character(islenenHP[48,13]),as.character(islenenHP[49,13]),as.character(islenenHP[50,13]),as.character(islenenHP[51,13]),as.character(islenenHP[52,13]),as.character(islenenHP[53,13]),as.character(islenenHP[54,13]),as.character(islenenHP[55,13]),as.character(islenenHP[56,13]),as.character(islenenHP[57,13]),as.character(islenenHP[58,13]),as.character(islenenHP[59,13]),as.character(islenenHP[60,13]),as.character(islenenHP[61,13]),as.character(islenenHP[62,13]),as.character(islenenHP[63,13]),as.character(islenenHP[64,13]),as.character(islenenHP[65,13]),as.character(islenenHP[66,13]),as.character(islenenHP[46,12])))

islenenHPlistesirev <- head(islenenHPlistesi, 19)
sarjaacikunitelistesi <- tail(islenenHPlistesi, 1)

We don't have this file.