Re: [R] intersection in data frame

2022-10-27 Thread Gábor Malomsoki
Dear all, i have tried all of your proposals, all of them was ok. Maybe dcast() with data table was faster. Thank you! Best regards Gabor Am Fr., 14. Okt. 2022 um 01:31 Uhr schrieb Dénes Tóth < toth.de...@kogentum.hu>: > Or if your data is really large, you can try data.table::dcast(). > > > l

Re: [R] intersection in data frame

2022-10-13 Thread Dénes Tóth
Or if your data is really large, you can try data.table::dcast(). > library(data.table) > dcast(ID ~ station, data = as.data.table(df1)) ID xy xz 1: 12 15 20 2: 13 16 19 (Note: instead of `as.data.table()`, you can use `setDT` or create your object as a data.table in the first place.) On

Re: [R] intersection in data frame

2022-10-13 Thread Rui Barradas
Hello, To reshape from long to wide format, here are two options: df1 <- 'IDstation value 12 xy15 12 xz20 13 xy 16 13 xz 19' df1 <- read.table(textConnection(df1), header = TRUE) # base R reshape(df1, direction = "wide", idvar = "ID", tim

Re: [R] intersection in data frame

2022-10-13 Thread Ben Tupper
Hi, If you are game to use a tidy approach then you can use tidyr::pivot_wider() library(dplyr) library(tidyr) x <- dplyr::tribble( ~ID, ~station, ~value, 12, "xy", 15, 12, "xz", 20, 13, "xy", 16, 13, "xz", 19) tidyr::pivot_wider(x, names_from = station,

[R] intersection in data frame

2022-10-13 Thread Gábor Malomsoki
Dears, i need to create from a column of observations variables in a datafram like this way: example: original: IDstation value 12 xy15 12 xz20 13 xy 16 13 xz 19 new df: ID xy xz 12 15 20 13 16 19 i have been loo