亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在一個文檔中定位到第一個空行,讀取其后的所有文本,報錯如下:

在一個文檔中定位到第一個空行,讀取其后的所有文本,報錯如下:

慕雪6442864 2023-04-21 19:19:59
get.msg <- function(path){con <- file(path, open = "rt", encoding = "latin1")text <- readLines(con)# The message always begins after the first full line breakmsg <- 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 [email protected] Thu Aug 22 13:17:22 2002Return-Path: <[email protected]>Delivered-To: [email protected]: from localhost (localhost [127.0.0.1])by phobos.labs.spamassassin.taint.org (Postfix) with ESMTP id 136B943C32for <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>
查看完整描述

2 回答

?
德瑪西亞99

TA貢獻1770條經驗 獲得超3個贊

seq函數是產生序列用的他的用法是seq(from,to,by)或者是seq(下界,by=,length=)
下面是用r運行的結果
seq(2,6,2)
[1] 2 4 6
seq(10,by=2,length=5)
[1] 10 12 14 16 18

查看完整回答
反對 回復 2023-04-25
?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

在一個文檔中定位到第一個空行,讀取其后的所有文本  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 [email protected]  Thu Aug 22 13:17:22 2002

Return-Path: <[email protected]>

Delivered-To: [email protected]

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-04-25
  • 2 回答
  • 0 關注
  • 288 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號