The read.table and read.csv functions in R are used to parse a file or URL containing delimited data and produce an R data frame. However, I already have a character vector that contains the CSV delimited data (using comma and \n as column and record delimiters), so I don't need to read it from a file or URL. How can I pass this character vector into read.table
, read.csv
, or scan()
without writing it to a file on disk first and reading it back in? I realize that writing it to disk is possible, but I am looking for a solution that does not require this needless roundtrip and can read data from the character vector directly.
相关问题
- Correctly parse PDF paragraphs with Python
- R - Quantstart: Testing Strategy on Multiple Equit
- How to remove spaces in between characters without
- Using predict with svyglm
- Reshape matrix by rows
相关文章
- How to convert summary output to a data frame?
- How to plot smoother curves in R
- Paste all possible diagonals of an n*n matrix or d
- ess-rdired: I get this error “no ESS process is as
- How to read local csv file in client side javascri
- How to use doMC under Windows or alternative paral
- dyLimit for limited time in Dygraphs
- How do I get from a type to the TryParse method?
A minor addendum to neilfws's answer. This wrapper function is great for helping answer questions on stackoverflow when the questioner has placed raw data in their question rather than providing a data frame.
With usage, e.g.
You can use textConnection() to pass the character vector to read.table(). An example:
Answer found in the R mailing list.
2017 EDIT
Seven years later, I'd probably do it like this: