I have imported a file with headings and numbers in multiple columns using the following command.
irs_data <- read.csv(file="10incyallnoagi.csv")
I would like to divide the values in 1 column by another and then determine the highest 3 values.
salary_var <- c(irs_data[13]/irs_data[12])
head(sort(new_var, decreasing=TRUE), 3)
I keep getting the constant error. As a beginner to R, what does it mean "x must be atomic" in this context.
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
'x' must be atomic
salary_var <- c(irs_data[[13]]/irs_data[[12]])
. It's not clear ifnew_var
should actually besalary_var
in your sort command. If not, then we need more info. The error is there becausenew_var
is a list and lists are not atomic vectors. – Criderc(irs_data[,13]/irs_data[,12])
(but there's no need for thec()
in either case). Do astr(irs_data[13]))
vs astr(irs_data[,13])
orstr(irs_data[[13]])
to see the difference in type/class. – Enchanter