All other questions and answers I have seen on this have not been useful.
I have imported data from an Excel sheet into R and I want to remove all of the non-numeric data from a particular column so I can perform calculations. Ideally I would like to be able to create a function that does this.
Assuming the data frame is called price and the column I want is Q1: I have found answers to this question where I could do this by using
- convert <- as.numeric(as.character(price$Q1)
- ncolumn <-concert[!is.na(convert)]
However, when I try and create the function I want to have the inputs to be both the name of the data frame as well as the name of the column. I have tried using price[2] instead of price$Q1 in that first line I showed but it doesn't seem to work. I also tried extracting the name of the column and the name of the data frame and using the $ notation instead of [ ] and it still doesn't work.