Hi,
I'm working on an assessment for university. I have load tidyverse, and imported the data using read() to assign directly in the environment.
To explore the data I have used glimpse() and realised some variable needs to be changed. e.g., Camp_1 are dbl and I want to change to factor.
in all of our practices, we had to change to a factor.
to change it I did:
sales <- sales %>%
mutate_(sales, Camp_1=as.factor(Camp_1),
Camp_2=as.factor(Camp_2),
Camp_3=as.factor(Camp_3),
Camp_4=as.factor(Camp_4),
Camp_5=as.factor(Camp_5),
Camp_6=as.factor(Camp_6))
however I get the following message: Error in is.factor(x) : object 'Camp_1' not found
I don't understand the mistake I have made. If someone has an idea it would be very useful.
Thanks
mutate
is a different function from mutate_
try to swap that out.
Thank you now it works.
Now I'm trying to create a plot: ggplot(general_sales, aes(x=Campaign, y=general_sales))+
geom_col(fill="green", alpha=1)
but it says errors:
#Visual for General Sales with ggplot
ggplot(general_sales, aes(x=Campaign, y=general_sales))+
geom_col(fill="green", alpha=1)
Don't know how to automatically pick scale for object of type tbl_df/tbl/data.frame. Defaulting to continuous.
Error in check_aesthetics()
:
! Aesthetics must be either length 1 or the same as the data (994): y
Run rlang::last_error()
to see where the error occurred.
To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
system
Closed
May 3, 2022, 11:20am
5
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.