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
80
votes
10 answers

the syntax requires an imported helper named __spreadArrays

When I'm trying to use spreading in typescript like: .reduce((unique, x) => { unique.some(element => element.machineName === x.machineName) ? unique : [...unique, x]; } I get warning with red marking from Visual Studio Code: the syntax requires…
Alex Vovchuk
  • 2,828
  • 4
  • 19
  • 40
65
votes
6 answers

A spread argument must either have a tuple type or be passed to a rest parameter React

I have this code in Typescript: const [history, setHistory] = useState([Array(9).fill(null)]); const newHistory = history.slice(0, currentStep + 1); and when I want to set new State using spread operators like that: setHistory(...newHistory); I…
14
votes
1 answer

What's the time complexity of JavaScript spread syntax in arrays?

I was wondering what is the time complexity of using spread with an array in JavaScript. Is it linear O(n) or constant O(1)? Example of syntax below: let lar = Math.max(...nums)
Jaaayz
  • 1,533
  • 7
  • 27
  • 59
13
votes
2 answers

how to spread or cast multiple values in r

Here is toy data set for this example: data <- data.frame(x=rep(c("red","blue","green"),each=4), y=rep(letters[1:4],3), value.1 = 1:12, value.2 = 13:24) x y value.1 value.2 1 red a 1 13 2 red b 2 14 3 red c …
Rokmc1050
  • 463
  • 1
  • 6
  • 16
9
votes
3 answers

Passing a column name to R tidyr spread

I am trying to pass an object with the column name to the spread function, but instead of reading the value inside the object it just tries to use the object name itself Here just a toy example library(tidyr) d = (1:4) n = c("a"," a", "b","b") s =…
user2963882
  • 625
  • 1
  • 8
  • 19
8
votes
2 answers

How can I simulate repulsion between multiple point charges (ball bearings) in Mathematica?

I'm trying to write a program in Mathematica that will simulate the way charged ball bearings spread out when they are charged with like charges (they repel each other). My program so far keeps the ball bearings from moving off the screen, and…
7
votes
1 answer

how to keep ordering after spread

I would like to know how to keep ordering after spread. data<-tibble(var=c("A","C","D","B"), score=c(1,2,4,3)) data_spread <-data%>%spread(key = var, value = score) I would like to keep the order of c("A","C","D","B").
user224050
  • 317
  • 3
  • 10
7
votes
1 answer

Spread with duplicate identifiers for rows

There has been questions on this topic before here, but I am still struggling with spreading this. I would like so each state to have its own column of temperatures values. Here is a dput() of my data. I'll call it df structure(list(date =…
Alex
  • 2,603
  • 4
  • 40
  • 73
7
votes
2 answers

Spread columns by count in R dplyr

I have a factor column. I would like to spread into one column for each factor and then fill the gaps by the count of that factor appears for each id. Suppose we have: car <- c("a","b","b","b","c","c","a","b","b","b","c","c") type <- c("good",…
Xbel
  • 735
  • 1
  • 10
  • 30
7
votes
3 answers

Browser support for text-shadow spread value

Seen discussions here but it has been 2 years! I don't know if I'm using this right but I have the following sass/compass code: +text-shadow(red 0 3px 0 3px) Generating the following css: text-shadow: red 0 3px 3px, red 0 3px 0 3px; text-shadow:…
Alvaro Lourenço
  • 1,321
  • 1
  • 10
  • 21
6
votes
1 answer

tidyr - spread multiple columns

I'm preparing data for a network meta-analysis and I am having difficult in tyding the columns. If I have this initial dataset: Study Trt y sd n 1 1 -1.22 3.70 54 1 3 -1.53 4.28 95 2 1 -0.30 4.40 76 2 …
Juanchi
  • 1,147
  • 2
  • 18
  • 36
6
votes
2 answers

How to use the spread function properly in tidyr

How do I change the following table from: Type Name Answer n TypeA Apple Yes 5 TypeA Apple No 10 TypeA Apple DK 8 TypeA Apple NA 20 TypeA Orange Yes 6 TypeA Orange No …
ayk
  • 869
  • 2
  • 7
  • 6
5
votes
3 answers

Redux Spread Operator vs Map

I have a State of objects in an Array (in my Redux Reducer). const initialState = { items: [ { id: 1, dish: "General Chicken", price: 12.1, quantity: 0 }, { id: 2, dish: "Chicken & Broccoli", price: 10.76, quantity: 0 }, …
Chris Kavanagh
  • 451
  • 1
  • 5
  • 15
5
votes
0 answers

Lint shows error when I use spread syntax and destructuring

I have problem with spread and destructuring operator. After npm run lint:js I'll see: TypeError: Cannot read property 'type' of undefined Occurred while linting C:\Users\USER\hq-manager-frontend\frontend\src\common\functions\projects.js:8 at…
Alexandre Adereyko
  • 438
  • 2
  • 4
  • 12
5
votes
4 answers

How to install pivot_long() and pivot_wide() in R

If you want to try these new functions (pivot_wide and pivot long), you need to install the development version of tidyr: devtools::install_github("tidyverse/tidyr"). But I have not managed to achieved it. I install a list of libraries except one, (…
1
2 3
27 28