Nome, P1, P2, EP1, EP2, EP3 Andre, 6.5, 7.5, 9.0, 8.7, 7.5 Bel , 5.5, 6.5, 6.8, 7.0, 7.5 Cris, 8.5, 9.5, 10.0, 10.0, 9.5
colP <- function(x){ x[,'P'] <- (x[,2] + x[,3])/2 return(x) }
colEP <- function(x){ x[,'EP'] <- (4*x[,4] + 5*x[,5] + 11*x[,6])/20 return(x) }
dirTrab <- "..." setwd(dirTrab) source(".../Arquivo1.r") source(".../Arquivo2.r") a <- read.csv("notaMac113.csv") print(a) print(" ", quote=F) b <- colP(a) print(b) print(" ", quote=F) c <- colP(b) print(c) print(" ", quote=F)
Nome P1 P2 EP1 EP2 EP3 1 Andre 6.5 7.5 9.0 8.7 7.5 2 Bel 5.5 6.5 6.8 7.0 7.5 3 Cris 8.5 9.5 10.0 10.0 9.5 Nome P1 P2 EP1 EP2 EP3 P 1 Andre 6.5 7.5 9.0 8.7 7.5 9.75 2 Bel 5.5 6.5 6.8 7.0 7.5 5.25 3 Cris 8.5 9.5 10.0 10.0 9.5 9.00 Nome P1 P2 EP1 EP2 EP3 P EP 1 Andre 6.5 7.5 9.0 8.7 7.5 9.75 9.325 2 Bel 5.5 6.5 6.8 7.0 7.5 5.25 8.125. 3 Cris 8.5 9.5 10.0 10.0 9.5 9.00 9.725
Prod, EmEstoque, EstoqueMin, pre�oUnit vinho, 132, 150, 85 wisky, 43, 50, 160 cacha�a, 82, 50, 45 sake, 37, 40, 120 vodka, 52, 50, 60 rum, 76, 80, 55 licor, 28, 15, 70
dirTrab <- "..." set(dirTrab) pl <- read.csv("estoque.csv")
pl[,'Pedido'] <- NA
arquivo f�ReporEstoque.r # caldula quantidade para repor. reporEstoque <- function(lin, x){ estoque <- x[lin,2] estoqueMin <- x[lin,3] if(estoque < estoqueMin){ repor <- estoqueMin - estoque }else{ repor <- 0 } return(repor) }
arquivo f�ColPedido.r # preenche a coluna de pedido. colPedido <- function(x){ tam <- nrow(x) for(i in(1:tam)){ x[i, 5] <- reporEstoque(i, x) } return(x) }
pl[,'Custo'] <- NA
arquivo f�CustoProd.r # caldula o custo de reposi��o de cada produto. custo <- function(lin, x){ pre�o <- x[lin,5] quant <- x[lin,6] custoProd <- quant * pre�o } return(custoProd) }
arquivo f�ColCusto.r # preenche a coluna de pedido. colCusto <- function(x){ tam <- nrow(x) for(i in(1:tam)){ x[i, 6] <- custo(i, x) } return(x) }
arquivo planilhaEstoque.r dirTrab <- "..." setwd(dirTrab) pl <- read.csv("estoque.csv") source(".../f�ReporEstoque.r") source(".../f�ColPedido.r") source(".../f�CustoProd.r") source(".../f�ColCusto.r") pl[,'Pedido'] <- NA pl <-ColPedido(pl) pl[,'Custo'] <- NA pl <-ColCusto(pl) print(pl)
Prod EmEstoque EstoqueMin pre�oUnit Pedido Custo vinho 132 150 85 18 1530 wisky 43 50 160 7 1120 cacha�a 82 50 45 0 0 sake 37 40 120 3 360 vodka 52 50 60 0 0 rum 76 80 55 4 220 licor 28 15 70 0 0
reporEstoque <- function(x){ if(x[, 2] < x[, 3]){ x[, 5] <- x[, 3] - x[, 2] }else{ x[, 5] <- 0 } return(x) }
dirTrab <- "..." setwd(dirTrab) pl <- read.csv("estoque.csv") source("../tentativa1.r") pl[,'Pedido'] <- NA pl <-reporEstoque(pl) print(pl)
Prod EmEstoque EstoqueMin pre�oUnit Pedido vinho 132 150 85 18 wisky 43 50 160 7 cacha�a 82 50 45 -32 sake 37 40 120 3 vodka 52 50 60 -2 rum 76 80 55 4 licor 28 15 70 -13