Re: [R] split a factor into single elements

2024-03-28 Thread Fabio D'Agostino
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])

[R] '[' vs subset() behaviors when filtering a dataframe with NA values

2022-02-19 Thread Fabio D'Agostino
Hi All, I just have two questions since I did not understand the behavior of '[' vs the subset() function when filtering a dataframe that has NA values I was filtering a dataframe named 'weight' according to values of the column named 'weight_rec' ... str(weight) 'data.frame': 17307 obs. of 6

Re: [R] how to remove factors from whole dataframe?

2021-09-19 Thread Fabio D'Agostino
Hi Luigi, try this library(taRifx) df_noFact <- remove.factors(df) str(df_noFact) 'data.frame': 5 obs. of 3 variables: $ region : chr "A" "B" "C" "D" ... $ sales : num 13 16 22 27 34 $ country: chr "a" "b" "c" "d" ... I hope this helps Fabio Il giorno dom 19 set 2021 alle ore 12:04 Luigi