0
I have a data.frame in which I need to perform a correlation matrix.
I’ve already sorted the numerical data by the command select_if(is.numeric)
as suggested by the colleague at link.
However, in my data.frame there is still a die with different class of "Numeric", ie, there is a class column list
, which is one to sf()
of a polygon of the state. I tried to apply the command select(- )
in the column list
and also the command distinct_at(vars(-))
and other web tips, but did not solve. Finally I still can not make the correlation because of this list
.
unfortunately I cannot reproduce an example of list
here, but there is an image of part of my df.
hello @Rui Barradas. I tested the solutions, however I was not successful in removing the "list" from my data frame. The clarification title I used the GEOBR package to create this data.frame. I see that the solution you put works to remove the "list" from the example dataframe, but in my case it did not work. When using the
sapply
, it creates a new column with False and True values. The commandselect(where(is.numeric))
actually separates only the Numeric data, but the columngeom
with thelist
still remains, I would use this command in another situation. But unfortunately in my case it has not worked yet.– wesleysc352
@wesleysc352 Can you please, edit the question with the departure of
dput(dados)
or, if the base is too large,dput(head(dados, 20))
?– Rui Barradas
ola @Rui Barradas, as my df has a
list
withsf()
it will get huge, but I’ll put– wesleysc352
ola @Rui Barradas I tried to do dput(head(data, 1)), but Stackoverflow only allows 30thousand characters and mine gave 34thousand. As I said, I used GEOBR to create my df, this package takes all the coordinates of a county boundary and puts inside the df in the format of
list
.– wesleysc352
@wesleysc352 Then post the output of
str(dados)
, please. Or, even better, code that allows you to create a base with similar structure but not necessarily the same size. (34,000 is too much, it’s possible much smaller?)– Rui Barradas
hello a little while ago I opened the question, but I managed to solve the problem in a very simple way I do not know if it applies to the other case:
df2<-df %>% st_set_geometry (NULL)
was able to remove columns of typelist
– wesleysc352