Hi,
I have to import a column(numerical data) from excel to r in order to do sth. But I only want some of the data as only positive values are desired and I only need 3~4 thousand data from the column contains ~60000 data. What codes can be used to handle the problem?
See the FAQ: How to do a minimal reproducible example reprex
for beginners . Without knowing the selection criteria for the 3-4 thousand records, I can only offer that you should read the data into a data frame and then subset out the non-positive values such as
set.seed(137)
example <- rnorm(100)
example
#> [1] 0.38351988 1.36694695 -0.34520196 1.34915414 0.30299584 0.52072416
#> [7] 1.14347930 0.21623641 1.13010260 -0.60028028 -0.14577486 1.41999612
#> [13] -0.52306705 0.31372968 0.92375247 0.57976740 -0.65468328 -0.25365892
#> [19] 0.12401743 0.30768539 -1.88340763 -0.40932788 0.46336257 -0.87907282
#> [25] -1.61913940 0.04188530 0.79710495 0.08772988 -1.01104375 0.36415246
#> [31] 0.83539027 0.18983531 0.94904841 0.23973975 1.22949385 0.19854351
#> [37] -2.01138853 1.64089925 -0.14161214 -1.13430607 0.61379004 0.31947382
#> [43] -1.22268494 -0.52783090 -0.59782853 0.99339972 0.72538290 -0.34264566
#> [49] -0.82195650 0.80545065 -0.09104667 1.56855159 1.31807990 0.75496865
#> [55] 0.05120691 -0.14081688 -0.44903762 -0.64806657 0.32339424 1.73758146
#> [61] -0.11614500 -1.96564365 0.22894035 -0.33757066 0.38135888 -0.59391173
#> [67] -0.36348201 -0.56392373 0.32406079 0.21732873 0.99321482 -0.03079702
#> [73] -0.45430447 -1.52427799 -0.66796610 -2.45181705 1.90315154 -1.38664684
#> [79] 0.66778535 -0.02520749 1.79183676 -0.58461648 0.70451121 -1.20841144
#> [85] -0.59886305 -0.66304341 -1.07750173 1.91298909 0.33429059 1.27895294
#> [91] -0.23001024 -2.37174631 -0.85945890 0.57656053 -0.60457517 1.07473707
#> [97] 1.29750035 1.21936564 -0.73489046 -1.17467082
example <- example[which(example > 0)]
example
#> [1] 0.38351988 1.36694695 1.34915414 0.30299584 0.52072416 1.14347930
#> [7] 0.21623641 1.13010260 1.41999612 0.31372968 0.92375247 0.57976740
#> [13] 0.12401743 0.30768539 0.46336257 0.04188530 0.79710495 0.08772988
#> [19] 0.36415246 0.83539027 0.18983531 0.94904841 0.23973975 1.22949385
#> [25] 0.19854351 1.64089925 0.61379004 0.31947382 0.99339972 0.72538290
#> [31] 0.80545065 1.56855159 1.31807990 0.75496865 0.05120691 0.32339424
#> [37] 1.73758146 0.22894035 0.38135888 0.32406079 0.21732873 0.99321482
#> [43] 1.90315154 0.66778535 1.79183676 0.70451121 1.91298909 0.33429059
#> [49] 1.27895294 0.57656053 1.07473707 1.29750035 1.21936564
system
Closed
April 18, 2021, 8:25am
3
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.