0

Since this morning, I am trying to convert the Smoothies table within the SensorMineR Dataset using R Studio, but when I do it, the CSV created file is not well tabulated. You can verify it yourself by running the following commands :

smoothiesData <- load('smoothies.rda')
write.csv(get(smoothiesData), file = "smoothies.csv")

You can see that the columns are not well separated, I tried running the following command, but it doesn't change anything

write.csv(get(smoothiesData), file = "smoothies.csv", sep=",")

Can you tell me how should I proceed ?

YellowishLight
  • 238
  • 3
  • 21
  • When loading the data, the data gets stored in a data.frame called `smoothies`, so please just `write.csv(smoothies, file="smoothies.csv")` should do the trick. To be sure you can add `quotes = TRUE` to the write.csv call. – hannes101 Jul 31 '18 at 14:25

1 Answers1

0

You have called get which returns the value of a named object.

To make it work you can go the simple way:

write.csv(smoothiesData, file = "smoothies.csv", sep=",")

or you can use the name:

write.csv(get("smoothiesData"), file = "smoothies.csv", sep=",")

See ?get

PavoDive
  • 6,322
  • 2
  • 29
  • 55
  • Did you check with the original .rda file? It's not working since the data.frame is not called `smoothiesData`. – hannes101 Jul 31 '18 at 14:31
  • @hannes101 I provided a general solution. About the naming of the variable I can't tell. Is it producing an error on your `load` call? – PavoDive Jul 31 '18 at 15:28