jupyter notebook 中的代码语法有什么问题
What is the problem in code syntax in jupyter notebook
库(dslabs)
图书馆(dplyr)
图书馆(润滑)
数据(reported_heights)
dat <- mutate(reported_heights, date_time = ymd_hms(time_stamp)) %>%
filter(date_time >= make_date(2016, 01, 25) & date_time < make_date(2016, 02, 1)) %>%
mutate(type = ifelse(day(date_time) == 25 & hour(date_time) == 8 & between(minute(date_time), 15, 30), "inclass","online")) %>%
select(sex, type)
y <- factor(dat$sex, c("Female", "Male"))
x <- dat$type
Error in library(dslabs): there is no package called 'dslabs'
Traceback:
2. library(dslabs)
Jupyter 可以与 R 内核一起使用(这是您编写代码的内核),但默认值为 Python。如果您安装了 R 内核,那么您应该可以从右上角的下拉菜单中 select 它。
如果您没有使用 R 的选项,则需要安装内核。如果您使用的是 conda,这非常简单,只需从命令行 运行 conda install -c r r-irkernel
。
您可能需要在成功安装必要的 R 内核后重新启动 Jupyter。然后,您应该可以 运行 在 Jupyter notebook 中编写 R 代码。
库(dslabs) 图书馆(dplyr) 图书馆(润滑) 数据(reported_heights)
dat <- mutate(reported_heights, date_time = ymd_hms(time_stamp)) %>%
filter(date_time >= make_date(2016, 01, 25) & date_time < make_date(2016, 02, 1)) %>%
mutate(type = ifelse(day(date_time) == 25 & hour(date_time) == 8 & between(minute(date_time), 15, 30), "inclass","online")) %>%
select(sex, type)
y <- factor(dat$sex, c("Female", "Male"))
x <- dat$type
Error in library(dslabs): there is no package called 'dslabs'
Traceback:
2. library(dslabs)
Jupyter 可以与 R 内核一起使用(这是您编写代码的内核),但默认值为 Python。如果您安装了 R 内核,那么您应该可以从右上角的下拉菜单中 select 它。
如果您没有使用 R 的选项,则需要安装内核。如果您使用的是 conda,这非常简单,只需从命令行 运行 conda install -c r r-irkernel
。
您可能需要在成功安装必要的 R 内核后重新启动 Jupyter。然后,您应该可以 运行 在 Jupyter notebook 中编写 R 代码。