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 value and mean of the data set.The difference is compared with standard deviation to find the outliers. va
#DATA LOAD
data <- read.csv('output9.csv')
height <- data$Height
hist(height) #histogram
#POPULATION PARAMETER CALCULATIONS
pop_sd <- sd(height)*sqrt((length(height)-1)/(length(height)))
pop_mean <- mean(height)
But I have this error after I tried the histogram part,
> hist(height)
Error in hist.default(height) : 'x' must be numeric
how should I fix this?
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 indata.frames. To subset one of your columns to use it for thehistyou can use the$operator. Be sure you subset on a column that actually exists. You can usenames(data)(ifdatais adata.frame) to find out what columns exist in your data. Usenrow(data)to find out how many rows there are in your data.After extracting your
heightyou can go further. First check that yourheightobject isnumericand has something in it. You can useclass(height)to find out.As you posted in your comment you have the following names
Therefore you can extract your
heightwithDid 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. Tryas.numeric("3")as an example.Here an example I made up.
This works just fine, because the data is numeric.
In the following the data are numbers but formatted as characters.
So you have to coerce it first:
..and then it works fine.
For future questions: Try to give Minimal, Complete, and Verifiable Examples.