row<-c("1","2","3") write to a row in a .txt using write lines
时间: 2023-07-19 07:26:20 浏览: 38
To write a row to a .txt file using the `writeLines` function in R, you can do the following:
1. Create a character vector with the row data:
```
row <- c("1", "2", "3")
```
2. Open a connection to the file using the `file` function:
```
con <- file("myfile.txt", open = "w")
```
The `open = "w"` argument specifies that the file should be opened for writing. If the file already exists, its contents will be overwritten.
3. Write the row data to the file using the `writeLines` function:
```
writeLines(row, con)
```
This will write the contents of the `row` vector to the file specified by the `con` connection.
4. Close the connection using the `close` function:
```
close(con)
```
This will ensure that the file is properly saved and closed.