in Education by
I have the following data frame: df = data.frame(date = "23-12-09 22:52") This code works fine: strptime(df$date, "%d-%m-%y %H:%M") # [1] "2009-12-23 22:52:00 CET"` But if I try it using mutate_at I get an error: dplyr::mutate_at(df, vars(date), strptime, "%d-%m-%y %H:%M") Error in mutate_impl(.data, dots) : Column "date" is of unsupported class POSIXlt` I would like to understand why my mutate_at statement doesn't work. (I don't need an alternative solution. This question is purely educational.) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
After applying strptime class of date column becomes POSIXlt class(strptime(df$date, "%d-%m-%y %H:%M")) #[1] "POSIXlt" "POSIXt" dplyr doesn't want to handle objects of class POSIXlt because of the reasons mentioned here. So you need to have objects of other class in dplyr chain. Maybe a character dplyr::mutate_at(df, vars(date), ~ as.character(strptime(., "%d-%m-%y %H:%M"))) # date #1 2009-12-23 22:52:00 Or a POSIXct object dplyr::mutate_at(df, vars(date), ~ as.POSIXct(., format = "%d-%m-%y %H:%M")) # date #1 2009-12-23 22:52:00

Related questions

0 votes
    If commands are stored in an external file, say commands.R in the working directory work, they may be executed ... of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I am trying to consume this API for dart using Flutter: https://pixcut.wondershare.com/api.html. My ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 6, 2022 in Education by JackTerrance
0 votes
    Parallel processing is done via __________ package can make the elapsed time smaller than the user time. (a) ... of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    The ________ for R are the main feature that make it different from the original S language. (a) scoping ... of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    which of the following statement make a mosaic plot? (a) histogram() (b) mosaicplot() (c) bar() (d ... Regression of R Programming Select the correct answer from above options...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    Which of the following method make vector of repeated values? (a) rep() (b) data() (c) view() (d ... Linear Regression of R Programming Select the correct answer from above options...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    Can someone please tell me some tips to make a great minimal reproducible r example? And How can I paste data ... should I include? Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    I am trying to make an app that can get the patient's symptoms as inputs and outputs the three most likely ... classes[sortedshit[2]]) Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I've been trying to use plot_ly with transforms (ultimately to subset data from a dropdown menu) and a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    My initial dataframe looks: library(tidyverse) df...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    My initial dataframe looks: library(tidyverse) df...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    Regex has a character for or but what is the character for and? For example, say I have a folder with the following files: ... to get an and on a regex and got confused. data x...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I am trying to connect to remote site via https and download some information. I am doing this: library("httr") library("XML") library(RCurl) url...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I have the following data frame, I want to find the name of the column with the minimum date for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    A ________________ in R programming language can also contain numeric and alphabets along with special characters like ... Programming Select the correct answer from above options...
asked Feb 16, 2022 in Education by JackTerrance
...