Re: [R] Syntax help for 'Pivot_longer'

2021-12-01 Thread John Kane
n the 'Date' > > >column. > > >data_long <- mutate(data_long, JulianDay = format(data_long$Date, "%j")) > > > > > ># Creates a new column called 'TimePeriod' where 1 = pre-construction, > > >and 2 = post-construction of

Re: [R] Syntax help for 'Pivot_longer'

2021-11-29 Thread Philip Monk
iod) > > > ># Change data types of Month, Year nad JulianDay > >data_long$Month <- as.numeric(data_long$Month) > >data_long$Year <- as.numeric(data_long$Year) > >data_long$JulianDay <- as.numeric(data_long$JulianDay) > > > ># 'Compactly disp

Re: [R] Syntax help for 'Pivot_longer'

2021-11-28 Thread Jeff Newmiller
s wrote: >> >> Often the issue is that different variables in the wide format are of >> different types so won't simply >> pivot_longer without you making decisions which the function shouldn't make >> for you. However, I think >> the error mes

Re: [R] Syntax help for 'Pivot_longer'

2021-11-28 Thread Philip Monk
ometimes seen, legalistically correctly I think, as outside the remit of > this Email list) but I agree > that the help for pivot_longer() and many other tidyverse functions is not as > good as it could be particularly > for people new to R. Often there is better documentation in vignettes

Re: [R] Syntax help for 'Pivot_longer'

2021-11-28 Thread Bert Gunter
Sighh... Questions on "non-standard" packages such as the TidyVerse universe are off topic here: per the posting guide: "If the question relates to a contributed package , e.g., one downloaded from CRAN, try contacting the package maintainer first. You can also use find("functionname") and packag

Re: [R] Syntax help for 'Pivot_longer'

2021-11-28 Thread Chris Evans
quot;R-help Mailing List" > Sent: Sunday, 28 November, 2021 13:57:07 > Subject: [R] Syntax help for 'Pivot_longer' > Hello, > > I have a wide table that I transform to a long table for analysis. > The wide table has 25 columns - the first is labels, then columns 2

Re: [R] Syntax help for 'Pivot_longer'

2021-11-28 Thread Kimmo Elo
Hi! If I understood this correctly, you want to pivot the columns from 2 to 25 and use the first column as a "key". Your data has 27 columns in total, right? I tested it with your data and seems that the parameter 'cols' does have some problems. It takes all variables irrespectively of the range

[R] Syntax help for 'Pivot_longer'

2021-11-28 Thread Philip Monk
Hello, I have a wide table that I transform to a long table for analysis. The wide table has 25 columns - the first is labels, then columns 2:25 are monthly data of LST which is in 19 rows. I mutate this with : data_long <- data %>% pivot_longer(cols = 2:25, names_to =