Giter VIP home page Giter VIP logo

Comments (9)

XiangyunHuang avatar XiangyunHuang commented on August 30, 2024

@pzhaonet 帮忙确认一下,能不能在你的环境中运行,我初步判定是存在 BUG

下面是 Debian 环境运行的结果

demo("SongWordsNet“, package = "MSG")
        ---- ~~~~~~~~~~~~

> require("igraph")
Loading required package: igraph

Attaching package: igraph

The following objects are masked from package:stats:

    decompose, spectrum

The following object is masked from package:base:

    union


> load(system.file('extdata','HighFreq100.rda',package='MSG'))

> g <- graph.adjacency((HighFreq100>0.05)*HighFreq100,mode="undirected",weighted
=T, diag=F)

> cg <- clusters(g)

> colbar <- as.numeric(as.factor(cg$csize[cg$membership+1]))

> V(g)$color <- rev(heat.colors(9))[colbar]

> ff <- as.numeric(cut(g[[9]][[4]]$weight,breaks=c(0.05,0.1,0.2,0.3,0.4)),right=
F)
Error in g[[9]][[4]] : subscript out of bounds
> sessionInfo()
R Under development (unstable) (2019-08-12 r76979)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)

Matrix products: default
BLAS:   /opt/R/R-devel/lib/R/lib/libRblas.so
LAPACK: /opt/R/R-devel/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] igraph_1.2.4.1

loaded via a namespace (and not attached):
[1] compiler_3.7.0  magrittr_1.5    tools_3.7.0     pkgconfig_2.0.2
>

from msg.

pzhaonet avatar pzhaonet commented on August 30, 2024

嗯,我这里报同样的错。


> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] igraph_1.2.4.1     vioplot_0.3.2      zoo_1.8-6          sm_2.2-5.6         RColorBrewer_1.1-2 maps_3.3.0        
 [7] KernSmooth_2.23-15 MSG_0.2.4          rpart_4.1-15       survival_2.44-1.1  formatR_1.7       

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2       knitr_1.24       magrittr_1.5     splines_3.6.1    lattice_0.20-38  stringr_1.4.0    tcltk_3.6.1     
 [8] tools_3.6.1      grid_3.6.1       packrat_0.5.0    xfun_0.8         htmltools_0.3.6  yaml_2.2.0       digest_0.6.20   
[15] bookdown_0.12    latex2exp_0.4.0  Matrix_1.2-17    rsconnect_0.8.15 evaluate_0.14    rmarkdown_1.14   stringi_1.4.3   
[22] compiler_3.6.1   magick_2.1       pkgconfig_2.0.2 

from msg.

XiangyunHuang avatar XiangyunHuang commented on August 30, 2024

这应该是 MSG 的 bug 了,全书应该就差这个图没复现出来

from msg.

pzhaonet avatar pzhaonet commented on August 30, 2024

试了一下源代码,在刚开始 load() 数据时就出现了中文乱码问题。

from msg.

XiangyunHuang avatar XiangyunHuang commented on August 30, 2024

你的系统原来是不是中文的

from msg.

pzhaonet avatar pzhaonet commented on August 30, 2024

是英文的,但是我把 locale 调成了中文。

from msg.

XiangyunHuang avatar XiangyunHuang commented on August 30, 2024
load(system.file("extdata", "HighFreq100.rda", package = "MSG"))
write.table(HighFreq100, "HighFreq100.csv")

我是把它写出来再读进去,才能看到中文

mat

mat-cn

再转回矩阵

dat <- as.matrix(dat)

我对 igraph 不熟悉,复现起来比较困难

ff <- as.numeric(cut(g[[9]][[4]]$weight, breaks = c(0.05, 0.1, 0.2, 0.3, 0.4)), right = F)

而实际上

str(g)
List of 10
 $ :List of 1
  ..$ 自然: 'igraph.vs' Named int [1:6] 2 9 16 18 85 96
  .. ..- attr(*, "names")= chr [1:6] "逍遥" "无为" "修行" "清净" ...
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 逍遥: 'igraph.vs' Named int [1:8] 1 5 9 18 25 39 43 74
  .. ..- attr(*, "names")= chr [1:8] "自然" "物外" "无为" "清净" ...
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 人间: 'igraph.vs' Named int 26
  .. ..- attr(*, "names")= chr "万里"
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 何处: 'igraph.vs' Named int(0) 
  .. ..- attr(*, "names")= chr(0) 
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 物外: 'igraph.vs' Named int [1:3] 2 39 43
  .. ..- attr(*, "names")= chr [1:3] "逍遥" "云水" "自在"
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 明月: 'igraph.vs' Named int 45
  .. ..- attr(*, "names")= chr "清风"
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 风流: 'igraph.vs' Named int [1:2] 57 65
  .. ..- attr(*, "names")= chr [1:2] "千古" "当年"
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 东风: 'igraph.vs' Named int 27
  .. ..- attr(*, "names")= chr "风吹"
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 无为: 'igraph.vs' Named int [1:8] 1 2 16 18 36 43 85 99
  .. ..- attr(*, "names")= chr [1:8] "自然" "逍遥" "修行" "清净" ...
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 $ :List of 1
  ..$ 尊前: 'igraph.vs' Named int [1:2] 79 83
  .. ..- attr(*, "names")= chr [1:2] "相逢" "人生"
  .. ..- attr(*, "env")=<weakref> 
  .. ..- attr(*, "graph")= chr "8befa314-c332-11e9-80f1-ed1b15b68ff1"
 - attr(*, "class")= chr "igraph"
> g[[9]]
$无为
+ 8/100 vertices, named, from 8befa31:
[1] 自然 逍遥 修行 清净 功成 自在 功行 些儿

所以下标越界了

from msg.

XiangyunHuang avatar XiangyunHuang commented on August 30, 2024

参考文章 @yixuan 统计词话2 统计词话1 @taiyun 统计词画番外篇(一):谁共我,醉明月 二位大佬是否有时间帮忙更新一下代码?

from msg.

XiangyunHuang avatar XiangyunHuang commented on August 30, 2024

yihui/MSG#31 合并后,本书所有代码、图都可重复了

from msg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.