hi, can anybody helps me with this?
Is the result of
mode(Book1[, "SPI"])
"numeric"?
Oops! I just saw you did that test. Never mind.
oh no, the result of mode(Book1[, "SPI"])
is "list"
what should i do?
Are you sure you didn't run
mode(Book1)
by mistake? You already tested
class(Book1[, "SPI"])
and got "numeric". If you run mean(Book1[, "SPI"])
, do you get an error or a number? If you get a number, the the problem lies with sens.slope not seeing the data as numeric. If you get an error, then somehow your result using class() is misleading me.
Also, try running sens.slope on another data frame with data others can reproduce.
DF <- data.frame(SPI = rnorm(100))
sens.slope(DF[, "SPI"])
I have to stop for the day but others should be able to help you.
As @FJCC notes, irreproducible problems breed few answers.
See the FAQ: How to do a minimal reproducible example reprex
for beginners.
Eyeballing it (subject to the vagaries of eyes older than 70), it looks like this is similar to
class(mtcars$mpg)
#> [1] "numeric"
which doesn't need sapply
at all.
i got it like this! but why when i;
sens.slope(Book1[,"SPI"])
i get 'x' is not a numeric?
and when i mean;
i get an error
There's only so much that's possible with a screenshot.
See the FAQ: How to do a minimal reproducible example reprex
for beginners.
Books1 must be a tibble which is a type of data.frame
The square bracket syntax works differently for it than a traditional data.frame.
library(dplyr)
(irisframe <- head(iris))
(iristibble <- tibble(irisframe))
# $ syntax - same
irisframe$Sepal.Length
iristibble$Sepal.Length
# square bracket syntax - different
irisframe[,"Sepal.Length"]
iristibble[,"Sepal.Length"]
# dplyr syntax - same
irisframe %>% pull(Sepal.Length)
irisframe %>% pull("Sepal.Length")
iristibble %>% pull(Sepal.Length)
iristibble %>% pull("Sepal.Length")
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.