It looks like you have a typo in the definition of your data.frame. The name of the third column is missing the quote at the beginning.
Data.frames in R can only have the same number of elements for each column. For example, this works:
# define vectors of the same length
waga_linkow <- rnorm(10)
selekcja <- 1:10
selekcja2 <- c(rep("wieczór", 5), rep("dzień",5))
# combine vectors into a data frame
mojeDane = data.frame('Numer'= waga_linkow , 'Zarażenie nr 1.'= selekcja, 'Zarażenie nr 2'= selekcja2)
# save the data
write.csv2(mojeDane, 'wynik.csv', row.names = F, na = '', fileEncoding = 'Windows-1250')
If you original values are vectors or various lengths, then you can save them as a list and then save it in Rdata format:
# define vectors of the various length
waga_linkow <- rnorm(10)
selekcja <- 1:20
selekcja2 <- c(rep("wieczór", 5), rep("dzień",1))
# save as a list
mojeDane.list = list('Numer'= waga_linkow , 'Zarażenie nr 1.'= selekcja, 'Zarażenie nr 2'= selekcja2)
# Save to a file
save(mojeDane.list, file="wynik.Rdata")
To load Rdata file back into R use load()
function
If you nned to save columns of different lenght in csv.format you can add missing values to the shorter vectors and write the output with na=' '
:
# Assuming selekcja is the longest vector in the data
df <- data.frame('Zarażenie nr 1.'= selekcja,
'Numer' = waga_linkow[seq(selekcja)],
'Zarażenie nr 2' = selekcja2[seq(selekcja)])
# Assuming you want spaces for missing values
write.csv(df, "output.csv",row.names=F, quote=FALSE, na=" ")
