example data:
df_stock2 <-data.frame(url= c("https://www.example.com/test","https://www.example2.com/test","https://www.example3.com/test"), stock_yes_01 = c("Google","Microsoft","Yahoo"), stock_yes_02 = c("Yahoo","Google",NA))
I try to reproduce the code from here:
library(data.table)
setDT(df_stock2 )
df_stock3 <- dcast(melt(df_stock2 , url = 'url')[value != 'NA'],
url ~ value, fun.aggregate = length)
However it doesn't seam to work as expected.
Any idea why this is not working or what I have to change?
the error I receive:
> setDT(df_stock2)
Warning message:
In melt.data.table(df_stock2, url = "url") :
To be consistent with reshape2's melt, id.vars and measure.vars are internally guessed when both are 'NULL'. All non-numeric/integer/logical type columns are conisdered id.vars, which in this case are columns [url, stock_yes_01, stock_yes_02, stock_yes_03, ...]. Consider providing at least one of 'id' or 'measure' vars in future.
df_stock3 <- dcast(melt(df_stock2, url = 'url')[value != 'NA'],
+ url() ~ value, fun.aggregate = length)
Error in url() : argument "description" is missing, with no default
In addition: Warning message:
In melt.data.table(df_stock2, url = "url") :
To be consistent with reshape2's melt, id.vars and measure.vars are internally guessed when both are 'NULL'. All non-numeric/integer/logical type columns are conisdered id.vars, which in this case are columns [url, stock_yes_01, stock_yes_02, stock_yes_03, ...]. Consider providing at least one of 'id' or 'measure' vars in future.