Using write.table to write rows row-by-row to a CSV in R, as you would in Python's writerows -


How do I write the CSV file in R, so did I do in Python?

In Python, I did this:

  Import Import CSV Import Numerical Number # Sample Data x = np.asarray ((1,2,3)) Y = np.asarray ((4,5,6)) file name = os.path.normpath ("output_py.csv") f = open (file name, "wb") author = csv.writer (f, delimiter = ',') Author.writerow (X) Writer Author (Y) f.close ()  

writer.writerow works well because I do not need to repeat parameters during writing is . Everything I need to do is specify the array to write.

I would like to do this in R. I have done so far:

  # sample data x  

Both outputs produce the correct output,

  1,2,3 4,5,6  

but the problem This is that every time I use the write.table , I have to repeat the parameters.

How to write rows without repeating the parameters every time?

Any other suggestions for code optimization would be appreciated.

Just type your own function write.row , using those criteria Which you would prefer as standards, eg

  write.row  

In this case, I Assume that you want to call this function multiple times and defaults to append = TRUE Want to industry and set it to change the first line otherwise FALSE


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -