search for: pivot_long

Displaying 9 results from an estimated 9 matches for "pivot_long".

Did you mean: pivot_longer
2023 Apr 04
1
Simple Stacking of Two Columns
Just to repeat: you have NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly")) and you want NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly")) There must be something I am missing, because NamesLong <- data.frame(Names = c(NamesWide$Name1, NamesWide$Name2)) appears to
2023 May 02
1
Reg: Help regarding ggplot2
...uot;, 1.04, 0.615, 1.69, 2.48, 0.346, 0.509, 0.630, 1.01) -> data_vol3 ### please give us data using dput in future: saves us having to do something like that to reclaim it! ### pivot that longer to make it easy to get country data as separate lines data_vol3 %>%? select(-rowN) %>% ? pivot_longer(cols = -index, # as you want to pivot the other variables/columns ?????????????? names_to = "countries") -> tibDataVol3Long ggplot(data = tibDataVol3Long, ?????? aes(x = index, y = value, ???????????? ### now get the grouping and use it for a colour legend ???????????? group =...
2023 Oct 31
1
weights vs. offset (negative binomial regression)
...model, as below. > > ? ?cheers > ? ? Ben Bolker > > > edata <- data.frame(Catch, Effort, xx1, xx2, xx3) > > ## graphical exploration > > library(ggplot2); theme_set(theme_bw()) > library(tidyr) > edata_long <- edata |> pivot_longer(names_to="var", cols =-c("Catch", > "Effort")) > ggplot(edata_long, aes(value, Catch)) + > ? ? ?geom_point(alpha = 0.2, aes(size = Effort)) + > ? ? ?facet_wrap(~var, scale="free_x") + > ? ? ?geom_smooth(method = "g...
2023 Dec 04
2
Transformar una base de datos a matriz
Buenos d?as. Tengo una duda: Trabajo con comundiades de especies, y mis datos se ordenan de tal forma que, cada especie corresponde a una fila de la base de datos, por lo que cada muestra tiene un n?mero de filas correspondiente al n?mero de especies. Mi objetivo es transformar esa base de datos a un formato de matriz donde, cada muestra sea una fila ?nica y las especies sean las columnas, con
2023 May 16
0
Newbie: Controlling legends in graphs
...plot code > library(ggplot2) > library(dplyr) > library(tidyr) > library(lubridate) > > weights %>% > ??? mutate(Year = year(Date)) %>% > ??? group_by(Year) %>% > ??? summarize(across(J:K, mean, na.rm = TRUE)) %>% > ??? # now reshape the data > ??? pivot_longer(-Year) %>% > ??? # uncomment the next line if you want K > ??? # to show up on top in the legend > ??? # mutate(name = factor(name, levels = c("K", "J"))) %>% > ??? ggplot(aes(Year, value, color = name)) + > ??? geom_smooth( > ??????? formula = y...
2023 Apr 03
1
Simple Stacking of Two Columns
Hi, You were on the right track using stack(), but you just pass the entire data frame as a single object, not the separate columns: > stack(NamesWide) ? values ? ind 1 ? ?Tom Name1 2 ? Dick Name1 3 ?Larry Name2 4 ?Curly Name2 Note that stack also returns the index (second column of 'ind' values), which tells you which column in the source data frame the stacked values originated
2023 May 12
2
Newbie: Controlling legends in graphs
Hello, I'm trying to create a line graph with a legend, but have no success controlling the legend. Since nothing I've tried seems to work, I must be doing something systematically wrong. Can anyone point this out to me? Here's my data: > weights # A tibble: 1,246 ? 3 Date J K <date> <dbl> <dbl> 1 2000-02-13 133 188 2
2023 May 02
5
Reg: Help regarding ggplot2
Dear All, I have a dataset which contains date and 12 other countries data. I have extracted the data as xts object. I am not able to recall all the series in the Y axis. My data set looks like this index crepub finland france germany italy netherlands norway poland <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
2023 Apr 03
4
Simple Stacking of Two Columns
Hi R-Helpers, Sorry to bother you, but I have a simple task that I can't figure out how to do. For example, I have some names in two columns NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly")) and I simply want to get a single column