I'd like to make all values that appear more than 10 times from 2D array a random. How should I describe them?I want to do it without looping.
For writing using the for statement,
for(time in unique(a)){
if(length(a[a==time])>=10){
a[a==time]<-0
}
}
I think I can write like that, but I don't know how to make it happen without using a loop.The work we're doing now involves a large number of two-dimensional arrays, so we're looking for ways to achieve this without looping as much as possible.
If you are familiar with the description of R, please take care of it.
The following is how to use the table
function:
f<-as.data.frame(table(a))
a [a% in %f [f$Freq>=10,]$a] <-0
You can use the table
function to obtain the frequency at which unique elements appear.
362 To Limit Column Values to Strings in a String List Using sqlalchemy
351 I have saved several codes written in python to a visual studio file.
353 I want to create an array of sequences from "1" to a specified number.
369 Update Flask User Information
361 Add dataframe values of the same structure without column names
© 2023 OneMinuteCode. All rights reserved.