rowwise Questions

6

Solved

There are other posts about row-wise operators on datatable. They are either too simple or solves a specific scenario My question here is more generic. There is a solution using dplyr. I have play...
Hyperaesthesia asked 7/7, 2015 at 1:57

8

Solved

I am working in R, and would prefer a dplyr solution if possible. sample data: data.frame( col1 = c("a", "b", "c", "d"), col2 = c("a", "b&qu...
Hindgut asked 8/1 at 13:35

4

Solved

This is somehow related to this question: In principle I try to understand how rowwise operations with mutate across multiple columns applying more then 1 functions like (mean(), sum(), min() etc.....
Sebrinasebum asked 1/5, 2021 at 14:34

6

I have a dataframe that has lots of columns that are something like this: data <- data.frame (a.1 = 1:5, a.2b = 3:7, a.5 = 5:9, bt.16 = 4:8, bt.12342 = 7:11) I'd like a result with columns that...
Unexceptional asked 16/4, 2018 at 13:53

3

I have a data table with probabilities for a discrete distribution stored in columns. For example, dt <- data.table(p1 = c(0.5, 0.25, 0.1), p2 = c(0.25, 0.5, 0.1), p3 = c(0.25, 0.25, 0.8)) I'd l...
Beast asked 16/7, 2022 at 4:3

4

I'm trying to automatically calculate the mean score per row for multiple groups of columns. E.g. a set of columns could represent items of different scales. The columns are also systematically nam...
Hydric asked 1/7, 2022 at 17:15

6

Solved

ID <- 1:6 math <- c("YES","NO","YES","NO",NA,NA) history <- c(NA,NA,"NO","NO","YES",NA) dt <- data.frame(ID, math,...
Ea asked 10/6, 2022 at 8:47

2

Solved

I will use the following data set to illustrate my questions: my_df <- data.frame( a = 1:10, b = 10:1 ) colnames(my_df) <- c("a", "b") Part 1 I use the mutate() function to create two n...
Boarfish asked 20/1, 2018 at 6:31

3

Solved

If I wanted to sum over some variables in a data-frame using dplyr, I could do: > head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0....
Monohydric asked 21/3, 2018 at 0:27

7

I'm having trouble using rowwise() to count the number of NAs in each row. My minimal example: df <- data.frame(Q1 = c(rep(1, 1), rep(NA, 9)), Q2 = c(rep(2, 2), rep(NA, 8)), Q3 = c(rep(3, 3), ...
Geese asked 18/4, 2021 at 16:27

3

Solved

I need to find the minimum values of three columns that are bigger than the values in another column. Say these five individuals entered a hospital in different months of the year, and they suffere...
Best asked 11/6, 2021 at 16:26

4

Solved

I have a dataframe in R. For each row, I would like to select which column has the highest value, and paste the name of that column. This is simple when there are only two columns to chose from (no...
Imeldaimelida asked 14/5, 2021 at 10:53

2

Solved

I have this df: df <- structure(list(a = 1:5, b = 6:10, c = 11:15, d = c("a", "b", "c", "d", "e"), e = 1:5), row.names = c(NA, -5L), class = c(...
Sexless asked 1/5, 2021 at 14:3

2

Solved

Does the following code represent the preferred procedure for traversing the rows of an R data.table and passing the values found at each row to a function? Or is there a more performant way to do ...
Casebook asked 18/4, 2021 at 7:58

2

Solved

I have a data.frame that contains 4 columns (given below). I want to find the index of the minimum column (NOT THE VALUE) for each row. Any idea hiw to achieve that? > d V1 V2 V3 V4 1 0.38811...
Halmstad asked 19/8, 2013 at 22:20

2

Solved

I'm trying to return a list using mutate and rowwise but get the error shown in the code. These questions Q1 Q2 helped, but I'd like to keep it simple by iterating over rows using rowwise(), and th...
Xuanxunit asked 7/9, 2017 at 23:19

3

Solved

I need to find the row-wise minimum of many (+60) relatively large data.frame (~ 250,000 x 3) (or I can equivalently work on an xts). set.seed(1000) my.df <- sample(1:5, 250000*3, replace=TRUE)...
Hilton asked 25/10, 2011 at 5:44

2

Solved

As a follow-up to this oldie but goodie: efficient row-wise operations on a data.table I have some data that (unfortunately) look like: library('data.table') set.seed(1234) m <- 5 n <- 7 rb...
Usual asked 30/11, 2015 at 21:38

2

Although I've figured this out before, I still find myself searching (and unable to find) this syntax on stackoverflow, so... I want to do row wise operations on a subset of the data.table's colum...
Ephialtes asked 26/10, 2015 at 18:28

1

Recently I ran into the data.table package. I'm still not sure how to do row-wise matrix operations. Was it originally intended to handle such operations? For example, what would be data.table equi...
Friedrich asked 5/3, 2012 at 9:52
1

© 2022 - 2024 — McMap. All rights reserved.