Ich habe die folgenden Datenrahmen, die Informationen über verschiedene Zustände enthält.Schreibe Datenrahmen zu mehreren csv in R
long=c(-106.61291,-106.61291,-106.61291,-81.97224,-81.97224,-81.97224,-84.4277,-84.4277,-84.4277)
lat=c(35.04333,35.04333,35.04333,33.37378,33.37378,33.37378,33.64073,33.64073,33.64073)
city=c("Albuquerque","Albuquerque","Albuquerque","Augusta","Augusta","Augusta","Atlanta","Atlanta","Atlanta")
date=c("2017-08-22","2017-08-23","2017-09-24","2017-09-28","2017-10-24","2017-09-22","2017-11-12","2017-010-14","2017-09-03")
value=c(12,10.8,18.3,12.4,43,21,12,32.1,14)
df<-data.frame(long,lat,city,date,value)
Problem: Ich möchte jede Stadt Informationen in einzelnen csv des schreiben. Und jeder csv sollte wie unten aussehen. fertige Ausgabe:
Albuquerque.csv
long lat city date value
1 -106.6129 35.04333 Albuquerque 2017-08-22 12.0
2 -106.6129 35.04333 Albuquerque 2017-08-23 10.8
3 -106.6129 35.04333 Albuquerque 2017-09-24 18.3
Augusta.csv
long lat city date value
1 -81.97224 33.37378 Augusta 2017-09-28 12.4
2 -81.97224 33.37378 Augusta 2017-10-24 43.0
3 -81.97224 33.37378 Augusta 2017-09-22 21.0
Atlanta.csv
long lat city date value
1 -84.4277 33.64073 Atlanta 2017-11-12 12.0
2 -84.4277 33.64073 Atlanta 2017-010-14 32.1
3 -84.4277 33.64073 Atlanta 2017-09-03 14.0
Vielen Dank im Voraus!
Mögliches Duplikat [Wie mehr, CSV-Dateien in R erstellen?] (Https://stackoverflow.com/questions/8126984/how-to-create-multiple-csv-files-in-r) –
Sie haben keine 'state'-Spalte? – simone