出现错误提示如下:
Error in geom_network_nodes()
:
! Problem while setting up geom aesthetics.
ℹ Error occurred in the 2nd layer.
Caused by error in check_aesthetics()
:
! Aesthetics must be either length 1 or the same as the data (23)
✖ Fix the following mappings: size
Run rlang::last_trace()
to see where the error occurred.
rlang::last_trace()运行结果如下:
<error/rlang_error>
Error in geom_network_nodes()
:
! Problem while setting up geom aesthetics.
ℹ Error occurred in the 2nd layer.
Caused by error in check_aesthetics()
:
! Aesthetics must be either length 1 or the same as the data (23)
✖ Fix the following mappings: size
Backtrace:
▆
- └─bibliometrix::histPlot(...)
- ├─ggplot2::ggplot_build(g)
- └─ggplot2:::ggplot_build.ggplot(g)
- └─ggplot2:::by_layer(...)
- ├─rlang::try_fetch(...)
- │ ├─base::tryCatch(...)
- │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
- │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
- │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
- │ └─base::withCallingHandlers(...)
- └─ggplot2 (local) f(l = layers[], d = data[])
- └─l$compute_geom_2(d)
- └─ggplot2 (local) compute_geom_2(..., self = self)
- └─self$geom$use_defaults(data, self$aes_params, modifiers)
- └─ggplot2 (local) use_defaults(..., self = self)
- └─ggplot2:::check_aesthetics(params[aes_params], nrow(data))
原始代码如下:
library('bibliometrix')
wosfile <- c('F:/WOS导出/jzcw1-500.txt','F:/WOS导出/jzcw501-1000.txt',
'F:/WOS导出/jzcw1001-1500.txt','F:/WOS导出/jzcw1501-2000.txt',
'F:/WOS导出/jzcw2001-2500.txt','F:/WOS导出/jzcw2501-3000.txt',
'F:/WOS导出/jzcw3001-3500.txt','F:/WOS导出/jzcw3501-4000.txt',
'F:/WOS导出/jzcw4001-4500.txt','F:/WOS导出/jzcw4501-5000.txt',
'F:/WOS导出/jzcw5001-5500.txt','F:/WOS导出/jzcw5501-6000.txt',
'F:/WOS导出/jzcw6001-6500.txt','F:/WOS导出/jzcw6501-7000.txt',
'F:/WOS导出/jzcw7001-7500.txt','F:/WOS导出/jzcw7501-8000.txt',
'F:/WOS导出/jzcw8001-8500.txt','F:/WOS导出/jzcw8501-9000.txt',
'F:/WOS导出/jzcw9001-9500.txt','F:/WOS导出/jzcw9501-10000.txt',
'F:/WOS导出/jzcw10001-10500.txt','F:/WOS导出/jzcw10501-11000.txt',
'F:/WOS导出/jzcw11001-11500.txt','F:/WOS导出/jzcw11501-12000.txt',
'F:/WOS导出/jzcw12001-12500.txt','F:/WOS导出/jzcw12501-12938.txt')
###数据转换,转换函数###
Bw <- convert2df(file=wosfile,dbsource = 'wos',format = 'plaintext')
##删除年份###
Bw1 <- Bw[-c(which(is.na(Bw$PY)),which(Bw$PY==2023)),]
###创建引文网络###
hN <- histNetwork(M=Bw1,min.citations = 0,sep=';',network = TRUE,verbose = TRUE)
##top lcs papers##
lcs <- localCitations(Bw1)
plcs <- lcs$Papers
plcstop <- plcs[1:30,]
histPlot(hN,n=30,size = 5,labelsize = 5,verbose = TRUE)
size=which(hN$LCS>=95)
histPlot(hN,n=30,size = hN$LCS[size]/10,labelsize = 5,verbose = TRUE)
###请各位大神帮我瞅瞅####