<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>R on The Personal Website of Myosotics</title>
    <link>/tags/r/</link>
    <description>Recent content in R on The Personal Website of Myosotics</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Thu, 19 Oct 2023 00:00:00 +0000</lastBuildDate><atom:link href="/tags/r/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>在Rmarkdown中调用Python代码</title>
      <link>/blog/2023-10-19-rmarkdown-python/</link>
      <pubDate>Thu, 19 Oct 2023 00:00:00 +0000</pubDate>
      
      <guid>/blog/2023-10-19-rmarkdown-python/</guid>
      <description>在Rmarkdown中调用Python代码块需要用到reticulate包
install.packages(&amp;quot;reticulate&amp;quot;) 在我们运行python代码块之前首先需要设置好Python环境。下面我们需要指定Python路径， 在命令窗口输入where python看python的路径 接下来在R中指定Pyrhon路径
library(reticulate) use_python(&#39;E:/software/Program Files/python3.11.0&#39;) 最后即可在Rmarkdown中运行python代码块了
import numpy as np import matplotlib.pyplot as plt # 计算正弦曲线上的 x 和 y 坐标 x = np.arange(0, 3*np.pi, 0.1) y = np.sin(x) plt.title(&#39;sine wave form&#39;) # 使用 matplotlib 来绘制点 plt.plot(x, y) plt.show() </description>
    </item>
    
  </channel>
</rss>
