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
0
votes
1 answer

spread columns and count by ID in r

I have a factor column that name is Lead_DataSource__c. I want to spread into one column for each factor and then fill the gaps by the count of that factor appears for every row by id. Here is head of my dataframe; head(df) Id …
Ozgur Alptekın
  • 505
  • 6
  • 19
0
votes
1 answer

R spread dataframe

IN R language how to convert data1 into data2 data1 = fread(" id year cost pf loss A 2019-02 155 10 41 B 2019-03 165 14 22 B 2019-01 185 34 56 C 2019-02 350 50 0 A 2019-01 310 40 99") data2 = fread(" id item 2019-01 2019-02 2019-03 A cost…
0
votes
6 answers

How do I correctly spread 2 arrays overwriting the old values that matches the object id

My goal is to combine the values in both arrays, overwriting the objects that matches all the _id. Is this possible? oldState = [ { _id: 1, label: 'a' }, { _id: 2, label: 'b' }, { _id: 3, label: 'c' } …
agvera
  • 31
  • 6
0
votes
1 answer

How do I create a new variable in R if it does not already exist?

I am currently using tidytext in R to do some sentiment analysis. I'm using code extremely similar to the one listed at the vignette. This is the example…
0
votes
3 answers

Update object array without adding new properties from another object

Is it possible to update only the existing property values of an object without adding new properties from another object? Here is my example. form = {name: '',email: ''}; data = {name: 'sample', email: 'sample@gmail.com', datofbirth: '6/2/1990'…
Dekso
  • 541
  • 4
  • 23
0
votes
2 answers

Combining Rows in R with Pivot or Spread?

Here, I am manipulating election data, and the current data is in the following format. Both a visual and coded example are included (while visual is a bit condensed). Moreover, values have been edited from their originals. # Representative…
PageSim
  • 143
  • 1
  • 1
  • 8
0
votes
0 answers

Why does dplyr put quotes around my variables

I'm using "pivot_wider" (also tried "spread") function in dplyr to rearrange some data. But when I use the function, the output variables get weird ` ` around them (shown below). I don't see any mention of this in the documentation and I haven't…
0
votes
2 answers

JavaScript - Use addition on values of multiple dynamically created objects with same name in array

I have an array of objects that's created dynamically (in React, although I don't think it matters), and I'm attempting to use addition on values that have the same name. for example: [{ n1:"1", n2:"2", n3:"3"}, { n1:"4", n2:"6", n3:"4"}, {…
ConJastle2
  • 13
  • 2
0
votes
4 answers

Remove object key by spread operated returns undefined

I am creating a Radio Button object. Each object in the array has the object {value: 1, text: 'Sometext'} and if radio button is selected, to add selected: true into the object and remove selected from the others. const onChoiceChange = function…
Someone Special
  • 12,479
  • 7
  • 45
  • 76
0
votes
1 answer

Moving a Few Observations to New Rows in R?

I am trying to create a few new columns, based on specific observations in an existing row in my data frame. Below, I have a few rows as a representative example: test.df <- tibble(can=c("can1","can2","unmarked","invalid","blank"), …
PageSim
  • 143
  • 1
  • 1
  • 8
0
votes
1 answer

How do I transpose this data frame to look like the following example (long to wide)?

I have this data table that showcases customer service agent IDs and behaviors that the agents were coached on by a quality coach who listens to the call. I want to transpose this data frame: long data To look like this: wide data (goal) Basically,…
0
votes
2 answers

Original array modified even the spread operator

I've been searching for an answer for this for weeks, but I don't understand what am I doing wrong or expecting wrong... let simpleArray = [{"weight": "2kg"},{"weight": "5kg"}]; // I want to turn the weight value string to number without modifying…
DanDoW
  • 1
0
votes
2 answers

How do reconstruct the given booked trip dataset to a desired linked trip dataset using probably spread() and gather() functions in R?

I have a booked trip dataset as follows: bktrips <- data.frame( userID =c("P001", "P001", "P001", "P001", "P001", "P002", "P002", "P002", "P002"), mode = c("bus", "train", "taxi", "bus", "train", "taxi","bus", "train", "taxi"), Origin =…
0
votes
1 answer

Spread data by group ID ~ cbind each block with group ID

I have several data associated with an period ID which correspond to a period attributed regarding the date. I would like to build an automatic system to cbind each block associated with a group ID. This is just a sample of my data i have other…
0
votes
1 answer

breaks a service during migration to Angular 9

I usually use this method to get my values ​​from firebase. I have no problem with getUsers (). But since the switch to angularfire6, I have a problem with getUserById there: "... data" "error: spread type may only created from object…