Uploading dataset from Rstudio

Hi guys!
I've been using Rstudio for 1 month, so I'm asking sorry at beginning because maybe the topic could be a stupid question! But I'm trying in different way and it has never worked.
So, after different subsettings I've got this table on R (attached) that I'm trying to save on my pc. I tried with
write.csv and write.table but every time the result is a table in excel where I've the different columns pooled in the same one (the first).
This is the script:
write.table(R1BTs34, file = "R1BTropicsafe34.csv", sep = "", col.names =TRUE)
I've already read some webguide and also checked on youtube.
Nobody has this problem, with the same script they obtain the excel table with the different rows and columns well seperated.
So since I'm here I would like also to know if I can merge these type of datasets (I've 10-12 as this, each one is for one sample) in the same one: the problem is that the rows are different so they couldn't be merged in a unique big dataset. I've thought that at this point it could be useful to have all these in the same excel but separeted.
Thanks for the space
Giuseppe

Welcome to the community! It looks like the fields are all collapsed into one column because the field separator is set to the empty character (""). Try setting the separator to a comma.

write.table(R1BTs34, file = "R1BTropicsafe34.csv", sep = ",", col.names =TRUE)

Thanks you for the answer, but it's still not working

Can you suppl some data from R1BTs34? A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need.

I'm not sure that I undertood what are you meaning. Do you need the dataset R1BTs34??
If it is, I'm pasting here:
structure(list(OTU = c("OTU_1", "OTU_68", "OTU_53", "OTU_25",
"OTU_480", "OTU_62", "OTU_136", "OTU_1702", "OTU_1213", "OTU_23",
"OTU_336", "OTU_575", "OTU_967", "OTU_1095", "OTU_12", "OTU_153",
"OTU_1659", "OTU_1746", "OTU_1789", "OTU_2198", "OTU_266", "OTU_295",
"OTU_467"), Abundance = c(1329, 12, 11, 9, 9, 8, 5, 3, 2, 2,
2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), Positivity_to_phytoplasma_HLB = c("yes",
"yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes",
"yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes",
"yes", "yes", "yes", "yes")), class = "data.frame", row.names = c(1L,
22L, 19L, 13L, 18L, 21L, 5L, 8L, 4L, 12L, 16L, 20L, 23L, 2L,
3L, 6L, 7L, 9L, 10L, 11L, 14L, 15L, 17L))
Thanks you very much

Yes exactly. Thank you.

Hi, Im run the code of @scottyd22 for save the .csv file with the example data and show this.

Try to make with the all data set

Run very well.

R1BTs34 <- structure(list(OTU = c("OTU_1", "OTU_68", "OTU_53", "OTU_25",
                                  "OTU_480", "OTU_62", "OTU_136", "OTU_1702", "OTU_1213", "OTU_23",
                                  "OTU_336", "OTU_575", "OTU_967", "OTU_1095", "OTU_12", "OTU_153",
                                  "OTU_1659", "OTU_1746", "OTU_1789", "OTU_2198", "OTU_266", 
                                   "OTU_295",  "OTU_467"), 
Abundance = c(1329, 12, 11, 9, 9, 8, 5, 3, 2, 2, , 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 
Positivity_to_phytoplasma_HLB = c("yes",  "yes", "yes", "yes", 
"yes", "yes", "yes", "yes", "yes", "yes",   "yes", "yes", "yes", "yes", "yes", 
"yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes")),
 class = "data.frame", 
row.names = c(1L, 22L, 19L, 13L, 18L, 21L, 5L, 8L, 
4L, 12L, 16L, 20L, 23L, 2L,  3L, 6L, 7L, 9L, 10L, 11L, 
14L, 15L, 17L))

write.table(R1BTs34, file = "R1BTropicsafe34.csv", sep = ",", col.names =TRUE)

I can duplicate the problem. I have no idea of why but the col.names =TRUE seems to be the problem.

I named your data.frame dat1 and both of these seem to work.

write.table(dat1, "giuseppe1.csv", row.names = FALSE)
write.csv(dat1, "giuseppe2.csv", row.names = FALSE)

Hi guys, I tried with both scritpts and it's still not working. I don't know why, it seems a very easy question but the problem always occur. Maybe could be an excel problem? I don't know what think, maybe it could be another thing out of the script

It might be or maybe something in your R environment? Whatever it is, it's weird.

Perhaps try shutting down R and RStudio or even do a complete reboot?

Can you give us a copy of the output from sessionInfo() ?

I've solved. The problem was "sep", I need to use "sep=;" and not the comma.
Thanks you everybody!

Oh , of course. I should have thought of that but I am from Canada.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.