0

I am trying to export my simple data frame into a .txt file. My data frame BridgeGateHourlyDirection looks like:

6 columns

I used the statement below

write.table(BridgeGateHourlyDirection, "X:/Maria/Trends/BridgeGateHourlyDOWDirection.txt", sep="\t",row.names=FALSE, quote=FALSE, eol="\n",na="NA",dec=".")

The output looks to be quite unusual and is not readable containing c(). It looks like this: text file output

Has anyone experienced this before and found a solution?

sapply(BridgeGateHourlyDirection,class)
        Year        Month         Hour     DayClass        EBTot        WBTot 
   "integer"    "integer"    "integer"  "character" "data.frame" "data.frame" 

Thank you!

Maria
  • 1
  • 1
  • 1
    what is sapply(BridgeGayeHourlyDirection, class) – MichaelChirico Sep 09 '20 at 20:19
  • How did you create the `BridgeGateHourlyDirection` object. Seems like you may have created an invalid data.frame at some point during your processing. – MrFlick Sep 09 '20 at 20:31
  • @MrFlick I created it using pivot_wider and then converted from a tibble into a data.frame. the data frame looks fine even when examining the whole data set – Maria Sep 09 '20 at 20:43
  • You can see from the `sapply` that you have `data.frames` inside your `data.frame` which doesn't bother tibbles but you cannot write out such a structure with `write.table`. It's hard to say how exactly that happened without some sort of [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Sep 09 '20 at 20:45

0 Answers0