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
3 answers

How can i add a property to an inner Object in Typescript with spread operator?

I have following Object let car = { year: 2004, type: {name: "BMW"} } Now i want to add a property to inner object "type". I want to to this with the spread operator, since i need a new object, because the existing is an immuteable state object.…
Emre Öztürk
  • 2,660
  • 4
  • 16
  • 19
0
votes
1 answer

tidyr::spread but keep original data

data: test = data.frame(case=c("cyl","eng","mon"), worst=c(1,0,1),money=c(123,42,13),girl=c("no","yes","no")) desired_test= data.frame(case=c("cyl","eng","mon"), worst=c(1,0,1),money=c(123,42,13),girl=c("no","yes","no"), …
Helen
  • 533
  • 12
  • 37
0
votes
2 answers

Change Rows to Columns and Group By

I have a relatively large DF and now need a way to make columns out of rows. My DF looks like this: AID FNAME FVALUE 1 A 10 1 B 12 1 C 16 2 A 10 2 E 4 3 F 10 3 G 13 and so on. Not all rows have all…
Timothy_Goodman
  • 393
  • 1
  • 5
  • 18
0
votes
0 answers

Iterate through columns performing group_by and neighbor assignment

Probably this is a common question, but I wasn't able to find any answer capable to fit in my problem. I have data that has a column where some lines are assigned and others are NA. The NA cases may be assigned if it belongs to a group where has at…
Aureliano Guedes
  • 767
  • 6
  • 22
0
votes
0 answers

Is there an R function to redefine a variable so I can use the spread function?

I'm new with R and I have the following problem. Maybe it's a really easy question, but I don't know the terms to search for an answer. My problem: I have several persons, each person is assigned a studynumber (SN). And each SN has one or more…
AvdH
  • 39
  • 1
  • 6
0
votes
2 answers

How can I spread the dates in this data frame?

I need to spread the date value of a data frame (long to wide) but am having trouble achieving this because there are two variables that I need. A solution I thought of might be to create two separate data frames, one for each variable, with the…
Mus
  • 7,290
  • 24
  • 86
  • 130
0
votes
0 answers

R: invalid multibyte string 1 (with spread)

I'm trying to spread two columns but R is returning Error in make.names(x) : invalid multibyte string 1 There are plenty of questions here and elsewhere about invalid multibyte strings, but they are all for reading files into R; the issue seems to…
Unrelated
  • 347
  • 2
  • 14
0
votes
2 answers

Convert multi-line Excel group to individual lines

I have an Excel document with groups and username names in such a format: Group1 user1 user2 user3 Group2 user2 user4 Group3 user5 etc.etc. Each of the Groups is a single…
Zomgie
  • 92
  • 1
  • 12
0
votes
2 answers

Why are parentheses needed in this expression?

In the following code snippet: // Error code: (y,...x) => {...x,y}; // output = "SyntaxError: Unexpected token ..." // Expected result: (y,...x) => ({...x,y}); I don't quite understand why the "()" are needed to surround the object literal. I…
0
votes
1 answer

spread() function used to work, now gives error about object 'as_data_frame.matrix' of mode 'function' was not found

I was running code from a month ago with the tidyr package's spread() function, and it now throws the error below. Does the code need to be changed, or the package updated? Error in get("as_data_frame.matrix", asNamespace("tibble"), mode =…
0
votes
2 answers

How to convert row names to column names and bind it by order in r

I am working on a data set: Annual Returns by Ticker and I want to convert to : Result Matrix I used the code: returns.df <- returns %>% spread(key = DATE, value = RETURN) and its is showing wrong order: enter image description here
0
votes
2 answers

Why are the keys not spread across multiple columns?

I am trying to spread the key-values of the 'Type' column across multiple columns. The dataframe (dat_weighted) is as follows: AreaName Type index_disagg_standard index Category 1 Barking and Dagenham MRF 0.3329420 0.518…
Daniel
  • 471
  • 3
  • 8
  • 18
0
votes
1 answer

R: Gather/Spread/Reshape 21 Columns Based on 21 Other Column s

I would like to create columns based on values in some fields, populated by values in other fields. For example column1_time has value "1030" and column1_status has value "booked". I would like to pivot those into a new field time1030 with value…
Rob Causey
  • 323
  • 2
  • 9
0
votes
1 answer

R: Why do I lose data with spread()?

I have a tibble that looks like this. # A tibble: 1,000 x 3 id question answer
Cauder
  • 2,157
  • 4
  • 30
  • 69
0
votes
1 answer

I want to make tidy data

I want to make spread data based on duplicate data. I want to accumulate column based on overlapping rows. For example, X2 column is repeated 5 times. It looks similar to using spread function in tidyr package, but it's a little different. Could you…
Sang won kim
  • 524
  • 5
  • 21