我有一个数据集:(可以从下面的链接中看到)
https://drive.google.com/file/d/0B4Mldbnr1-avMDIxYmZLSnRfUDA/view?usp=sharing
我想用子集&级别功能。以下是我一直在尝试应用的内容,但似乎不起作用:
# Setting working directory
setwd("F:/Intro Data Science/Assignment Part B/Assignment Part B-20170902")
plot.new()
options(digits=2)
# Reading data set
installed.packages("lubridate")
library(lubridate)
# Reading data set
power <- read.csv("data set 6.csv", na.strings="")
# SUBSETTING
Area <- as.numeric(power$Area)
City <- as.character(power$City)
P.Winter <- as.numeric(power$P.Winter)
P.Summer <- as.numeric(power$P.Summer)
#Data Cleaning
levels(power$City)<- c(levels(power$City),"Auckland")
power$City[power$City == "Ackland"] <- "Auckland"
我真的需要你们的帮助。这本应该很容易,因为我完全遵循了讲座中给出的内容,但当我运行代码时,它没有做任何事情。
谢谢你的帮助
纳尔逊
请求的输出:
> dput(head(power, 30))
structure(list(Area = c(144.38, 176.83, 268.71, 208.67, 123.61,
199.3, 109.46, 183.28, 110.61, 146.91, 77.451, 232.65, 270.94,
49.191, 234.5, 280.93, 192.18, 95.918, 230.74, 72.698, 129.26,
110.76, 199.44, 129.75, 146.8, 287.97, 162.1, 249.03, 159.3,
272.51), City = c("Auckland ", "Auckland ", "Auckland ", "Auckland ",
"Auckland ", "Auckland ", "Auckland ", "Auckland ", "Auckland ",
"Auckland ", "Auckland ", "Auckland ", "Auckland ", "Auckland ",
"Auckland ", "Auckland ", "Auckland ", "Ackland ", "Auckland ",
"Auckland ", "Auckland ", "Auckland ", "Auckland ", "Auckland ",
"Auckland ", "Auckland ", "Auckland ", "Auckland ", "Auckland ",
"Auckland "), P.Winter = c(1684.9, 1926.7, 2026.9, 1938.1, 1579.9,
1991.4, 1572.5, 1691.2, 1684.2, 1743.6, 1234.6, 2043, 1986.7,
1259.7, 1870.4, 2115.6, 18000, 1452, 1936.2, 1430.2, 1587.3,
1614.3, 1993.2, 1746.4, 1807.6, 2009.4, 1859.1, 1985.5, 1909.4,
1892.7), P.Summer = c(1194.5, 1487.3, 1737.3, -158, 1148.1, 1445.8,
885.77, 1393, 1191.5, 1149.9, 813.38, 1623.8, 1708, 874.48, 1635.7,
1826.1, 1596.6, 793.71, 1668.8, 905.6, 1227.3, 938.38, 1523.1,
1012.6, 1122.8, 1829.5, 1223.3, 1653.2, 1175.5, 1882)), .Names = c("Area",
"City", "P.Winter", "P.Summer"), row.names = c(NA, 30L), class = "data.frame")