UserGuide BioStat Prime Help

Convert

Convert section of variable menu aids the user to convert a character variable to date, to factor, to ordered factor and vice versa.

Date to Character

Converts date (posixct and date class) to character -to control the format in which the date is displayed. User can specify as input the format in which the string should be generated i.e. year/month/Day or month-dat=year etc.

The function above internally calls strftime in the base package.

Date to Character

Character to Date & Time

Converts a date, time, or date time character string with partial or full date and time elements, i.e., date elements such as year, month, and day of the month to a date (POSIXct class) type or just the time such as Hour Min Sec Millisec, Hour Min Sec, .. to a full date (POSIXct class) type.

  1. Select a format from the possible list of formats from date formats if only date elements are available in the selected character string

  2. Select a time format the possible list of time formats if only time elements are available in the selected character string

  3. Select both date and time formats from the date and time formats selection list if both date and time elements are available in the selected character string

  4. Select the appropriate format that represents the date and time character string (i.e., order and presence/absence of month, day, or year or hour, min, seconds, or milliseconds elements)

  5. Many string preparation steps are performed internally before calling the functions from lubridate package to convert the prepared character date, time, or date time string to a new POSIXct date variable.

Character to Date & time

OPTIONS

Expand the OPTIONS to fine-tune further whether to use the current year, month, or today if the year, month, or date elements are absent in the character date string variable or current hour, minute, seconds if one or more time elements are missing from the character time string.

  • Date Formatting choices for the selected character date string variable are:

month day: Choose this when the selected character date string only contains the month followed by a day and no year, such as 03/17, 05-25, Mar,15 , May-21, ...

day month: Choose this when the selected character date string only contains the day followed by the month and no year, such as 17/03, 25-05, 15,Mar , 21-May,...

month year: Choose this when the selected character date string only contains the month followed by the year and no day of the month, such as 03/2024, 05-2020, Mar,2023 , Jul-2018,...

year month: Choose this when the selected character date string only contains the year followed by the month and no day of the month, such as 2024/03, 2020-05, 2023,Mar, 2018-Jul,...

year only: Choose this when the selected character date string only year and no day or month, such as 2020, 2024, 1995, ....

month only: Choose this when the selected character date string only month and no day or year, such as 03, 11, Mar, November, ....

day only: Choose this when the selected character date string only day and no month or year, such as day of the month as 03, 17, 28, or day of the week as Mon, Saturday, ....

year month day: Choose this when the selected character date string year, followed by month and day such as 2024/03/22, 2020-05-19, 2019,Mar,26,...

month day year: Choose this whenthe selected character date string contains the month, followed by day and year, such as 03/22/2024, 05-19-2020, Mar,26,2019,...

day month year: Choose this when the selected character date string contains a day, followed by a month and year, such as 22/03/2024, 19-05-2020, 26 March 2019,...

  • Time Formatting choices for the selected character date string variable are:

Hour Min Sec Choose this when the selected character date/time string contains Hour, followed by Minutes and Seconds, such as 22/03/2024 17:15:48, or just time as 17:15:48,...

Hour Min Sec Millisec (or Microsec) Choose this when the selected character date/time string contains Hour, followed by Minutes, Seconds, and Milliseconds, or Micro seconds, such as 22/03/2024 17:15:48.784, or just time as 17:15:48.784,17:15:48.784239,...

Min Sec Millisec (or Microsec) Choose this when the selected character time string contains Minutes, Seconds, and Milliseconds, or Micro seconds, such as just time 15:48.784,15:48.784239...

Hour Min Choose this when the selected character date/time string contains Hour, followed by Minutes, such as 22/03/2024 17:15, or just time 17:15,...

Min Sec Choose this when the selected character time string contains Minutes and Seconds such as time as 15:48,...

Sec Millisec (or Microsec) Choose this when the selected character time string contains Seconds, and Milliseconds, or Micro seconds, such as time as 48.784, 55.784239,...

Hour only Choose this when the selected character time string contains only Hour such as time as 10, 14, or 22,...

Min only Choose this when the selected character time string contains only Minutes such as time as 10, 29, 44, or 59,...

Sec only Choose this when the selected character time string contains only Seconds such as time as 10, 29, 44, or 59,...

Millisec only Choose this when the selected character time string contains only Milliseconds such as time as 10, 290, 448, or 759,...

Microsec only Choose this when the selected character time string contains only Microseconds such as time as 101, 2901, 448890, or 759123,...

Convert to Factor

The function factor is used to encode a vector as a factor (the terms ‘category’ and ‘enumerated type’ are also used for factors). If argument ordered is TRUE, the factor levels are assumed to be ordered. For compatibility with S there is also a function ordered. is.factor, is.ordered, as.factor and as.ordered are the membership and coercion functions for these classes.

Convert to Factor

Convert to ordered factor/ordinal

The function factor is used to encode a vector as a factor (the terms ‘category’ and ‘enumerated type’ are also used for factors). If argument ordered is TRUE, the factor levels are assumed to be ordered. For compatibility with S there is also a function ordered. is.factor, is.ordered, as.factor and as.ordered are the membership and coercion functions for these classes.

Convert to ordered factor/ordinal
Last modified: 31 July 2025