我正在将一个excel文件导入R。我只想保留A列和C列而不是B列(列按顺序是A,B,C),但是下面的代码也保留了B列。我如何摆脱B列而不在另一行代码中子集化?
df <- read_excel("df.xlsm", "futsales", range = cell_cols(c("A","C")), na = " ")
答案 0 :(得分:0)
通过浏览externnotify
Want to run an external program whenever a caller leaves a voice mail message for a user? This is where the externnotify command comes in handy. Externnotify takes a string value which is the command line you want to execute when the caller finishes leaving a message.
Note: see an example of an external notification script here.
Note: This command will also run after a person who has logged into a mailbox exits the VoiceMailMain() application. (Remark: This seems not to be the case for Asterisk 1.2.x)
The way it works is basically any time that somebody leaves a voicemail on the system (regardless of mailbox number), the command specified for externnotify is run with the arguments (in this order): context, extension, new voicemails, old voicemails and urgent voicemails. These arguments are passed to the program that you set in the externnotify variable.
函数的文档,您必须给出一个范围,
read_excel
答案 1 :(得分:0)
我刚刚这样做是为了成功读取27列的Excel文件的5列,因此这是如何对名称存储在x
中的文件执行此操作,并且仅检索第一列和第三列,假设A列是文本,C列是数字:
library(tibble)
library(readxl)
df.temp <- as.tibble(read_excel(x,
col_names=TRUE,
col_types=c("text","skip","numeric")
)
答案 2 :(得分:0)
您似乎无法在read_excel
的range参数中指定多个范围。但是,您可以使用purrr
中的map函数将read_excel
应用于范围向量。在您的用例中,map_dfc
会将A列和C列的选择绑定回一起到单个输出数据集中。
library(readxl)
library(purrr)
path <- readxl_example("datasets.xlsx")
ranges <- list("A", "C")
ranges %>%
purrr::map_dfc(
~ read_excel(
path,
range = cell_cols(.))
)
答案 3 :(得分:0)
@MauritsEvers所说的其他选择是:
df <- read_excel("df.xlsm", "futsales")[,c(1,3)]
您要用所有数据制作一个矩阵,同时用所有行制作df
(这就是[,
的原因),只用第一个(“ A”)和第三(“ C”)列(这就是,c(1,3)]
的原因)