Removing a row?

Hi there,
I'm very (very!) new to using R & R studio.

I was given the following code:

example <- tempfile()
writelines(c('1,2,3', '4,5,6', 'blank'), example)

I'm trying to delete the last row with the 'blank'.
I've tried using nrow, rm, and -c but I keep getting the error of "incorrect number of dimensions".

Can I get a hand with this?
Also, how do I assign column names?
Thank you!

I think I could better support you if I understood your intentions.
your code provides for an temporary output file, and assuming you meant writeLines (as there is no base function writelines and the code as provided would error).
Your code writes 3 lines to the file, the last of which is the word 'blank'

When you say you are trying to delete the last row, do you mean that you wish to delete it from the file ?
You could of course, not write it to begin with.
otherwise, you would read the file back in, adjust it, and write it out again, would be the general approach.

Generally speaking, in the R world, column names relate to data.frames (tables in memory). if you had such a dataframe, you might choose to write it out as a csv which would be a universally understood spreadsheet compatible format that would generally consider the first row to be a header row listing column names.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.