Import file and clutch

HI,

I am new learner in R programming.
I have few questions so i am seeking help here.

  1. How to convert csv file to excel file through R code
  2. How to clutch 10 csv file to one csv file

One way of several:

https://tutorials.methodsconsultants.com/posts/reading-and-writing-excel-files-with-r-using-readxl-and-writexl/

I am not familiar with the term clutch here but I will assume you want to merge the files is some way.

How to do it depends on a number of things.

Can you tell us more about the csv files . How similar are they to each other? Are there names similar? If so how?

How do you wish to combine them, by row or by column?

Can you supply us with some sample data from two or more files?

A very simple and very effective way to supply some data is to use the dput() command.

dput(mydata)

and then simply copy the output and paste it here. If you have a very large data set then a sample should be fine. To supply us with 100 rows of your data set do

dput(head(mydata , 100))

where mydata is the name of your dataframe or tibble.

  1. Yes i want to merge files. They are very similar to each other. Yes they have similar names (heading) but they have different data.
  2. I want to combine them by column
  3. On this platform i tried to attach sample files but it is not supported as only Jpeg/pdf/image are supported here
  4. This csv is to be converted into excel format a single file.

Please guide for above

Can you put all oy the .csv files is a single folder with no other files?

If so then this should work. "path_to_directory" needs to be changed to your path.

In my case it would be "/home/john/testfolder" .

library(tidyverse)

filenames = list.files("path_to_directory", full.names = TRUE)

myfiles  <-  lapply(filenames, read.csv)

 dat1  <-    myfiles   %>%  map_df(as_tibble)

library(writexl)
write_xlsx(dat1, "myfile.xlsx")

That is why I suggested using dput()

You execute the command **dput(myfile) and paste the output here.

This topic was automatically closed 21 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.