Added option in select_weight
This commit is contained in:
18
R/pcm.R
18
R/pcm.R
@ -66,7 +66,11 @@ pcm <- function(df=NULL,items=NULL,grp=NULL,dif.items=NULL,type.dif=NULL,weights
|
|||||||
}
|
}
|
||||||
grp <- NULL
|
grp <- NULL
|
||||||
# prepare data
|
# prepare data
|
||||||
df <- df[,c('id',items)]
|
if (is.null(weights)) {
|
||||||
|
df <- df[,c('id',items)]
|
||||||
|
} else {
|
||||||
|
df <- df[,c('id',items,"weights")]
|
||||||
|
}
|
||||||
print(df)
|
print(df)
|
||||||
colnames(df)[2:(length(colnames(df)))] <- paste0("item",seq(1,length(colnames(df))-1))
|
colnames(df)[2:(length(colnames(df)))] <- paste0("item",seq(1,length(colnames(df))-1))
|
||||||
df.long <- reshape(df,v.names=c("item"),direction="long",varying=c(items))
|
df.long <- reshape(df,v.names=c("item"),direction="long",varying=c(items))
|
||||||
@ -108,7 +112,11 @@ pcm <- function(df=NULL,items=NULL,grp=NULL,dif.items=NULL,type.dif=NULL,weights
|
|||||||
cat("#################################################################################################\n")
|
cat("#################################################################################################\n")
|
||||||
}
|
}
|
||||||
# prepare data
|
# prepare data
|
||||||
df <- df[,c('id',items,"grp")]
|
if (is.null(weights)) {
|
||||||
|
df <- df[,c('id',items,"grp")]
|
||||||
|
} else {
|
||||||
|
df <- df[,c('id',items,"grp","weights")]
|
||||||
|
}
|
||||||
colnames(df)[2:(length(colnames(df))-1)] <- paste0("item",seq(1,length(colnames(df))-2))
|
colnames(df)[2:(length(colnames(df))-1)] <- paste0("item",seq(1,length(colnames(df))-2))
|
||||||
df.long <- reshape(df,v.names=c("item"),direction="long",varying=c(items))
|
df.long <- reshape(df,v.names=c("item"),direction="long",varying=c(items))
|
||||||
if (is.null(weights)) {
|
if (is.null(weights)) {
|
||||||
@ -197,7 +205,11 @@ pcm <- function(df=NULL,items=NULL,grp=NULL,dif.items=NULL,type.dif=NULL,weights
|
|||||||
cat("#################################################################################################\n")
|
cat("#################################################################################################\n")
|
||||||
}
|
}
|
||||||
# prepare data
|
# prepare data
|
||||||
df <- df[,c('id',items,"grp")]
|
if (is.null(weights)) {
|
||||||
|
df <- df[,c('id',items,"grp")]
|
||||||
|
} else {
|
||||||
|
df <- df[,c('id',items,"grp","weights")]
|
||||||
|
}
|
||||||
colnames(df)[2:(length(colnames(df))-1)] <- paste0("item",seq(1,length(colnames(df))-2))
|
colnames(df)[2:(length(colnames(df))-1)] <- paste0("item",seq(1,length(colnames(df))-2))
|
||||||
df.long <- reshape(df,v.names=c("item"),direction="long",varying=c(items))
|
df.long <- reshape(df,v.names=c("item"),direction="long",varying=c(items))
|
||||||
if (is.null(weights)) {
|
if (is.null(weights)) {
|
||||||
|
Reference in New Issue
Block a user