All Questions
5,218
questions
0
votes
1
answer
36
views
Using dplyr to keep values above certain threshold in correlation matrix [closed]
I am trying to keep all correlations in my correlation matrix that are above 0.7 or below -0.7. When I try using the filter_all function within dyplr, I'm always left with a data frame with 0 obs. ...
0
votes
2
answers
28
views
Merge two datasets in a many to one framework, where dataset B's columns are a subset of dataset A's
My dataset A is a panel of individuals, as below. Many individuals can belong to a single family (variable fam_id). I have person variables and family variables in this dataset. As you can see, I have ...
1
vote
2
answers
42
views
How to get column-wise summary statistics with missing codes?
I have written a custom function ord_table() to extract summary statistics from a series of databases. To get those summary statistics, I have to filter out missing data codes (all codes are large ...
1
vote
3
answers
100
views
Can we retrieve entries from a tibble using index matrix?
I have a matrix where the row and column indices are stored that I want to retrieve from a dataset. With a data.frame this works fine:
set.seed(1)
df <- data.frame(a= letters[1:10], b= LETTERS[1:10]...
0
votes
2
answers
34
views
Loop in r with subset makes incomplete selection
I have a data frame (words) containing words with five letters, in which each letter appears in one of five columns. The sixth column represents the log probability of the word based on letter ...
1
vote
2
answers
65
views
How to remove all rows where at least one column does not have a value of 1?
I have a presence/absence matrix of species occurences, which looks like this:
coords.x coords.y 1 2 3
Point 1 -69.07354 -15.76097 0 NA NA
Point 2 -69....
0
votes
2
answers
55
views
Filtering my data frame is erasing my data frame despite correct number of rows
I have a dataframe of transactions (roughly 76K rows). Each row has a column called START_DATE which is when the transaction started.
I am trying to filter down to transactions with START_DATE > 1/...
1
vote
1
answer
84
views
Overriding the subset method in R for a specific class interferes with other objects
I am working with R and I have created a new subset method for objects of class new_object. Here is my function:
setGeneric('subset', function(x, i) standardGeneric('subset'))
setMethod('subset', '...
3
votes
3
answers
51
views
How to filter out numbers with n digits in a dataframe in R?
In my DATA below, I'm trying to subset()/dplyr::filter() the INs that are 5 digits long.
I'm using the following without success. Is there a better solution?
Tried: subset(DATA, nchar(sub('\\.[0-9]+', ...
0
votes
1
answer
16
views
How do I turn the values in a subset into text so that I can generate a wordcloud?
From a large tabular data set (using read.csv function) I have created a subset from a column that lists different job roles in the rows.
View(jobs_mysubset)
.....
\[995\] physician
\[996\] painter
...
1
vote
2
answers
33
views
Filter rows in an R tidy data frame based on same-column values that are located in different rows
I am trying to filter out the species (ASV) in samples that have lower abundance counts than the same species in controls. Below is a simplified version of my tidy data table:
ASV
ID
Type
Batch
...
1
vote
2
answers
43
views
how filter a dataframe to remove rows in which no column contains a value higher than X or lower than Y
I am trying to remove any rows of data that do not contain any values that are greater than 5 or less than -5 in order to exclude them from my data analysis. I could not find a way to use an OR ...
1
vote
1
answer
39
views
Creating a subset that only includes columns that have a certain value in a certain vector
Input:
library(ISLR)
data("NCI60")
cancers <- NCI60$labs
gene_counts <- table(cancers)
g3 <- names(gene_counts[gene_counts > 3])
g3
subset_NCI60 <- NCI60[cancers %in% g3]
...
0
votes
2
answers
57
views
Subsetting dataframe so as to retain combinations that contain all values for a certain variable in R [closed]
Let us generate the dataframe we want to subset
vDates =
seq(
from = as.Date("2024-01-01"),
to = as.Date("2024-01-5"),
by = 1
)
vToy = c(1, 2, 3)
vColors = c("...
0
votes
2
answers
59
views
R: How to run 'for-loop' by factor level?
How does one do 'for-loops' with different variable types? My loop works by simply averaging counts, then increases the sample size as more data gets added; except it doesn't repeat the sequence of ...