r - Change file name when using write.table() according to the name of the third column in data frame -
I have written a script in R, which merges and modifies some CSV data and then using the writing table Result the data saved by the frame. When the file is saved, it adds the current date of the file. The third column of the resulting data frame is always country-specific, so I was thinking that there is no way to include the name of the country using the writeable name in the name of the country (based on the name of the third column).
For example, if the third column's name is "this", then I want to add "Italy" to the name of the CSV file.
Import the list of country names and codes in R: ( it's the top of your script But it would be wise to do this: You should not read more into the data in each data set written on .csv in your processing loop, the rest of the code will be your current Get the name of the third column in your data with the count Ry code: Remove the country name: Enclose the country name in the csv filename ( Change "..." Any other tags You want to add to the output file name. Otherwise delete "..." ) Write your data to the file: Good luck: -) write.table order
Library (RQRL) csv_src & lt; - getURL ("https://raw.githubusercontent.com/umpirsky/country-list/master/country/cldr/en/ Country.csv ") World & lt; - read.csv (text = Csv_src, header = T) `
country code & lt; - colnames (Yourdata) [3]
csv_name & lt; - paste0 ("...", country, ".csv")
writeable (x = yourdata , File = csv_name)
Comments
Post a Comment