发布网友 发布时间:2022-04-19 09:56
共5个回答
热心网友 时间:2023-07-15 01:10
seq函数是R语言中的基本函数,其功能是生成一个向量。热心网友 时间:2023-07-15 01:10
在一个文档中定位到第一个空行,读取其后的所有文本 get.msg <- function(path) { con <- file(path, open = "rt", encoding = "latin1") text <- readLines(con) # The message always begins after the first full line break msg <-... 文档定位第空行读取其所文本
get.msg <- function(path)
{
con <- file(path, open = "rt", encoding = "latin1")
text <- readLines(con)
# The message always begins after the first full line break
msg <- text[seq(which(text == "")[1]+1, length(text), 1)]
close(con)
return(paste(msg, collapse = "\n"))
}
报错:
Error in seq.default(which(text == "")[1]+1, length(text), 1) :
'from' cannot be NA, NaN or infinite 展开 示例文档:
From 12a1mailbot1@web.de Thu Aug 22 13:17:22 2002
Return-Path: <12a1mailbot1@web.de>
Delivered-To: zzzz@localhost.spamassassin.taint.org
Received: from localhost (localhost [127.0.0.1])
by phobos.labs.spamassassin.taint.org (Postfix) with ESMTP id 136B943C32
for <zzzz@localhost>; Thu, 22 Aug 2002 08:17:21 -0400 (EDT)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Dwindows-1252" http-equiv=3DContent-T=
ype>
热心网友 时间:2023-07-15 01:11
seq函数是产生序列用的他的用法是seq(from,to,by)或者是seq(下界,by=,length=)热心网友 时间:2023-07-15 01:11
兄弟,你是不是在看《机器学习:实用案例解析》这本书。这个问题我也遇到了。把这一行:con <- file(path, open = "rt", encoding = "latin1")中的encoding删掉,就解决了。(改成‘utf-8’也不行)就是字符编码的问题。热心网友 时间:2023-07-15 01:12
seq函数是产生序列用的他的用法是seq(from,to,by)或者是seq(下界,by=,length=)