Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

r - Undefined columns selected when cleaning data frame

I am cleaning my data frame with 136 columns. While doing so, I put the columns in the right order and removed some by making a subset of the data frame.

but then I try to run it I get an error:

Error in [.data.frame(Stnd_valerie_dataset, (DFfinalAdult_22jan)) : undefined columns selected

I already checked the gramma of my new subset but can not find a mistake..

I hope someone can tell me how to fix this!

question from:https://stackoverflow.com/questions/65846860/undefined-columns-selected-when-cleaning-data-frame

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Since we don't have the full dataframe to look at, it's going to be hard to give a full answer. That being said, running the subset function multiple times, each time adding a column, will tell you where your issue is.

foo <- df['a']
foo <- df['a','b']

Alternatively, you can do something similar, but with select() from dplyr:


foo <- df %>%
select('a','b')

You'll get an error message telling you which columns don't exist.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...