What's wrong with the year? If you want to print a lovely list of birthdays, just omit the year when formatting the date (see format
for this).
I'll add some comments, because you are taking a lot of extra steps to do simple things. Firstly, in your question when creating your dates and names, you create a simple vector (with c
) and then wrap it into a matrix (a column-matrix in this case). I assume because you want to use cbind
. But cbind
also accepts vectors to join as columns.
Here's the short version to create the matrix:
xy <- c("09/08", "10/14", "10/06", "05/11", "02/23", "10/27",
"08/04", "11/29", "07/23", "12/17")
names <- c("G", "C", "R", "OB", "S", "B", "Ms", "Mi", "Ma", "A")
cbind(Name=names, Date=xy)
The issue with this approach is if you are combining several different data types, e.g. both characters and numbers. The resulting matrix
can only contain 1 data type at a time - and if any of the columns are a character vector, everything is reduced to characters. No more doing math on values saved as a character.
Second step is converting to a data.frame. But you could just create the data.frame directly:
data.frame(Name=names, Date=xy)
If your goal is to sort by, you strictly don't have to convert them to dates, because you already have the format starting with month.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…