#install.p
library(tidyverse)
library(dplyr)
setwd('D:\\Users\\GBD数据') #修改成你自己的文件夹路径
data <- read.csv('IHME-GBD_2021_DATA.csv',header = T)
EAPC <- data %>%
filter(metric_name== 'Rate') %>%
filter(measure_name=='Incidence')
EAPC_cal <- matrix(nrow=0,ncol=6) %>% as.data.frame()#????!!!
## 计算不同性别、不同年龄的EAPC
num=1#here is my problem
for (Global in unique(EAPC$location_name)){
for (Both in unique(EAPC$sex_name)) {
for (Age-standardized in unique(EAPC$age_name)) {
a <- EAPC %>%
filter(location == Globa) %>%
filter(sex == Both) %>%
filter(age == Age-standardized)
a$y <- log(a$val)
mod_simp_reg<-lm(y~year,data=a)
estimate <- (exp(summary(mod_simp_reg)[["coefficients"]][2,1])-1)*100
low <- (exp(summary(mod_simp_reg)[["coefficients"]][2,1]-1.96*summary(mod_simp_reg)[["coefficients"]][2,2])-1)*100
high <- (exp(summary(mod_simp_reg)[["coefficients"]][2,1]+1.96*summary(mod_simp_reg)[["coefficients"]][2,2])-1)*100
EAPC_cal[num,] <- c(i,j,k,estimate,low,high)
num = num+1
}
}
}
names(EAPC_cal) <- c('location','sex','age','EAPC','LCI','UCI')
EAPC_cal <- EAPC_cal %>% mutate(EAPC=as.numeric(EAPC),
LCI=as.numeric(LCI),
UCI=as.numeric(UCI)) %>%
mutate(EAPC=round(EAPC,2),
LCI=round(LCI,2),
UCI=round(UCI,2))
EAPC_cal <- EAPC_cal %>% mutate(EAPC_CI = paste(EAPC, LCI,sep = '\n(')) %>%
mutate(EAPC_CI = paste(EAPC_CI, UCI,sep = ' to ')) %>%
mutate(EAPC_CI = paste0(EAPC_CI, ')'))
head(EAPC_cal)
write.csv(EAPC_cal,"EAPC_outcome.csv")
Can you supply us with some sample data and any error messages you get when you run the code? Thanks
A handy way to supply data is to use the dput() function. Do dput(mydata) where "mydata" is the name of your dataset. For really large datasets probably dput(head(mydata, 100)) will do. Paste the output between
```
```
错误: 意外的'-' 于
" for (Both in unique(EAPC$sex_name)) {
for (Age-"
、、、
dput(head(data, 100))
structure(list(measure_id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), measure_name = c("Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths", "Deaths",
"Deaths"), location_id = c(1L, 1L, 1L, 167L, 167L, 167L, 137L,
137L, 137L, 104L, 104L, 104L, 199L, 199L, 199L, 100L, 100L, 100L,
192L, 192L, 192L, 158L, 158L, 158L, 199L, 199L, 199L, 100L, 100L,
100L, 44634L, 44634L, 44634L, 174L, 174L, 174L, 5L, 5L, 5L, 32L,
32L, 32L, 21L, 21L, 21L, 44637L, 44637L, 44637L, 100L, 100L,
100L, 44635L, 44635L, 44635L, 134L, 134L, 134L, 137L, 137L, 137L,
174L, 174L, 174L, 104L, 104L, 104L, 56L, 56L, 56L, 120L, 120L,
120L, 70L, 70L, 70L, 44634L, 44634L, 44634L, 174L, 174L, 174L,
199L, 199L, 199L, 73L, 73L, 73L, 44634L, 44634L, 44634L, 104L,
104L, 104L, 100L, 100L, 100L, 199L, 199L, 199L, 44634L), location_name = c("Global",
"Global", "Global", "Central Sub-Saharan Africa", "Central Sub-Saharan Africa",
"Central Sub-Saharan Africa", "North Africa and Middle East",
"North Africa and Middle East", "North Africa and Middle East",
"Caribbean", "Caribbean", "Caribbean", "Western Sub-Saharan Africa",
"Western Sub-Saharan Africa", "Western Sub-Saharan Africa", "High-income North America",
"High-income North America", "High-income North America", "Southern Sub-Saharan Africa",
"Southern Sub-Saharan Africa", "Southern Sub-Saharan Africa",
"South Asia", "South Asia", "South Asia", "Western Sub-Saharan Africa",
"Western Sub-Saharan Africa", "Western Sub-Saharan Africa", "High-income North America",
"High-income North America", "High-income North America", "High-middle SDI",
"High-middle SDI", "High-middle SDI", "Eastern Sub-Saharan Africa",
"Eastern Sub-Saharan Africa", "Eastern Sub-Saharan Africa", "East Asia",
"East Asia", "East Asia", "Central Asia", "Central Asia", "Central Asia",
"Oceania", "Oceania", "Oceania", "Low SDI", "Low SDI", "Low SDI",
"High-income North America", "High-income North America", "High-income North America",
"High SDI", "High SDI", "High SDI", "Tropical Latin America",
"Tropical Latin America", "Tropical Latin America", "North Africa and Middle East",
"North Africa and Middle East", "North Africa and Middle East",
"Eastern Sub-Saharan Africa", "Eastern Sub-Saharan Africa", "Eastern Sub-Saharan Africa",
"Caribbean", "Caribbean", "Caribbean", "Eastern Europe", "Eastern Europe",
"Eastern Europe", "Andean Latin America", "Andean Latin America",
"Andean Latin America", "Australasia", "Australasia", "Australasia",
"High-middle SDI", "High-middle SDI", "High-middle SDI", "Eastern Sub-Saharan Africa",
"Eastern Sub-Saharan Africa", "Eastern Sub-Saharan Africa", "Western Sub-Saharan Africa",
"Western Sub-Saharan Africa", "Western Sub-Saharan Africa", "Western Europe",
"Western Europe", "Western Europe", "High-middle SDI", "High-middle SDI",
"High-middle SDI", "Caribbean", "Caribbean", "Caribbean", "High-income North America",
"High-income North America", "High-income North America", "Western Sub-Saharan Africa",
"Western Sub-Saharan Africa", "Western Sub-Saharan Africa", "High-middle SDI"
), sex_id = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L), sex_name = c("Male", "Female",
"Both", "Male", "Female", "Both", "Male", "Female", "Both", "Male",
"Female", "Both", "Male", "Female", "Both", "Male", "Female",
"Both", "Male", "Female", "Both", "Male", "Female", "Both", "Male",
"Female", "Both", "Male", "Female", "Both", "Male", "Female",
"Both", "Male", "Female", "Both", "Male", "Female", "Both", "Male",
"Female", "Both", "Male", "Female", "Both", "Male", "Female",
"Both", "Male", "Female", "Both", "Male", "Female", "Both", "Male",
"Female", "Both", "Male", "Female", "Both", "Male", "Female",
"Both", "Male", "Female", "Both", "Male", "Female", "Both", "Male",
"Female", "Both", "Male", "Female", "Both", "Male", "Female",
"Both", "Male", "Female", "Both", "Male", "Female", "Both", "Male",
"Female", "Both", "Male", "Female", "Both", "Male", "Female",
"Both", "Male", "Female", "Both", "Male", "Female", "Both", "Male"
), age_id = c(27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L),
age_name = c("Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized", "Age-standardized", "Age-standardized",
"Age-standardized"), cause_id = c(564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L), cause_name = c("Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders", "Amphetamine use disorders",
"Amphetamine use disorders"), metric_id = c(3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L), metric_name = c("Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate", "Rate",
"Rate", "Rate"), year = c(1980L, 1980L, 1980L, 1980L, 1980L,
1980L, 1982L, 1982L, 1982L, 1982L, 1982L, 1982L, 1980L, 1980L,
1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L,
1980L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L,
1981L, 1982L, 1982L, 1982L, 1980L, 1980L, 1980L, 1980L, 1980L,
1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1982L, 1982L,
1982L, 1981L, 1981L, 1981L, 1980L, 1980L, 1980L, 1981L, 1981L,
1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1981L, 1980L, 1980L,
1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1980L, 1982L, 1982L,
1982L, 1984L, 1984L, 1984L, 1983L, 1983L, 1983L, 1980L, 1980L,
1980L, 1983L, 1983L, 1983L, 1980L, 1980L, 1980L, 1983L, 1983L,
1983L, 1982L, 1982L, 1982L, 1980L), val = c(0.0453151941995438,
0.105172305655841, 0.0750281707636706, 0.00101933291896466,
0.0021142222572603, 0.00157523212871058, 0.00568304896322596,
0.0254400605013999, 0.0153657256663069, 0.00287611115203672,
0.00441558230703229, 0.00367133470576548, 0.000537341119005222,
0.000245394873607799, 0.000379496407960497, 0.0754655298761291,
0.0298888059817248, 0.0523463252979641, 0.0160464299993725,
0.0378568983618454, 0.0271473027172371, 0.00171605205580804,
0.0211807437511592, 0.0110072082153351, 0.000555707264740762,
0.000251462303279199, 0.000390511792614723, 0.0800704037208873,
0.0308876324795781, 0.0551320389732734, 0.0688492568180038,
0.135853362872345, 0.101973386017818, 0.000945582535159888,
0.00621935678791806, 0.00371073189029681, 0.144657319390091,
0.419991298731019, 0.273636470535801, 0.019744118666867,
0.0154712168949544, 0.017379080282244, 0.00603590012822721,
0.00296306731399174, 0.0045471719632121, 0.000617601571101955,
0.0139236594694251, 0.00727864994488253, 0.0827368940591706,
0.0321096870249925, 0.0570759581354397, 0.0422618428638097,
0.0271034311361237, 0.0345980646581793, 0.000102024450995094,
0.006217449797453, 0.00321471213027716, 0.00500530228046273,
0.025763323844235, 0.0151819258745636, 0.000860853522969367,
0.00614602574890249, 0.00362923296849163, 0.00271138642747508,
0.00428144141202847, 0.0035228731078129, 0.104763816115137,
0.0363744095078401, 0.0697622972129979, 0.0057302463402654,
0.0157103626913249, 0.0107658149981088, 0.0353644659934208,
0.0215956375369001, 0.0285373917008006, 0.0696439313553407,
0.129175245654635, 0.0989583716836189, 0.00109380526965572,
0.00635006826487857, 0.00384795983192415, 0.000588081965781882,
0.000262190656587784, 0.000409301320564777, 0.0228839288790006,
0.0131982740871455, 0.0180847427648711, 0.0706325096856843,
0.128354192748291, 0.0989760108926901, 0.00243589053768012,
0.00420556449588197, 0.00334964311787614, 0.08627810890664,
0.0340062587169274, 0.0597876676103476, 0.00057391821520148,
0.000257676003771676, 0.000401303718951073, 0.0658792307900555
), upper = c(0.070488790303272, 0.140959295140781, 0.100887838089572,
0.00737090307672693, 0.004720756327979, 0.00510529138807885,
0.0293367815416744, 0.0487774523002768, 0.0296045983143985,
0.00566272435954818, 0.0057628855406551, 0.00528621108032866,
0.00217270072854818, 0.000515485311265291, 0.0012211121819534,
0.0821637194400483, 0.0313061191223064, 0.0559698701473124,
0.0435540730837954, 0.0689630272337316, 0.0439416146755409,
0.00487578324718631, 0.0417020641129474, 0.0215202158545269,
0.00211982667922499, 0.000512673465474454, 0.00118588565433851,
0.0863403403487587, 0.0323783928888162, 0.0585934217172815,
0.0960182893793005, 0.174241204528618, 0.129675815571121,
0.00674288169781337, 0.0126751250869369, 0.00810195306604763,
0.248711243752963, 0.575155905648178, 0.380751129576776,
0.0491415436869008, 0.0210809041428008, 0.0314668879309446,
0.0145348042300937, 0.00661276086675496, 0.00975525615092824,
0.00401648413541859, 0.0296407682494482, 0.0152765096988198,
0.0890133508352763, 0.0336797462157352, 0.0604967687417577,
0.0461191458642305, 0.0315117621383233, 0.0375459100273628,
0.000294151855932881, 0.00730920309475635, 0.0037812150831592,
0.026524830693523, 0.0502416830107444, 0.0293033348286315,
0.00630292800524163, 0.0127730654214338, 0.0075331117034187,
0.00552548117718593, 0.00568928620639609, 0.00522436645702757,
0.131206705887578, 0.0416319623565085, 0.0838182225675846,
0.0132724246943387, 0.0248676468135524, 0.0157361323941925,
0.0432850892031558, 0.0252147176227496, 0.0325723426928318,
0.10271099106863, 0.165697376748943, 0.122652058891301, 0.00755510751923754,
0.0129566067127932, 0.00846710741412548, 0.00199461361117569,
0.000523250882731318, 0.00115527614005339, 0.0285327356340232,
0.0144123204774036, 0.020986884674006, 0.102040103104944,
0.167843440751174, 0.124239164457824, 0.00510976194255693,
0.00563853249668739, 0.00506983437154636, 0.0932037955671251,
0.035698658495082, 0.0635619135521837, 0.00214834796922995,
0.000523743123119984, 0.00118984224996238, 0.0950889416836118
), lower = c(0.0331250573600183, 0.073233943370134, 0.058946134446592,
0.000110961101978376, 0.00110492841269874, 0.000660293190193496,
0.0012387084509016, 0.0148588861384435, 0.00807836002840565,
0.00198890781004768, 0.0036074515334691, 0.00299704868733253,
0.000172783155634397, 0.000119422948636315, 0.000169780420755116,
0.0693425140767771, 0.0284307891239452, 0.0489247008980836,
0.00783375099805036, 0.0244437093306226, 0.0173771721702658,
0.00074449912245459, 0.0135488168031791, 0.007209855140411,
0.000197446386540723, 0.000120445881831817, 0.00017558476485374,
0.0739700846096944, 0.0294029314634526, 0.0516587814418052,
0.0522603237257177, 0.100716955948556, 0.0808671599142648,
0.000115983278635075, 0.00334590506973949, 0.00183174680853457,
0.0908616228147834, 0.282295977529243, 0.206578632307603,
0.0106543612814546, 0.00959276346855331, 0.0113627249394075,
0.00304457367774539, 0.00177908879152841, 0.0025716772391891,
5.184602485681e-05, 0.00806723735472006, 0.00427642361582169,
0.0768117611638288, 0.0304756346991466, 0.0535372589055887,
0.0391027268173858, 0.0239913393072094, 0.032129055682308,
7.5755053212336e-05, 0.00562998606168534, 0.00290456983438464,
0.000948259634145485, 0.0146753779078623, 0.00778440298865123,
9.63560046416047e-05, 0.00316309934181383, 0.00172315258781249,
0.00181161514844395, 0.00345255106193576, 0.00282994394123657,
0.0949263403725351, 0.0299271127848473, 0.0639606884831382,
0.00296957728732894, 0.0105155527440682, 0.00736603621651509,
0.0287943792769141, 0.0185522010560143, 0.0249471522065455,
0.0522513118940892, 0.0968151088783078, 0.0814631365657066,
0.000168902188599182, 0.00353177045233839, 0.0019482973898737,
0.000222922409323595, 0.000124209151308418, 0.000198767964054175,
0.0209416431122579, 0.0125145962748406, 0.0169114278155223,
0.0530496123170425, 0.094682015575402, 0.0824874340300805,
0.00155832320081479, 0.00334715385836742, 0.00266223802343592,
0.0796518804777955, 0.0322929343702114, 0.0561277263225024,
0.000203072177292601, 0.000123809302737403, 0.000190486497276221,
0.0499034619076675)), row.names = c(NA, 100L), class = "data.frame")
、、、
Thank you for the data. It helps but it appears that you are pulling from a large dataset so we are not getting much variation in some of the variables.
We may need to ask you to do some random sampling across the data set.
Note, for my own convenience I have converted your data.frame data
to a data.table DT
but it should not make any difference in underlying operations. The syntax may be a little different.
Anyway I find I am not understanding what you are doing here.
num=1 #here is my problem
for (Global in unique(EAPC$location_name)){
for (Both in unique(EAPC$sex_name)) {
for (Age-standardized in unique(EAPC$age_name)) {
a <- EAPC %>%
filter(location == Globa) %>%
filter(sex == Both) %>%
filter(age == Age-standardized)
a$y <- log(a$val)
it is not clear why you need
num = 1
and I have no idea where "Global" and "Both" are coming from. Oh wait
they seem to be coming from
DT[, unique(location_name)]
DT[, unique(sex_name)]
but I do not think they are what you think they are.
You have a statement
a$y <- log(a$val)
but I do not see where you have defined "a".
Perhaps you could give us a description in Chinese or English of what you want to do? It would help us help you.