Re: [R] Filtering an Entire Dataset based on Several Conditions

2022-05-09 Thread Avi Gross via R-help
R Sent: Mon, May 9, 2022 12:44 pm Subject: Re: [R] Filtering an Entire Dataset based on Several Conditions Dear Rui, I was trying to dput() the datasets I am working on, but since it is a bit large (42,000 rows by 60 columns) couldnĀ“t retrieve all the structure of the data to include it here

Re: [R] Filtering an Entire Dataset based on Several Conditions

2022-05-09 Thread Bert Gunter
This is trivial, so perhaps there is a miscommunication. How do you want to handle values outside your desired range? I would simply change them to NA (see below), but perhaps you have something else in mind that you need to describe more explicitly. Anyway, below is a simple example of what I

Re: [R] Filtering an Entire Dataset based on Several Conditions

2022-05-09 Thread Rui Barradas
Hello, My code seems to work with your data, except that the first column is not to be scaled. # file names xlsfile <- file.path("~/dados", "trainFeatures42k.xls") csvfile <- file.path("~/dados", "Normalized_Data.csv") # read in the data files df1 <- readxl::read_excel(xlsfile, col_names =

Re: [R] Filtering an Entire Dataset based on Several Conditions

2022-05-09 Thread Rui Barradas
Hello, Something like this? First normalize the data. Then a apply loop creates a logical matrix giving which numbers are in the range -3 to 3. If they are all TRUE then their sum by rows is equal to the number of columns. This creates a logical index i. Use that index i to subset the scaled

Re: [R] Filtering an Entire Dataset based on Several Conditions

2022-05-09 Thread Jim Lemon
Hi Paul, Based on my guess that all values have been normalized, I would say: mat<-(matrix(runif(16,-5,5),4)) df<-as.data.frame(mat) df[abs(df) < 3]<-NA df V1 V2 V3V4 1 NA 4.675699 3.166625NA 2 NA NA NA 3.463660 3 4.288831 NA