0

i wand import my data to CSV but without number Column or with numeric it . My code Very sorry for my bad english:

tab<-read.csv2("CENY.csv")
#View(tab)
library(reshape2)
tab.m<-melt(tab,id.vars="Nazwa")
View(tab.m)
dim(tab.m)
tab.m<-tab.m[5:436,]
mies<-rep(c("sty","lut","mar","kwi","maj","cze","lip","sie","wrz","paź","lis","gru"),each=36)
produkt<-rep(rep(c("cytryny","marchew","cebula"),each=12),12)
rok<-rep(rep(c(2017,2018,2019),each=4),36)
length(mies)
length(produkt)
length(rok)
dane.m<-data.frame(tab.m$Nazwa,tab.m$value,mies=mies,produkt=produkt,rok=rok)
#View(dane.m)
X<-split(dane.m, dane.m$produkt)
str(X)
dane <- X$cebula[,-4]
colnames(dane)<-c("region","cebula","mies","rok")
dane$cytryny<-X$cytryny$tab.m.value
dane$marchew<-X$marchew$tab.m.value
#View(dane)
write.csv(dane, "dane-ceny.csv")

and i get:

"","region","cebula","mies","rok","cytryny","marchew"
"25","POLSKA",1.78,"sty",2017,6.56,1.64
"26","MAZOWIECKIE",1.59,"sty",2017,6.9,1.57
"27","OPOLSKIE",1.77,"sty",2017,7.05,1.85
"28","PODKARPACKIE",1.39,"sty",2017,5.83,1.4
camille
  • 16,432
  • 18
  • 38
  • 60
  • 1
    [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. We can't run any of your code without your data, and really all we'd need in order to reproduce the issue would be whatever `dane` is in the last line of code. Are you trying to write a csv file without any numeric columns, or without the row numbers in the first column? – camille Jan 20 '22 at 18:39
  • Thank you for showing what you get - could you add what you want to get? – Gregor Thomas Jan 20 '22 at 18:53
  • All row.names=FALSE to the write.csv call. – G. Grothendieck Jan 20 '22 at 20:37
  • @G.Grothendieck thanks, its work! – NewRobot30 Jan 20 '22 at 22:02

0 Answers0