{"id":3468,"date":"2023-07-17T08:16:54","date_gmt":"2023-07-17T08:16:54","guid":{"rendered":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/"},"modified":"2023-07-17T08:16:54","modified_gmt":"2023-07-17T08:16:54","slug":"la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/","title":{"rendered":"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un errore comune che potresti riscontrare in R \u00e8:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>Error in as.POSIXlt.character(x, tz, ...): \n  character string is not in a standard unambiguous format\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Questo errore si verifica in genere quando si tenta di convertire un oggetto in R in un formato data, ma l&#8217;oggetto \u00e8 attualmente un carattere o un fattore.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Per correggere questo errore, devi prima convertire l&#8217;oggetto in digitale.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial spiega come correggere questo errore nella pratica.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Come riprodurre l&#8217;errore<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Supponiamo di avere il seguente frame di dati in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (date=c('1459397140', '1464397220', '1513467142'),\n                 sales=c(140, 199, 243))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n        dirty date\n1 1459397140 140\n2 1464397220 199\n3 1513467142 243<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Supponiamo ora di provare a convertire i valori della colonna <strong>della data<\/strong> in un formato di data:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#attempt to convert values in date column to date\n<\/span>df$date &lt;- as. <span style=\"color: #3366ff;\">POSIXct<\/span> (df$date, origin=' <span style=\"color: #ff0000;\">1970-01-01<\/span> ')\n\nError in as.POSIXlt.character(x, tz, ...): \n  character string is not in a standard unambiguous format\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Riceviamo un errore perch\u00e9 i valori della colonna <strong>della data<\/strong> sono attualmente in formato carattere, che la funzione <strong>as.POSIXct()<\/strong> non \u00e8 in grado di gestire.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Come correggere l&#8217;errore<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Per correggere questo errore, dobbiamo utilizzare <strong>as.numeric()<\/strong> per convertire prima i valori della colonna <strong>della data<\/strong> in un formato numerico, che \u00e8 un formato che <strong>as.POSIXct<\/strong> pu\u00f2 gestire:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#convert values in date column to date\n<\/span>df$date &lt;- as. <span style=\"color: #3366ff;\">POSIXct<\/span> (as. <span style=\"color: #3366ff;\">numeric<\/span> (as. <span style=\"color: #3366ff;\">character<\/span> (df$date)), origin=' <span style=\"color: #ff0000;\">1970-01-01<\/span> ')\n\n<span style=\"color: #008080;\">#view updated data frame\n<\/span>df\n\n                 dirty date\n1 2016-03-31 04:05:40 140\n2 2016-05-28 01:00:20 199\n3 2017-12-16 23:32:22 243<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Questa volta non riceviamo un errore e siamo in grado di convertire correttamente i valori della colonna <strong>della data<\/strong> nel formato data perch\u00e9 abbiamo prima convertito i valori nel formato numerico.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come correggere altri errori comuni in R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/loggetto-r-list-non-puo-essere-forzato-a-digitare-double\/\" target=\"_blank\" rel=\"noopener\">Come risolvere il problema: non \u00e8 possibile forzare l&#8217;oggetto (elenco) a digitare &#8220;doppio&#8221;<\/a><br \/> Come risolvere il problema in R: formula modello non valida in ExtractVars<br \/><a href=\"https:\/\/statorials.org\/it\/r-sostituzione-a-lunghezza-zero\/\" target=\"_blank\" rel=\"noopener\">Come riparare in R: la sostituzione ha lunghezza zero<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un errore comune che potresti riscontrare in R \u00e8: Error in as.POSIXlt.character(x, tz, &#8230;): character string is not in a standard unambiguous format Questo errore si verifica in genere quando si tenta di convertire un oggetto in R in un formato data, ma l&#8217;oggetto \u00e8 attualmente un carattere o un fattore. Per correggere questo errore, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco: Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come correggere il seguente errore in R: la stringa di caratteri non \u00e8 in un formato standard univoco.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco: Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come correggere il seguente errore in R: la stringa di caratteri non \u00e8 in un formato standard univoco.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-17T08:16:54+00:00\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/\",\"url\":\"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/\",\"name\":\"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco: Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-17T08:16:54+00:00\",\"dateModified\":\"2023-07-17T08:16:54+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come correggere il seguente errore in R: la stringa di caratteri non \u00e8 in un formato standard univoco.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco: Statorials","description":"Questo tutorial spiega come correggere il seguente errore in R: la stringa di caratteri non \u00e8 in un formato standard univoco.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/","og_locale":"it_IT","og_type":"article","og_title":"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco: Statorials","og_description":"Questo tutorial spiega come correggere il seguente errore in R: la stringa di caratteri non \u00e8 in un formato standard univoco.","og_url":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/","og_site_name":"Statorials","article_published_time":"2023-07-17T08:16:54+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/","url":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/","name":"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco: Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-17T08:16:54+00:00","dateModified":"2023-07-17T08:16:54+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come correggere il seguente errore in R: la stringa di caratteri non \u00e8 in un formato standard univoco.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/la-stringa-di-caratteri-non-e-in-un-formato-standard-univoco\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come risolvere il problema: la stringa non \u00e8 in un formato standard univoco"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3468"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=3468"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3468\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}