理解read.csv代码的困难
我正在提高我的R技能,重建他们在R博客上所做的一些令人惊奇的事情。现在,我正试图重现这一点: . 此练习的相关数据集可在此处找到: 如果我正在深入研究代码(在第一个链接的底部可以找到),并且正在运行这段代码:理解read.csv代码的困难,r,R,我正在提高我的R技能,重建他们在R博客上所做的一些令人惊奇的事情。现在,我正试图重现这一点: . 此练习的相关数据集可在此处找到: 如果我正在深入研究代码(在第一个链接的底部可以找到),并且正在运行这段代码: r1 <- read.csv(sep=';',header=FALSE, col.names=c('Causes','Causes2','Age','year','aantal','count'), na.strings='-',text=txtlines[3:l
r1 <- read.csv(sep=';',header=FALSE,
col.names=c('Causes','Causes2','Age','year','aantal','count'),
na.strings='-',text=txtlines[3:length(txtlines)]) %>%
select(.,-aantal,-Causes2)
r1%
选择(,-aantal,-Causes2)
有人能帮我把这里采取的步骤分开吗?下面是对
read.csv()
调用中的每一行在您的示例中所做的解释。请注意,最后一个参数text
的赋值很复杂,取决于您上面给出的链接中的脚本。从较高的层次来看,他首先读取文件“overleden_uudoodsoo_170615161506.csv”
中的所有行,其中包含字符串“central”
,只使用该过滤集的第三行到最后一行。还有一个附加步骤应用于这些行
r1 <- read.csv( # columns separate by semi-colon
sep=';',
# first row is data (i.e. is NOT a header)
header=FALSE,
# names of the six columns
col.names=c('Causes','Causes2','Age','year','aantal','count'),
# treat hyphen as NA
na.strings='-',
# read from third line to final line of the original input
# Overledenen__doodsoo_170615161506.csv, after some
# filtering has been applied
text=txtlines[3:length(txtlines)]) %>% select(.,-aantal,-Causes2)
r1%选择(,-aantal,-Causes2)
以下是对示例中调用read.csv()
的每一行的说明。请注意,最后一个参数text
的赋值很复杂,取决于您上面给出的链接中的脚本。从较高的层次来看,他首先读取文件“overleden_uudoodsoo_170615161506.csv”
中的所有行,其中包含字符串“central”
,只使用该过滤集的第三行到最后一行。还有一个附加步骤应用于这些行
r1 <- read.csv( # columns separate by semi-colon
sep=';',
# first row is data (i.e. is NOT a header)
header=FALSE,
# names of the six columns
col.names=c('Causes','Causes2','Age','year','aantal','count'),
# treat hyphen as NA
na.strings='-',
# read from third line to final line of the original input
# Overledenen__doodsoo_170615161506.csv, after some
# filtering has been applied
text=txtlines[3:length(txtlines)]) %>% select(.,-aantal,-Causes2)
r1%选择(,-aantal,-Causes2)
read.csv,读取csv文件,用分隔符分隔列”
这样,像这样的输入是a;Bc将在以下列中分开:第一列=a,第二列=b,第三列=c
header=FALSE->它指定原始文件中没有给出任何头
col.names将列出的名称分配给r中的列
na.strings='-'将na值替换为'-'
text=txtlines[3:长度(txtlines)])从位置3一直读到末尾
%>%选择(,-aantal,-Causes2)过滤数据框read.csv,读取csv文件,用分隔符分隔列“ 这样,像这样的输入是a;Bc将在以下列中分开:第一列=a,第二列=b,第三列=c header=FALSE->它指定原始文件中没有给出任何头 col.names将列出的名称分配给r中的列 na.strings='-'将na值替换为'-' text=txtlines[3:长度(txtlines)])从位置3一直读到末尾 %>%选择(,-aantal,-Causes2)过滤数据帧