Finding specific values in an array

Yani Udiani

I am relatively new to R programming. I am writing a code that generates an array of numbers:

[1] 0.5077399,  0.4388107, 0.3858783, 0.3462711, 0.3170844, 0.2954411, 0.2789464, 0.2658839,

[9] 0.2551246, 0.2459498 

Note: I manually separated the values by commas for ease on the eyes :)

I want to pick the first 3 numbers from this array that are below 0.3 - [0.2954411, 0.2658839, 0.2551246]. In addition to picking these values, I want to generate the numbers that represents where those three values exist within the array. In this case, I want the code to give me [6,7,8].

How would I write code to do this?

I greatly appreciate the help.

Polar.Ice

For a similar simulated set,

y <- c(2, 4,6, 8)
ind <- which(y < 6) ## for finding indices 1 and 2
val <- y[y<6]       ## for picking values  2 and 4

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Finding changes in a list then storing specific values into an array C#

From Dev

Finding specific numbers in an array?

From Dev

Finding unique values in Array

From Dev

Finding unique values in Array

From Dev

AngularJS not finding values in array

From Dev

Finding the average of specific values in a dictionary

From Dev

Finding the average of specific values in a dictionary

From Dev

Finding index of specific values in matrix

From Dev

finding specific indices with pointer array

From Dev

Finding a specific string in array of strings

From Dev

Finding First and Second in an Array of Values?

From Dev

Finding Largest Values in Array of Arrays

From Dev

Finding distinct values in array column

From Dev

Finding duplicate values in a MongoDB array

From Dev

Finding indexes of maximum values of an array

From Dev

Finding First and Second in an Array of Values?

From Dev

Finding `uniq` values in array with their indexes

From Dev

Finding Duplicate values in array of integers

From Dev

Finding chained, incremented values in array

From Dev

Iterating though array is finding no values

From Dev

finding a specific array element and remove the container array

From Dev

Finding documents having specific values in subdocuments in MongoDB

From Dev

Finding partial duplicate values and keeping a specific

From Dev

finding rows with specific values for a column (matlab)

From Dev

finding a specific index on a two dimensional array

From Dev

Finding range index of a sorted array on a specific element

From Dev

Finding the sum of specific multidimensional array php

From Dev

Finding indexes of a specific repeated number in array

From Dev

Array with specific values

Related Related

HotTag

Archive