Skip to content

Commit

Permalink
Export code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmeloman committed Nov 17, 2020
1 parent f6c47f7 commit ee095d1
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .Rproj.user/DFCA1C7C/sources/prop/421CC383
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "128,0",
"scrollLine": "119"
"scrollLine": "140"
}
6 changes: 6 additions & 0 deletions demographics.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
library("writexl")

demographics <- read.csv("oxford_hgshsa_260820_demographics.csv", sep = ";")

demographics$missing <- data.export$has.na

write_xlsx(demographics,"hab_taxon_demographics_2020_final_exported.xlsx")

data <- read.csv("oxford_hgshsa_260820_modded.csv", sep = ";")

data <- na.omit(data)
Expand Down
34 changes: 24 additions & 10 deletions hability_taxon_data_prep.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
library("RTaxometrics")
library("dplyr")
library("writexl")

#Read the data
data <- read.csv("oxford_hgshsa_260820_modded.csv", sep = ";")

data <- na.omit(data)

#Prepare a table for exporting for OSF
data.export <- data

#Generate the xlsx file for OSF
data.export$has.na <- 0
data.export$has.na[rowSums(is.na(data.export)) > 0] <- 1
write_xlsx(data.export,"hab_taxon_2020_final_exported.xlsx")

#Get the filtered data
data <- data.export[data.export$has.na == 0,]

#Subset the dataset for involuntariness scale
invol <- select(data, INV.1:INV.12)

#Classify data with base rates .15 and .10
invol15 <- ClassifyCases(invol, p = 0.15)

invol10 <- ClassifyCases(invol, p = 0.10)

#Remove problematic items
invol_purified <- select(data, INV.3:INV.10)

#Classify data with base rates .15 and .10
invol_pur15 <- ClassifyCases(invol_purified, p = 0.15)

invol_pur10 <- ClassifyCases(invol_purified, p = 0.10)
Expand All @@ -25,7 +41,7 @@ invol$challenge <- invol$INV.4 + invol$INV.5 + invol$INV.6 + invol$INV.8 + invol
invol$cogper <- invol$INV.9 + invol$INV.11
invol$amnesia <- invol$INV.12


#Subset subscales columns and classify
invol_subscales15 <- select(invol, ideomotor, challenge, cogper, amnesia)
invol_subscales15 <- ClassifyCases(invol_subscales15, p = 0.15)

Expand All @@ -41,7 +57,7 @@ invol_purified$ideomotor <- invol_purified$INV.3 + invol_purified$INV.7
invol_purified$challenge <- invol_purified$INV.4 + invol_purified$INV.5 + invol_purified$INV.6 + invol_purified$INV.8 + invol_purified$INV.10
invol_purified$cogper <- invol_purified$INV.9


#Subset subscales columns and classify
invol_subscales_pur15 <- select(invol_purified, ideomotor, challenge, cogper)
invol_subscales_pur15 <- ClassifyCases(invol_subscales_pur15, p = 0.15)

Expand All @@ -56,6 +72,7 @@ invol_subscales_pur10 <- ClassifyCases(invol_subscales_pur10, p = 0.10)
#Create a H. suggestibility subset
hab <- select(data, HGSHS.A1:HGSHS.A11, HGSHS.A12)

#Classify data with base rates .15 and .10
hab15 <- ClassifyCases(hab, p = 0.15)

hab10 <- ClassifyCases(hab, p = 0.10)
Expand All @@ -66,6 +83,7 @@ hab10 <- ClassifyCases(hab, p = 0.10)
#Create a H. suggestibility subset without "bad" items
hab_purified <- select(data, HGSHS.A3:HGSHS.A10)

#Classify data with base rates .15 and .10
hab_pur15 <- ClassifyCases(hab_purified, p = 0.15)

hab_pur10 <- ClassifyCases(hab_purified, p = 0.10)
Expand All @@ -80,7 +98,7 @@ hab$challenge <- hab$HGSHS.A4 + hab$HGSHS.A5 + hab$HGSHS.A6 + hab$HGSHS.A8 + hab
hab$cogper <- hab$HGSHS.A9 + hab$HGSHS.A11
hab$amnesia <- hab$HGSHS.A12


#Subset subscales columns and classify
hab_subsc15 <- select(hab, ideomotor, challenge, cogper, amnesia)
hab_subsc15 <- ClassifyCases(hab_subsc15, p = 0.15)

Expand All @@ -96,7 +114,7 @@ hab_purified$ideomotor <- hab_purified$HGSHS.A3 + hab_purified$HGSHS.A7
hab_purified$challenge <- hab_purified$HGSHS.A4 + hab_purified$HGSHS.A5 + hab_purified$HGSHS.A6 + hab_purified$HGSHS.A8 + hab_purified$HGSHS.A10
hab_purified$cogper <- hab_purified$HGSHS.A9


#Subset subscales columns and classify
hab_subsc_pur15 <- select(hab, ideomotor, challenge, cogper)
hab_subsc_pur15 <- ClassifyCases(hab_subsc_pur15, p = 0.15)

Expand All @@ -105,11 +123,7 @@ hab_subsc_pur10 <- select(hab, ideomotor, challenge, cogper)
hab_subsc_pur10 <- ClassifyCases(hab_subsc_pur10, p = 0.10)


# Performing the analysis

## Involuntariness data: separate items

### P = 0.15
# Perform the analysis

cat("invol15")
RunTaxometrics(invol15)
Expand Down
Loading

0 comments on commit ee095d1

Please sign in to comment.