Right now I'm trying to do a bell curve on a file called output9.csv on my.
Here is my code, I want to uses z score to detect outliers, and uses the difference between the va
#POPULATION PARAMETER CALCULATIONS
pop_sd <- sd(height)*sqrt((length(height)-1)/(length(height)))
pop_mean <- mean(height)
Error in hist.default(height) : 'x' must be numeric
Since I don't have your data I can only guess. Can you provide it? Or at least a portion of it?
What class is your data? You can use
class(data) to find out. The most common way is to have table-like data in
data.frames. To subset one of your columns to use it for the
hist you can use the
$ operator. Be sure you subset on a column that actually exists. You can use
data is a
data.frame) to find out what columns exist in your data. Use
nrow(data) to find out how many rows there are in your data.
After extracting your
height you can go further. First check that your
height object is
numeric and has something in it. You can use
class(height) to find out.
Did you try to convert it to numeric?
as.numeric(height) might do the trick.
as.numeric() can coerce all things that are stored as characters but might also be numbers automatically. Try
as.numeric("3") as an example.
Here an example I made up.
height <- c(1,1,2,3,1) class(height) #  "numeric" hist(height)
This works just fine, because the data is numeric.
In the following the data are numbers but formatted as characters.
height_char <- c("1","1","2","3","1") class(height_char) #  "character" hist(height_char) # Error in hist.default(height) : 'x' must be numeric
So you have to coerce it first:
..and then it works fine.
For future questions: Try to give Minimal, Complete, and Verifiable Examples.