How to remove extra rows and columns with NA values when importing from csv file using R -
i have started learning r. i'm trying input data .csv file , r keeps adding rows , columns na values. know why might happening? advice on removing these na appreciated. have used following code:
>no_col <- max(count.fields("6%aa_comp.csv", sep=",")) >mydata <- read.csv(file="6%aa_comp.csv", fill=true, header=true, col.names = 1:no_col-1) >mydata x0 x1 x2 x3 x4 1 206428 152160 122080 111940 na 2 183620 148300 118820 107260 na 3 169100 164480 151420 146200 na 4 179000 135920 107340 93540 na 5 213820 146640 113040 109140 na 6 150920 141400 133600 132000 na 7 185645 154000 124510 128900 na 8 176102 139100 141000 110300 na 9 159045 154350 121050 153500 na 10 198610 161000 119000 105600 na 11 183100 138900 141500 129550 na 12 211050 142550 136700 113500 na 13 167000 150100 120000 102540 na 14 na na na na na 15 na na na na na 16 na na na na na
well, data cleansing half job or more. can read file , clean indexing rows , columns interested in, in case be:
mydata <- read.csv(file="6%aa_comp.csv", fill=true, header=true) mydata <- mydata[1:13, 1:5]
Comments
Post a Comment