0

I have a big project to work on and the dataset is classified so I am just going to use my own example so everyone can understand what I am targeting.

Let's take Target as an example: We consider three brands of tape: Target brand, 3M and Avery. The original data frame has 4 columns: Year of Record, Product_Name(which contains three brands of tape), Sales, and Region.

The original data frame will look like this:

   Year of Record      Product_Name        Sales       Region
     2018              Target_Brand        2000$        Midwest
     ...                ...                 ...          ...
     2018               Avery               9000$       Central America

I want to create a visualization based on, for instance, region, sales, etc.

Should I use barplot?

Second question

My R code says this when I run multiple regression model:

data = read.excel(...) data1 = subset(data, Product_Name == "Target Brand")

model = lm(Product_Name ~ ., data1)

Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
contrasts can be applied only to factors with 2 or more levels
In addition: Warning message:
In storage.mode(v) <- "double" : NAs introduced by coercion

How can I approach this scenario?

(P.S: My real dataset has about 36 columns and I truncate down to 21 columns. That is why I use the notation ~.)

I need help. Please give me guidance.

Adam Ralphus
  • 339
  • 3
  • 14
  • The reproducible example is not complete. Please provide some sample data and expected output. – MKR Jun 01 '18 at 15:53
  • @Chris I did post a sample. Please let me know if I can help clarify my question better. Thanks all! – Adam Ralphus Jun 01 '18 at 16:12
  • It looks like the original dataset is already in the perfect form for the analysis you wish to perform – Chris Jun 01 '18 at 16:12
  • @Chris My goal is that I want to look at the Target Brand variable, analyze the data set (decision tree analysis maybe?) to make a decision whether I should invest more Target brand in Mid-west or Central america. I am trying to profile data to provide a good data visualization. – Adam Ralphus Jun 01 '18 at 16:15
  • @AdamRalphus your data is in so called 'tidy' form already with each column representing a variable - perfect for analysis with `dplyr` and `ggplot2` for example. If you have a specific visualization/ analysis in mind then maybe consider a more pointed question. – Chris Jun 01 '18 at 16:21
  • @Chris Hello Chris, is this a good place to have follow up question or should I create a new post? – Adam Ralphus Jun 01 '18 at 16:24
  • If it is a different question then make a new one, if still similar then edit. Be sure to provide a reproducible example to help people to provide an answer – Chris Jun 01 '18 at 16:30
  • @Chris I edited my post. Thanks for the help! – Adam Ralphus Jun 01 '18 at 16:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/172260/discussion-between-chris-and-adam-ralphus). – Chris Jun 01 '18 at 16:47

0 Answers0