- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在研究天气数据。我正在尝试清理一个 csv 文件,但不断出现奇怪的错误。在 csv 文件中,9999 和 -9999 是空值。我想删除超过一半的值是 9999 或 -9999 的所有列。我读入了 csv 文件。然后初始化一个空矩阵,使其与读取 csv 文件时创建的数据框具有相同的维度。我遍历数据框"file"中的列,检查是否有任何值是 na 或空字符串。我创建了一个向量“元”并从 plyr 库调用计数来聚合数据框中的所有列。然后我遍历行并检查行中是否有任何 na 值,然后我检查 9999 或 -9999 是否在向量元行中。然后我查看 的频率是否大于列中行数的一半。如果是,则将值添加到干净矩阵。我不断收到奇怪的错误,干净矩阵中的值不是我预期的。我将附上两者的屏幕截图。我还将附上 csv 文件和 R 代码。
谢谢
errors values in the clean matrix 1
file <- read.csv(header = TRUE, file = "C:\\Users\\michael.guarino1\\Desktop\\weather\\nov_6_2012\\735144.csv")
clean <- matrix(0, nrow(file), ncol(file))#initialize matrix of same dimensions as file
library(plyr)
count <- 1 #initialize count to 1
for (i in 1:ncol(file)) {
if (!any(is.na(file[,i]))|!any(file[,i]==" ")) {
meta <- count(file, i)
for(row in 1:nrow(meta)){
if(!is.na(meta[row,1])){
if (meta[row,1]== -9999 | meta[row,1]== 9999) {
print("condition 1 found")
if (meta$freq < (nrow(file) / 2)) {
print("condition 2 found")
clean[, count] <- file[, i]
count <- count + 1
}
}
}
#else{
# clean[, count] <- file[, i]
#count <- count + 1
# }
}
}
else{
next
}
}
print("meta")
print(meta)
print("clean")
print(clean)
STATION,STATION_NAME,ELEVATION,LATITUDE,LONGITUDE,DATE,MDPR,Measurement Flag,Quality Flag,Source Flag,Time of Observation,MDSF,Measurement Flag,Quality Flag,Source Flag,Time of Observation,DAPR,Measurement Flag,Quality Flag,Source Flag,Time of Observation,DASF,Measurement Flag,Quality Flag,Source Flag,Time of Observation,PRCP,Measurement Flag,Quality Flag,Source Flag,Time of Observation,SNWD,Measurement Flag,Quality Flag,Source Flag,Time of Observation,SNOW,Measurement Flag,Quality Flag,Source Flag,Time of Observation,TMAX,Measurement Flag,Quality Flag,Source Flag,Time of Observation,TMIN,Measurement Flag,Quality Flag,Source Flag,Time of Observation,TOBS,Measurement Flag,Quality Flag,Source Flag,Time of Observation,PGTM,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT09,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT07,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT01,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT06,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT05,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT02,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT11,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT04,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT16,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT08,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT18,Measurement Flag,Quality Flag,Source Flag,Time of Observation,WT03,Measurement Flag,Quality Flag,Source Flag,Time of Observation
GHCND:USR0000IPOB,POTTER BUTTE IDAHO ID US,1502.7,43.2261,-113.5744,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,40,H, ,U,9999,30,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USW00004842,WOOSTER WAYNE CO AIRPORT OH US,346.6,40.87306,-81.88667,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,71, , ,W,9999,40, , ,W,9999,-9999, , , ,9999,1605, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,1, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,1, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USW00003954,OKLAHOMA CITY WILEY POST AIRPORT OK US,395.3,35.53417,-97.64694,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,77, , ,W,9999,57, , ,W,9999,-9999, , , ,9999,1531, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00080737,BIG CYPRESS FL US,4.6,26.32833,-80.99583,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,0800,0.0,P, ,0,9999,0.0,P, ,0,9999,82, , ,0,0800,65, , ,0,0800,65, , ,0,0800,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000OBRI,BRER RABBIT OREGON OR US,1798.3,44.3231,-119.7669,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,31,H, ,U,9999,22,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00202381,EAST JORDAN MI US,178.3,45.1519,-85.1322,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,1500,0.0, , ,0,1500,0.0, , ,0,9999,74, , ,0,1500,43, , ,0,1500,74, , ,0,1500,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,1, , ,0,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000CKON,KONOCTI CALIFORNIA CA US,659.3,38.9119,-122.7064,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,49,H, ,U,9999,40,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000MBLA,BLACKWATER MARYLAND MD US,426.7,38.4167,-76,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,61,H, ,U,9999,54,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000WEST,ESTERBROOK WYOMING WY US,1990.3,42.4153,-105.3611,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,56,H, ,U,9999,32,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:US1GAGW0006,BUFORD 4.6 ESE GA US,352.7,34.0799,-83.9313,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,N,9999,-9999, , , ,9999,0.0, , ,N,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00111290,CARLYLE RESERVOIR IL US,152.7,38.63083,-89.36583,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,0800,0.0,P, ,0,9999,0.0,P, ,0,9999,76, , ,0,0800,46, , ,0,0800,49, , ,0,0800,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00116661,PAW PAW 2 S IL US,289.6,41.71222,-88.99889,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,0700,0.0, , ,0,9999,0.0, , ,0,9999,72, , ,0,0700,47, , ,0,0700,48, , ,0,0700,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000MSUN,SUNKHAZE MEADOWS MAINE ME US,34.7,44.9031,-68.64,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,63,H, ,U,9999,35,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000MAVA,AVA MISSOURI MO US,399.6,36.9431,-92.65,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,73,H, ,U,9999,44,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000JEBF,EB FORSYTHE NEW JERSEY NJ US,396.2,39.5,-74.5,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,60,H, ,U,9999,51,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000ADVK,DEVILS KNOB ARKANSAS AR US,640.1,35.6111,-93.3333,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,65,H, ,U,9999,54,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00228556,SUMRALL MS US,88.4,31.42222,-89.53861,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00,P, ,0,0700,0.0,P, ,0,9999,0.0,P, ,0,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000TDAY,DAYTON TEXAS TX US,30.5,30.105,-94.9314,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,79,H, ,U,9999,48,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00340292,ARDMORE OK US,268.2,34.17139,-97.12944,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,0800,0.0,P, ,0,9999,0.0,P, ,0,9999,78, , ,0,0800,60, , ,0,0800,67, , ,0,0800,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:US1PALN0003,ADAMSTOWN 2.5 SSE PA US,198.1,40.2055,-76.0509,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00,T, ,N,9999,-9999, , , ,9999,0.0, , ,N,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00408522,SPARTA WASTEWATER PLANT TN US,310.9,35.9566,-85.4813,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,0700,0.0,P, ,0,9999,0.0,P, ,0,9999,75, , ,0,0700,36, , ,0,0700,39, , ,0,0700,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000WGOL,GOLD MOUNTAIN WASHINGTON WA US,1428.3,48.1806,-118.4636,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,33,H, ,U,9999,27,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:US1FLAL0007,GAINESVILLE 8.1 SW FL US,36.9,29.5908,-82.4314,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,N,9999,-9999, , , ,9999,0.0, , ,N,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00148341,VALLEY FALLS KS US,299.3,39.3033,-95.4861,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,0700,0.0,P, ,0,0700,0.0,P, ,0,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000IHAR,HARDIN RIDGE INDIANA IN US,228.6,39,-86.4228,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,76,H, ,U,9999,43,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USW00014742,BURLINGTON INTERNATIONAL AIRPORT VT US,100.6,44.46806,-73.15028,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,2400,0.0, , ,0,9999,0.0, , ,0,9999,61, , ,0,2400,46, , ,0,2400,-9999, , , ,9999,941, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,1, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,1, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000SWIT,WITHERBEE SOUTH CAROLINA SC US,18,33.1597,-79.8306,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,62,H, ,U,9999,59,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00367782,SALINA 3 W PA US,338,40.5101,-79.5459,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,0700,0.0,P, ,0,0700,0.0,P, ,0,9999,69, , ,0,0700,43, , ,0,0700,44, , ,0,0700,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000CANZ,ANZA CALIFORNIA CA US,1194.8,33.555,-116.673,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,53,H, ,U,9999,42,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:US1KSEL0043,HAYS 5.4 SSW KS US,630.6,38.8129,-99.3735,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,N,9999,-9999, , , ,9999,0.0, , ,N,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000ATAL,TALLADEGA ALABAMA AL US,182.9,33.4411,-86.0811,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,76,H, ,U,9999,44,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USW00094985,MARSHFIELD MUNICIPAL AIRPORT WI US,382.5,44.63806,-90.1875,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,73, , ,W,9999,53, , ,W,9999,-9999, , , ,9999,1436, , ,W,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000ISLA,SLATE CREEK IDAHO ID US,477.9,45.6333,-116.2833,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,51,H, ,U,9999,41,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000MDRY,DRY BLOOD CREEK MONTANA MT US,914.4,47.2442,-108.3575,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,53,H, ,U,9999,38,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00134142,IOWA FALLS IA US,321.6,42.5188,-93.2536,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00,P, ,0,0700,0.0,P, ,0,9999,0.0,P, ,0,9999,75, , ,0,0700,52, , ,0,0700,55, , ,0,0700,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00161565,CARVILLE 2 SW LA US,7.6,30.19806,-91.12556,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,0,2400,0.0,P, ,0,9999,0.0,P, ,0,9999,77, , ,0,2400,51, , ,0,2400,58, , ,0,2400,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USR0000NSTO,STONYKILL NEW YORK NY US,61,41.5,-73.9,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,63,H, ,U,9999,40,H, ,U,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:US1ALMD0040,HAMPTON COVE 0.5 NNW AL US,187.1,34.667,-86.485,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.00, , ,N,9999,-9999, , , ,9999,0.0, , ,N,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
GHCND:USC00421446,CITY CRK WATER PLANT UT US,1624.6,40.8397,-111.8313,20081104,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,0.62, , ,0,1600,1.0, , ,0,1600,1.3, , ,0,9999,52, , ,0,1600,32, , ,0,1600,40, , ,0,1600,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999,-9999, , , ,9999
最佳答案
假设您的数据如下所示:
df <- data.frame(v1 = c(1,1,2,1,2,1),
v2 = c(9999, 1, 2, 1, 2, -9999),
v3 = c(9999, 1, -9999, 9999, 2, -9999))
然后,您可以使用 colSums
删除超过一半值为 9999 或 -9999 的列:
df[ , colSums(abs(df) == 9999)/nrow(df) < 0.5]
或使用colMeans
:
df[ , colMeans(abs(df) == 9999) < 0.5]
两者都会导致删除 v3
列:
v1 v2
1 1 9999
2 1 1
3 2 2
4 1 1
5 2 2
6 1 -9999
关于R 清理 csv 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37280024/
我正在从 Stata 迁移到 R(plm 包),以便进行面板模型计量经济学。在 Stata 中,面板模型(例如随机效应)通常报告组内、组间和整体 R 平方。 I have found plm 随机效应
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
我想要求用户输入整数值列表。用户可以输入单个值或一组多个值,如 1 2 3(spcae 或逗号分隔)然后使用输入的数据进行进一步计算。 我正在使用下面的代码 EXP <- as.integer(rea
当 R 使用分类变量执行回归时,它实际上是虚拟编码。也就是说,省略了一个级别作为基础或引用,并且回归公式包括所有其他级别的虚拟变量。但是,R 选择了哪一个作为引用,以及我如何影响这个选择? 具有四个级
这个问题基本上是我之前问过的问题的延伸:How to only print (adjusted) R-squared of regression model? 我想建立一个线性回归模型来预测具有 15
我在一台安装了多个软件包的 Linux 计算机上安装了 R。现在我正在另一台 Linux 计算机上设置 R。从他们的存储库安装 R 很容易,但我将不得不使用 安装许多包 install.package
我正在阅读 Hadley 的高级 R 编程,当它讨论字符的内存大小时,它说: R has a global string pool. This means that each unique strin
我们可以将 Shiny 代码写在两个单独的文件中,"ui.R"和 "server.R" , 或者我们可以将两个模块写入一个文件 "app.R"并调用函数shinyApp() 这两种方法中的任何一种在性
我正在使用 R 通过 RGP 包进行遗传编程。环境创造了解决问题的功能。我想将这些函数保存在它们自己的 .R 源文件中。我这辈子都想不通怎么办。我尝试过的一种方法是: bf_str = print(b
假设我创建了一个函数“function.r”,在编辑该函数后我必须通过 source('function.r') 重新加载到我的全局环境中。无论如何,每次我进行编辑时,我是否可以避免将其重新加载到我的
例如,test.R 是一个单行文件: $ cat test.R # print('Hello, world!') 我们可以通过Rscript test.R 或R CMD BATCH test.R 来
我知道我可以使用 Rmd 来构建包插图,但想知道是否可以更具体地使用 R Notebooks 来制作包插图。如果是这样,我需要将 R Notebooks 编写为包小插图有什么不同吗?我正在使用最新版本
我正在考虑使用 R 包的共享库进行 R 的站点安装。 多台计算机将访问该库,以便每个人共享相同的设置。 问题是我注意到有时您无法更新包,因为另一个 R 实例正在锁定库。我不能要求每个人都关闭它的 R
我知道如何从命令行启动 R 并执行表达式(例如, R -e 'print("hello")' )或从文件中获取输入(例如, R -f filename.r )。但是,在这两种情况下,R 都会运行文件中
我正在尝试使我当前的项目可重现,因此我正在创建一个主文档(最终是一个 .rmd 文件),用于调用和执行其他几个文档。这样我自己和其他调查员只需要打开和运行一个文件。 当前设置分为三层:主文件、2 个读
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 5年前关闭。 Improve this qu
我的 R 包中有以下描述文件 Package: blah Title: What the Package Does (one line, title case) Version: 0.0.0.9000
有没有办法更有效地编写以下语句?accel 是一个数据框。 accel[[2]]<- accel[[2]]-weighted.mean(accel[[2]]) accel[[3]]<- accel[[
例如,在尝试安装 R 包时 curl作为 usethis 的依赖项: * installing *source* package ‘curl’ ... ** package ‘curl’ succes
我想将一些软件作为一个包共享,但我的一些脚本似乎并不能很自然地作为函数运行。例如,考虑以下代码块,其中“raw.df”是一个包含离散和连续类型变量的数据框。函数“count.unique”和“squa
我是一名优秀的程序员,十分优秀!