如何将输出格式化为读取向量列表

时间:2022-12-09 04:17:17

I have a program that outputs to file an unevenly spaced time series of vectors (one vector per interval) that vary in size . I'm wondering what would be the best way of formatting the output so that the file can be read into a list of vectors in R (Assuming that is the correct data structure), and what code in R i would use to read it.

我有一个程序,它输出一个不均匀间隔的向量时间序列(每间隔一个向量),它们的大小不同。我想知道格式化输出的最好方式是什么,这样文件就可以被读入R中的向量列表(假设这是正确的数据结构),以及我将使用R中的哪些代码来读取它。

For example, I imagine the output could look something like this:

例如,我认为输出可以是这样的:

1, 24, 5, 211
3, 5
59, 465, 3, 333, 9, 98

or

(1 24 5 211)
(3 5)
(59 465 3 333 9 98)

But what I'm saying is that I want to change the formatting to suite the R read function.

但我想说的是,我想要改变格式,以使R读函数。

1 个解决方案

#1


0  

Keep fill = TRUE

保持填补= TRUE

data = read.table(file.choose(),sep=",",fill=TRUE)

data[is.na(data)] <- ""   # Replacing NA Values with nothing..

#1


0  

Keep fill = TRUE

保持填补= TRUE

data = read.table(file.choose(),sep=",",fill=TRUE)

data[is.na(data)] <- ""   # Replacing NA Values with nothing..