Hi Stefano, maybe something like this can help you? myfactor <- as.factor(c(2024, 2, 1, 0, 0))
# Convert factor values to integers first_element <- as.integer(as.character(myfactor)[1]) second_element <- as.integer(as.character(myfactor)[2]) third_element <- as.integer(as.character(myfactor)[3]) # Print the results first_element [1] 2024 second_element [1] 2 third_element [1] 1 # Check the type of the object typeof(first_element) [1] "integer" Fabio Il giorno gio 28 mar 2024 alle ore 11:29 Stefano Sofia < stefano.so...@regione.marche.it> ha scritto: > Dear R-list users, > > forgive me for this silly question, I did my best to find a solution with > no success. > > Suppose I have a factor type like > > > myfactor <- as.factor(2024, 2, 1, 0, 0) > > > There are no characters (and therefore strsplit for eample does not work). > > I need to store separately the 1st, 2nd and 3rd elements as integers. How > can I do? > > > Thank you for your help > > Stefano > > > (oo) > --oOO--( )--OOo-------------------------------------- > Stefano Sofia PhD > Civil Protection - Marche Region - Italy > Meteo Section > Snow Section > Via del Colle Ameno 5 > 60126 Torrette di Ancona, Ancona (AN) > Uff: +39 071 806 7743 > E-mail: stefano.so...@regione.marche.it > ---Oo---------oO---------------------------------------- > > ________________________________ > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere > informazioni confidenziali, pertanto è destinato solo a persone autorizzate > alla ricezione. I messaggi di posta elettronica per i client di Regione > Marche possono contenere informazioni confidenziali e con privilegi legali. > Se non si è il destinatario specificato, non leggere, copiare, inoltrare o > archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, > inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio > computer. Ai sensi dell'art. 6 della DGR n. 1394/2008 si segnala che, in > caso di necessità ed urgenza, la risposta al presente messaggio di posta > elettronica può essere visionata da persone estranee al destinatario. > IMPORTANT NOTICE: This e-mail message is intended to be received only by > persons entitled to receive the confidential information it may contain. > E-mail messages to clients of Regione Marche may contain information that > is confidential and legally privileged. Please do not read, copy, forward, > or store this message unless you are an intended recipient of it. If you > have received this message in error, please forward it to the sender and > delete it completely from your computer system. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.