我有下面的数据,包括分类变量和数字变量。我想用下面的方法自动替换数字变量中的所有异常值,但我需要在所有数字列中自动替换,而不是逐个替换
df$v3[df$v3 %in% boxplot(df)$out] <- median(df$v3)
df<-structure(list(`Project Title` = c("Cameroun - Projet dâaide humanitaire dâurgence en faveur des réfugiés hors sites et des populations hôtes situés dans les régions de lâAdamaoua, de lâEst et du Nord\r\n(Version française uniquement)",
"Multinational - Kenya-Tanzania Power Interconnection Project",
"Multinational - Kenya-Tanzania Power Interconnection Project",
"Zambia - Madison Finance Company Limited\r\n(under the Africa SME Program)",
"Eritrea - Skills Development for Employability and Entrepreneurship Project",
"Eritrea - Skills Development for Employability and Entrepreneurship Project",
"Uganda - Water Supply and Sanitation Programme - Additional activities",
"Cabo Verde - Aide dâurgence pour assister les populations affectées par lâéruption volcanique de lâîle de Fogo\r\n(Version française uniquement)",
"Kenya - Mombasa-Mariakani Highway Project", "Multinational - Africa Banking Corporation Holdings Ltd"
), `Approval date Year Trend` = structure(c(1421107200, 1424217600,
1424217600, 1425254400, 1425340800, 1425340800, 1425427200, 1425600000,
1426032000, 1426032000), tzone = "UTC", class = c("POSIXct",
"POSIXt")), `Type of Financing Source` = c("Special Relief Fund (SRF)",
"ADF", "ADF", "ADB Private Sector", "ADF", "ADF", "Global Environment Facility (GEF)",
"Special Relief Fund (SRF)", "ADF", "ADB Private Sector"), `Approved Amount_UA Equivalent` = c(690221.630165446,
75290000, 27500000, 2131605.31196044, 7580000, 5920000, 5947178.82036962,
191844.478076439, 8e+07, 11842251.7331135), `Approved Amount_USDEquivalent` = c(920065.43301054,
100361570, 36657500, 2841429.88084326, 10104140, 7891360, 7927589.3675527,
255728.689275894, 106640000, 15785721.5602403), `Project ID` = c("P-CM-I00-001",
"P-Z1-FA0-052", "P-Z1-FA0-086", "P-ZM-HAB-003", "P-ER-IA0-001",
"P-ER-IA0-001", "P-UG-E00-013", "P-CV-I00-001", "P-KE-DB0-021",
"P-Z1-HAB-046"), `Employe Name` = c("BISSAKONOU Judes", "MUGUWA Andrew",
"MUGUWA Andrew", "FRENCH Laura Katherine Smith", "ELAHEEBOCUS Bibi Nawsheen",
"ELAHEEBOCUS Bibi Nawsheen", "MBIRO Andrew", "TRAORE Rokhaya",
"MAMMO Zerfu Tessema", "MACHARIA Julius Karuga"), `Financing Source` = c("OTHERS",
"ADF Including TSF", "ADF Including TSF", "ADB Private", "ADF Including TSF",
"ADF Including TSF", "OTHERS", "OTHERS", "ADF Including TSF",
"ADB Private"), `Financial Access Category` = c("Blend Countries",
"Multinational", "Blend Countries", "Blend Countries", "ADF Countries",
"ADF Countries", "ADF Countries", "ADB Countries", "Blend Countries",
"Multinational"), `Country Classifaction` = c("Non-Transition States",
"Multinational", "Non-Transition States", "Non-Transition States",
"Transition States", "Transition States", "Non-Transition States",
"Non-Transition States", "Non-Transition States", "Multinational"
), `Country Name` = c("CAMEROON", "MULTINATIONAL", "KENYA", "ZAMBIA",
"ERITREA", "ERITREA", "UGANDA", "Cape Verde", "KENYA", "MULTINATIONAL"
), `REGION NAME` = c("Central", "Multinational", "East", "South",
"East", "East", "East", "West", "East", "Multinational"), `Sectoral Analysis` = c("Social",
"Power", "Power", "Finance", "Social", "Social", "WASH Sector",
"Social", "Transport", "Finance"), `High Five Prority 1: Feed Africa` = c(NA,
NA, NA, NA, NA, NA, 178415.364611089, NA, NA, NA), `High Five Prority 2: Light Up And Power Africa` = c(NA,
75290000, 27500000, NA, NA, NA, 59471.7882036962, NA, NA, NA),
`High Five Prority 3: Industrialize Africa` = c(NA, NA, NA,
2131605.31196044, NA, NA, NA, NA, NA, 11842251.7331135),
`High Five Prority 4: Integrate Africa` = c(NA, NA, NA, NA,
NA, NA, NA, NA, 8e+07, NA), `High Five Prority 5: Improve Quality Of Life` = c(690221.630165446,
NA, NA, NA, 7580000, 5920000, 5709291.66755484, 191844.478076439,
NA, NA), `Financing Instrument` = c("Emergency Assistance",
"Investment Project", "Investment Project", "Investment Project",
"Investment Project", "Investment Project", "ISP and Investment Project",
"Emergency Assistance", "Investment Project", "Investment Project"
), `Infrastructure vs Sector` = c("Social", "Infrastructure",
"Infrastructure", "Finance", "Social", "Social", "Infrastructure",
"Social", "Infrastructure", "Finance"), `SECTOR DEPARTMENT` = c("AHAI",
"PESD", "PESD", "PIFD", "AHHD", "AHHD", "AHWS", "AHHD", "PICU",
"PIFD"), `Sector Complex Name` = c("AHVP", "PEVP", "PEVP",
"PIVP", "AHVP", "AHVP", "AHVP", "AHVP", "PIVP", "PIVP"),
`Operations Type` = c("Sovereign", "Sovereign", "Sovereign",
"Non-Sovereign", "Sovereign", "Sovereign", "Sovereign", "Sovereign",
"Sovereign", "Non-Sovereign"), `NUMBER OF PROJECT` = c(1,
1, 1, 1, 0.5, 0.5, 1, 1, 1, 1), `Amount in UA Million` = c(0.690221630165446,
75.29, 27.5, 2.13160531196044, 7.58, 5.92, 5.94717882036962,
0.191844478076439, 80, 11.8422517331135)), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))