Questions tagged [spread]

This tag relates to the R spread function. For the javascript spread syntax - please use spread-syntax.

Some of the features are:

  1. Powerful Formula Engine with 300+ Excel Functions
  2. Full Excel Import/Export, PDF, and Print
  3. Support Input, Display, and Data Visualization Controls
  4. Visual Drag-and-Drop Designers
420 questions
5
votes
2 answers

r tidyverse spread() using multiple key value pairs not collapsing rows

I am trying to spread() a couple of key/value pairs but the common value column does not collapse. I think that it may have to do with some previous processing, or more likely I do not know the right way to spread two or more key/value pairs to get…
Austin Overman
  • 163
  • 2
  • 9
5
votes
1 answer

python pandas pivot: How to do a proper tidyr-like spread?

I am missing spontaneous and easy conversion from long to wide and vice versa in Python. Imagine, I have a large tidy dataframe with a lot of property-columns and a single column that contains all the actual values like PropA ... PropZ …
Antalagor
  • 428
  • 4
  • 10
5
votes
2 answers

Using spread to create two value columns with tidyr

I have a data frame that looks just like this (see link). I'd like to take the output that is produced below and go one step further by spreading the tone variable across both the n and the average variables. It seems like this topic might bear on…
spindoctor
  • 1,719
  • 1
  • 18
  • 42
5
votes
1 answer

how spread() in tidyr handles factor levels

I was manipulating my data and found that I did something wrong at some point in the process. When I explored the issue, the problem came down to the following behavior of spread() in the tidyr package. Here's a demonstrative example. Let us say we…
Akira Murakami
  • 463
  • 1
  • 4
  • 14
4
votes
8 answers

How to return key value pairs from map function using spread operator

I have an object and an array. Say: const first = { 'key1': 'some date', 'key2': 'some date' } const second = ['key3', 'key4'] Then using spread syntax I want to combine then into single object. For each item in array I want to create new key…
Zobla
  • 123
  • 2
  • 7
4
votes
3 answers

Spread operator with objects

i was trying to solve this problem in javascript : Write a function that takes an object as argument containing properties with personal information .Extract firstName, lastName, size, and weight if available .If size or weight is given transform…
Youssef Raf
  • 43
  • 1
  • 3
4
votes
5 answers

Organizing a dataframe - splitting one column into three

I have a dataset that looks like this: Ord_ID Supplier Trans_Type Date 1 A PO 2/3/18 1 A Receipt 2/15/18 2 B PO 2/4/18 2 B …
Millie
  • 77
  • 1
  • 5
4
votes
2 answers

Spreadsheets: how do I SUM values in a column, only if the text column has a 1?

Let's say I have this data 4 1 4 0 4 1 3 0 5 1 How do I write a function (using SUM or something like that) to add all the values on the left, if the values on the right are 1, or true The total should be 13
NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
4
votes
1 answer

tidyr spread sorting inconsistencies

Ive noticed tidyr(0.4.0) sorts value columns when using spread, where as tidyr(0.3.1) returns the value columns in the order they were prior to a gather. Reproducible example 1: library(dplyr) library(tidyr) # tidyr…
danny_C_O_T_W
  • 228
  • 2
  • 8
3
votes
3 answers

Pivoting single rows into rows with their combined values

I would like to transform the column word into another column, but with the original rows combined together, separed by _. Original: > head(df, 10) # A tibble: 10 x 1 word 1 Jason 2 Oscar 3 Maleeka 4 Janet 5…
Larissa Cury
  • 806
  • 2
  • 11
3
votes
1 answer

Javascript Spread Operator used with return

I'm confused on how the spread operator is being used here. I have a basic understanding of how the spread operator works but I'm confused on what the spread operators are referring to, how it is being used, and what it is offering. The…
3
votes
3 answers

How to spread a single column based on multiple columns in R?

Each unique year, site, quadrant, and species has two values "Val" in the dataset. I want to spread the values into two columns "Val1" and "Val2". I tried to use the regular spread function but it doesn't seem like its the right fit. Any…
Rspacer
  • 2,369
  • 1
  • 14
  • 40
3
votes
4 answers

Replace a key in an object while spreading in Javascript

I have the below object, const obj = { 'a': 1, 'b': 2, 'c': 3, 'd': 4, . . . . 'z': 26 } I want to have a new object which will contain all the keys as object obj, but instead of one specific key, I want it to be replaced with…
Frosted Cupcake
  • 1,909
  • 2
  • 20
  • 42
3
votes
3 answers

Is this a good way to pass props to child component in React?

In React, normally, we pass props to child component by following way: const Parent = ({ foo, bar, baz, myFoo, myBar, myBaz }) => (1) Currently I figured out an alternative way to do this: const Parent = ({…
Cam Song
  • 492
  • 2
  • 11
3
votes
3 answers

How to use the Spread function using only one value of the target column?

We have the following data frame a with something like this: > a google_prod Value 1 categoria ML 2 google 120 3 youtube 24 4 categoria AO 5 google 2 6 youtube…
1
2
3
27 28