1. Load in the data. Convert each column to an ordered factor with appropriate labels

  1. Load in the data. Convert each column to an ordered factor with appropriate labels
s50_1995 = read.table("s50_1995.txt",header = 1)
s50_1995$alcohol = factor(s50_1995$alcohol,levels = c(1,2,3,4,5),labels = c("not","once or twice a year","once a month","once a week","more than once a week"))
s50_1995$drugs = factor(s50_1995$drugs,levels = c(1,2,3,4),labels = c("not","tried once","occasional","regular"))
s50_1995$smoke = factor(s50_1995$smoke,levels = c(1,2,3),labels = c("not","occasional","regular"))
s50_1995$sport = factor(s50_1995$sport,levels = c(1,2),labels = c("not regular","regular"))
str(s50_1995)
  1. Using base R, create two suitable graphs, with labels, colours etc., one illustrating the variable smoke and the other illu

你可能感兴趣的:(R语言大学作业,python,开发语言)