Skip to content

Commit dd1f983

Browse files
committed
Create README_CN.md
1 parent a7abb54 commit dd1f983

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

README_CN.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# DolphinDB R包
2+
3+
### 1. 关于DolphinDB R包
4+
5+
#### 1.1 简介
6+
7+
DolphinDB提供了R包,用户可以通过R语言操作DolphinDB。DolphinDB R包是由R和C++实现的,使用的C++包是Rcpp。
8+
9+
DolphinDB R包支持以下功能:
10+
11+
- 运行脚本
12+
- 执行DolphinDB中的函数
13+
- 上传变量到DolphinDB
14+
15+
#### 1.2 依赖
16+
17+
- R ( ≥ 3. 2. 0)
18+
- Rcpp ( ≥ 0. 12. 17)
19+
20+
### 2. 安装DolphinDB R包
21+
22+
#### 2.1 准备R环境
23+
24+
- Linux系统:
25+
26+
- 执行`sudo apt-get install r-base`安装R
27+
- 或者从[R官网](https://www.r-project.org/)手动下载安装
28+
29+
- Windows系统:
30+
31+
-[R官网](https://www.r-project.org/)下载并安装R包和rtools
32+
33+
安装时需要配置好环境变量和路径。
34+
35+
#### 2.2 进入R命令行
36+
37+
在终端或命令行中输入`R`进入R命令行。
38+
39+
#### 2.3 安装devtools
40+
41+
在R命令行中输入`install.packages("devtools")`,选择最近的镜像下载并安装。
42+
43+
#### 2.4 通过devtools安装DolphinDB R包
44+
45+
在R命令行中输入`devtools::install_github("dolphindb/api-r")`,系统自动会下载并安装DolphinDB R包以及它所依赖的包。
46+
47+
如果在Windows系统上安装时出现 *Warning in system(cmd) : 'make' not found.* 的错误信息,可以在R命令行中执行以下代码。安装完成后,程序包将由g++自动编译和链接。
48+
49+
```R
50+
Sys.setenv(PATH = paste("*InstallDirectory*/Rtools/bin", Sys.getenv("PATH"), sep=";"))
51+
Sys.setenv(BINPREF = "*InstallDirectory*/Rtools/mingw_64/bin")
52+
```
53+
54+
#### 2.5 使用DolphinDB R包
55+
56+
假设DolphinDB运行在主机名为localhost,端口号为8848的服务器上,我们可以通过以下方式来连接DolphinDB、上传对象和执行脚本:
57+
58+
```R
59+
library(RDolphinDB)
60+
conn <- dbConnect(DolphinDB(), "localhost", 8848)
61+
if (conn@connected) {
62+
dbUpload(conn, c("val1", "val2"), list(3.5, c(1.3, 2.6, 3.7)))
63+
res_run <- dbRun(conn, "1 2 3")
64+
res_rpc <- dbRpc(conn, "size", list(c(1, 2, 3)))
65+
print(res_run)
66+
print(res_rpc)
67+
}
68+
dbClose(conn)
69+
```
70+
71+
### 3. 更多函数介绍
72+
73+
在R命令行中执行**help**函数可以获取更多DolphinDB R包中函数的用法。
74+
75+
```R
76+
# About the package
77+
help(package = "RDolphinDB")
78+
79+
# About the functions
80+
help("DolphinDB")
81+
help("dbConnect")
82+
help("dbRun")
83+
help("dbRpc")
84+
help("dbUpload")
85+
help("dbClose")
86+
```
87+
88+
更多关于DolphinDB内置函数的用法,请参考[DolphinDB用户手册](https://www.dolphindb.cn/cn/help/Chapter13FunctionsandCommands.html)
89+

0 commit comments

Comments
 (0)