如何使用substr函数创建新文件而不创建列表



我正在尝试使用substr函数来更改我的一个文件中的时间

我想把created_at times从mdy/hms改为mdy only

substr(jointTweet2$created_at.x, 1,10)

这样做可以工作,但不会改变我的文件

中的日期
jointTweet2 <- substr(jointTweet2$created_at.x, 1,10)

这样做会创建一个列表而不是

如何在不创建列表的情况下更改时间?我附上了我的数据,通过dput

structure(list(author_id = c("1000023272250118144", "1000030523270496262", 
"1000043409212674048", "1000050535649759232", "1000051189986177025", 
"1000060938463170560"), possibly_sensitive = c(FALSE, FALSE, 
FALSE, TRUE, FALSE, FALSE), created_at.x = c("2021-06-13T01:42:23.000Z", 
"2021-02-10T17:55:43.000Z", "2021-04-09T22:31:24.000Z", "2021-04-19T16:11:28.000Z", 
"2021-01-11T10:06:43.000Z", "2021-01-16T11:30:34.000Z"), lang = c("en", 
"en", "en", "en", "en", "en"), source = c("Twitter Web App", 
"Twitter Web App", "Twitter Web App", "Twitter Web App", "Twitter for Android", 
"Twitter Web App"), public_metrics.x = structure(list(retweet_count = c(0L, 
1L, 4L, 4L, 0L, 27L), reply_count = c(0L, 0L, 1L, 0L, 0L, 5L), 
like_count = c(1L, 0L, 5L, 39L, 0L, 125L), quote_count = c(0L, 
0L, 0L, 0L, 0L, 0L)), row.names = c(302733L, 69371L, 179801L, 
198715L, 15735L, 24450L), class = "data.frame"), id = c("1403890461387919362", 
"1359561699733430273", "1380649576164642817", "1384177838757072906", 
"1348572038705733635", "1350405079216640003"), entities.x = structure(list(
hashtags = list(structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(start = c(13L, 22L, 33L, 43L, 53L, 63L, 
74L), end = c(21L, 32L, 42L, 52L, 62L, 73L, 78L), tag = c("gamedev", 
"gamemaker", "pixelart", "aseprite", "indiedev", "indiegame", 
"art")), class = "data.frame", row.names = c(NA, 7L)), 
structure(list(), .Names = character(0)), structure(list(
start = c(21L, 32L, 38L, 45L, 54L, 64L), end = c(31L, 
37L, 44L, 53L, 63L, 69L), tag = c("IndieGame", "jRPG", 
"RM2k3", "RPG<U+30C4><U+30AF><U+30FC><U+30EB>", "PixelArt", 
"<U+30C9><U+30C3><U+30C8><U+7D75>")), class = "data.frame", row.names = c(NA, 
6L))), urls = list(structure(list(start = 62L, end = 85L, 
url = "", expanded_url = "", 
display_url = ""), class = "data.frame", row.names = 1L), 
structure(list(start = 197L, end = 220L, url = "", 
expanded_url = "https://twitter.com/FroppleStudios/status/1359552958309019653", 
display_url = ""), class = "data.frame", row.names = 1L), 
structure(list(start = c(23L, 55L, 101L, 154L, 222L), 
end = c(46L, 78L, 124L, 177L, 245L), url = c(""
), expanded_url = c(""), display_url = c(""
), status = c(NA, NA, 200L, NA, NA), unwound_url = c(NA, 
NA, "", 
NA, NA)), class = "data.frame", row.names = c(NA, 
5L)), structure(list(start = 79L, end = 102L, url = "", 
expanded_url = "", 
display_url = "", media_key = "7_1384177629943590919"), class = "data.frame", row.names = 1L), 
structure(list(start = 50L, end = 73L, url = "", 
expanded_url = "", 
display_url = ""), class = "data.frame", row.names = 1L), 
structure(list(start = 70L, end = 93L, url = "", 
expanded_url = "", 
display_url = "", media_key = "3_1350404601623830529"), class = "data.frame", row.names = 1L)), 
annotations = list(structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0))), mentions = list(
structure(list(start = 90L, end = 98L, username = "YouTube", 
id = "10228272"), class = "data.frame", row.names = 1L), 
structure(list(start = 34L, end = 49L, username = "FroppleStudios", 
id = "1359175250156679171"), class = "data.frame", row.names = 1L), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(start = 4L, end = 15L, username = "TimBledsoe", 
id = "20614993"), class = "data.frame", row.names = 1L), 
structure(list(), .Names = character(0))), cashtags = list(
NULL, NULL, NULL, NULL, NULL, NULL)), row.names = c(302733L, 
69371L, 179801L, 198715L, 15735L, 24450L), class = "data.frame"), 
conversation_id = c("1403890461387919362", "1359561699733430273", 
"1380649576164642817", "1384177838757072906", "1348572038705733635", 
"1350405079216640003"), text = c("RoboDunk - Reveal Trailer  Roguelite Basketball Combat for PC  via @YouTube", 
"Currently working on a project at @FroppleStudios nThose interested in following the development of an indie game be sure to follow. We are still in early stages but we will show more when we can. ", 
"My stuff: Wood carving and Crafting Also you can check my brother's work here: He's making a cool indie game", 
"Gutter waysnn#gamedev #gamemaker #pixelart #aseprite #indiedev #indiegame #art ", 
"Hey @TimBledsoe here's a new indie game for you.  ", 
"Mountainous ridge <U+0001F332>nn#IndieGame #jRPG #RM2k3 #RPG<U+30C4><U+30AF><U+30FC><U+30EB> #PixelArt #<U+30C9><U+30C3><U+30C8><U+7D75> "
), attachments = structure(list(media_keys = list(structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
"7_1384177629943590919", structure(list(), .Names = character(0)), 
"3_1350404601623830529"), poll_ids = list(structure(list(), .Names = character(0)), 
NULL, structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), NULL)), row.names = c(302733L, 
69371L, 179801L, 198715L, 15735L, 24450L), class = "data.frame"), 
geo = structure(list(place_id = c(NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_
), coordinates = structure(list(coordinates = list(NULL, 
NULL, NULL, NULL, NULL, NULL), type = c(NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, 
NA_character_)), row.names = c(302733L, 69371L, 179801L, 
198715L, 15735L, 24450L), class = "data.frame")), row.names = c(302733L, 
69371L, 179801L, 198715L, 15735L, 24450L), class = "data.frame"), 
referenced_tweets = list(structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0))), `FTweet$id` = c("1403890461387919362", 
"1359561699733430273", "1380649576164642817", "1384177838757072906", 
"1348572038705733635", "1350405079216640003"), created_at.y = c("2018-05-25T14:38:22.000Z", 
"2018-05-25T15:07:11.000Z", "2018-05-25T15:58:23.000Z", "2018-05-25T16:26:42.000Z", 
"2018-05-25T16:29:18.000Z", "2018-05-25T17:08:02.000Z"), 
verified = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), protected = c(FALSE, 
FALSE, FALSE, FALSE, FALSE, FALSE), public_metrics.y = structure(list(
followers_count = c(58L, 38L, 304L, 1444L, 4003L, 3696L
), following_count = c(27L, 323L, 255L, 531L, 273L, 1806L
), tweet_count = c(2721L, 7212L, 6082L, 663L, 11167L, 
1531L), listed_count = c(2L, 0L, 1L, 21L, 55L, 53L)), row.names = c("56366", 
"20397", "39153", "41987", "7173", "9740"), class = "data.frame"), 
entities.y = structure(list(url = structure(list(urls = list(
structure(list(start = 0L, end = 23L, url = "", 
expanded_url = "", display_url = "oldgamers.net"), class = "data.frame", row.names = 1L), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(
start = 0L, end = 23L, url = "", 
expanded_url = "", display_url = "castjunkie.com"), class = "data.frame", row.names = 1L), 
structure(list(start = 0L, end = 23L, url = "", 
expanded_url = "", 
display_url = ""), class = "data.frame", row.names = 1L))), row.names = c("56366", 
"20397", "39153", "41987", "7173", "9740"), class = "data.frame"), 
description = structure(list(urls = list(structure(list(
start = 87L, end = 110L, url = "", 
expanded_url = "", display_url = ""), class = "data.frame", row.names = 1L), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0))), hashtags = list(
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(start = 80L, end = 101L, tag = "SupportIndiePodcasts"), class = "data.frame", row.names = 1L), 
structure(list(), .Names = character(0))), mentions = list(
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(start = 74L, end = 85L, username = "Callia_wen"), class = "data.frame", row.names = 1L), 
structure(list(), .Names = character(0)), structure(list(), .Names = character(0)), 
structure(list(start = 7L, end = 22L, username = "BelovedRapture"), class = "data.frame", row.names = 1L)), 
cashtags = list(NULL, NULL, structure(list(), .Names = character(0)), 
NULL, structure(list(), .Names = character(0)), 
NULL)), row.names = c("56366", "20397", "39153", 
"41987", "7173", "9740"), class = "data.frame")), row.names = c("56366", 
"20397", "39153", "41987", "7173", "9740"), class = "data.frame"), 
username = c("oldgamers_TV", "DavidSantosDev", "Senti_nelle", 
"_AERYS_", "castjunkie", "BelovedRapture"), location = c("Houston, TX", 
NA, "Mon PV : @JeanJean_PV", "Northern Ireland", "Washington, USA", 
"Boston, MA"), description = c("Oldgamers shares gaming news & Support streamers.nAd* Video Games Best Deals are here: ", 
"", "Artisan de l'art. <U+2606> I draw big mechas, dragons and OCsnHunting partner of @Callia_wen", 
"Game Developer | 20 | UK | Thank You All So Much For 1400 Followers! Big fan of Adventure Time. Commissions open :D", 
"Host of vibrant Discord community with thousands of podcast creators/listeners. #SupportIndiePodcasts", 
"Dev of @BelovedRapture, a SNES-styled indie RPG game. <U+0001F3AE><U+0001F3F3><U+FE0F><U+200D><U+0001F308><U+0001F338>"
), pinned_tweet_id = c(NA, NA, "1380649576164642817", NA, 
"1515503033177673729", "1455620363564556291"), name = c("oldgamers_TV", 
"David", "Sentinelle <U+0001F47A>", "Aerys", "CastJunkie", 
"Blind"), withheld = structure(list(country_codes = list(
NULL, NULL, NULL, NULL, NULL, NULL)), row.names = c("56366", 
"20397", "39153", "41987", "7173", "9740"), class = "data.frame"), 
`FUsers$id` = c("1000023272250118144", "1000030523270496262", 
"1000043409212674048", "1000050535649759232", "1000051189986177025", 
"1000060938463170560")), row.names = c(NA, 6L), class = "data.frame")

很抱歉添加了所有的数据,我希望它能工作我必须手动删除URL

使用以下函数进行修复:

system.time(jointTweet2$created_at.x <- as.Date(jointTweet2$created_at.x))

不知道为什么其余的不工作

最新更新