Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

How do I convert Excel char variables to numeric values after importing from Excel in R

I know similar questions have been asked in the past but I am not able to find any that can solve my particular issue.

I have a data set which I have imported from Excel using both the read_excel function as well as trying to select file > import dataset > from excel. When I import the data it shows the columns with values in as 'doubles' but when I then view the data type using str(), once imported, it shows these as being a char variable. I have used many different functions to try convert from char to integer but I keep getting the 'NAs introduced by coercion' warning and the command does not seem to work.

The function I see come up mostly is as.numeric(as.character()) but this does not work.

The most common problem I see people having is that their data has "," however my data seems to be formatted correctly using ".".

This is causing me issues as I am then not able to filter out values outside of a certain range.

Would anyone have any ideas on what I could be doing wrong as I have literally spent hours trying to solve for this issue and am now completely stuck but sure it is a simple fix.

question from:https://stackoverflow.com/questions/65871478/how-do-i-convert-excel-char-variables-to-numeric-values-after-importing-from-exc

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...