I noticed that thought using dplyr
is quite handy when handling dataframe, sometimes when using select
or slice
, the resulting data.frame cannot be converted to numeric
, in order to do subsequent analysis, such as linear regression.
Here is my simple codes, where I want to select the first 100 rows:
Y <- data.frame(rnorm(1000,0,1))
Y_used <- Y %>% slice_head( n = 100)
The vector Y_used
is of data.frame
, and the function as.numeric()
seems not working.
If I still want to use slice
to select it, how can I convert Y_used
to numeric
? Thanks!