I am using R programming to export a .dat file. but the exported file is always included the index column. Is there any possible way/ code to export data in R without index column?
2.1 Remove Column by Index This notation takes syntax df[, columns] to select columns in R, And to remove columns you have to use the – (negative) operator. The following example removes the second column by Index from the R DataFrame.
Now let us see how these indices can be removed, for that simply set row. names parameter to False while writing data to a csv file using write. csv() function. By Default, it will be TRUE and create one extra column to CSV file as index column.
To delete an item at specific index from R Vector, pass the negated index as a vector in square brackets after the vector. We can also delete multiple items from a vector, based on index.
The most easiest way to drop columns is by using subset() function. In the code below, we are telling R to drop variables x and z. The '-' sign indicates dropping variables. Make sure the variable names would NOT be specified in quotes when using subset() function.
Lets say you are using write.table and your dataset is df then following will work for you
write.table(df,'df.dat',row.names=F)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With