-4

Hey guys i am really new to r and i am having difficulty in implementing the code i am attaching the csv file , in that csv file i need to create a table showing the average salary of males and females CSV file for the data can you guys please me with these questions :

Q1 . Use R to create a table showing the average salary of males and females, who were placed. Review whether there is a gender gap in the data. In other words, observe whether the average salaries of males is higher than the average salaries of females in this dataset. and also i need to run a t-test to test the following hypothesis: H1: The average salary of the male MBAs is higher than the average salary of female MBAs.

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 5
    Show us what you tried. We are not here to do your work for you. And please see https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question – GhostCat Jun 20 '17 at 13:12

1 Answers1

0

Please see GhostCat's comment link about asking a question. That being said, the following may help you figure out how to do what you ask.

There are a few handy functions that you may want to familiarize yourself with. To read csv files you will need to run read.csv where you can press the tab key to inform you of arguments you can enter- for example, header = TRUE which says the first row of the csv is only header information.

dat <- read.csv(file = "~\WHERE\FILENAME.csv", header = TRUE)

To save save any object as a data.frame you can use as.data.frame or data.frame functions.

df <- as.data.frame(dat)

To split a data.frame by some value into separate lists you can use the split function.

df_Gender <- split(df, df$Gender)

The best way to work on lists is to familiarize yourself with the apply family of functions (see a full and runnable explanation R Grouping functions: sapply vs. lapply vs. apply. vs. tapply vs. by vs. aggregate).

If you run into very specific trouble while working on a step please search furiously before posting a question. Best of luck.

Evan Friedland
  • 3,062
  • 1
  • 11
  • 25
  • I am new to this , so sorry for annoying by posting the whole question . My bad – vaishali aggarwal Jun 21 '17 at 08:38
  • I have made a data frame for a table and now i want to find the average in this table of a certain column . **> dean.df <- table(mba.df$Gender , mba.df$Placement ) > View(dean.df)** – vaishali aggarwal Jun 21 '17 at 08:39
  • so i added mean function 'dean.df <- table(mba.df$Gender , mba.df$Placement , mean) Error in table(mba.df$Gender, mba.df$Placement, mean) : all arguments must have the same length' – vaishali aggarwal Jun 21 '17 at 08:42
  • I highly recommend looking up some introductory R materials if you are just looking to find the mean of column... mean(mba.df$Gender) would give you the mean of that vector. – Evan Friedland Jun 21 '17 at 11:58
  • Or mean(dean.df[, x]) where x is the column you want to subset – Evan Friedland Jun 21 '17 at 12:23