I am using the data.table (version 1.10.4) to clean data (btw, I have installed "reshape2"), but I got this message:
Error in melt_check(data, id.vars, measure.vars, variable.name, value.name) : could not find function "patterns"
I checked many times, but don't figure out why. I am posting my code below, can anyone have a look at it, and tell me where I was wrong? Thanks.
library(reshape2)
library(data.table)
library(readxl)
data<-read_excel("Time3Ratee.xlsx")
meltdata<-melt(data,id = 1:4, measure = patterns ("^ratee\\d+$","^RICB.peer\\d+\\.1", "^RICB.peer\\d+\\.2","^RICB.peer\\d+\\.3", "^TICB.peer\\d+\\.1", "^TICB.peer\\d+\\.2","^TICB.peer\\d+\\.3","^LE.peer\\d+\\.1", "^LE.peer\\d+\\.2","^LE.peer\\d+\\.3","^LE.peer\\d+\\.4", "^DEV.peer\\d+\\.1", "^DEV.peer\\d+\\.2","^DEV.peer\\d+\\.3"), value.name = c("ratee", "RICB.peer.1", "RICB.peer.2","RICB.peer.3", "TICB.peer.1", "TICB.peer.2","TICB.peer.3", "LE.peer.1", "LE.peer.2","LE.peer.3","LE.peer.4", "DEV.peer.1", "DEV.peer.2","DEV.peer.3"))
patternsis a function only supported inside data.table::melt, not reshape2::melt. You'll get the former if you are applying melt to a data.table; but with a data.frame, a matrix or whatever read_excel returns, you'll get the latter.read_excel, but then (assuming it gives you a data.frame), usesetDTbefore applyingmelt. Likedata <- setDT(read_excel(...)). Your example is not reproducible, so there is no way for me to test if this works, of course.