Hi,
I used pivot longer function to convert wide data to long data format and after that it inserted . character inside all values having white spaces. For example: in QUESTION column, values are: 'How are you?', ' Do you like it ?', and so on
After melting, my values came like: 'How.are.you?', '.Do.you.like.it.?', and so on.
But I needed to join these values with onother table and because of these dot character inside values, not able to perform join.
melted_data1 <- modified_data %>%
pivot_longer(
cols = starts_with("Question"),
names_to = "Question+Subquestion",
values_to = "Answer",
values_drop_na = FALSE,
)
Inside these answer values, all the data came like I mentioned above. Is there any way we can stop adding dot character inside vales for white spaces while we perform pivot longer or after performing pivot longer functions.
thank you
"Question.24...Response.1...64" "Question.24...Response.1...65" "Question.24...Response.1...66"
[913] "Question.24...Response.1...67" "Question.25...Response.1...68" "Question.25...Response.1...69"
[916] "Question.25...Response.1...70" "Question.25...Response.1...71" "Question.25...Response.1...72"
[919] "Question.25...Response.1...73" "Question.25...Response.1...74" "Question.25...Response.1...75"
[922] "Question.25...Response.1...76" "Question.26...Response.1...77" "Question.26...Response.1...78"
[925] "Question.26...Response.1...79" "Question.26...Response.1...80" "Question.27...Response.1...81"
[928] "Question.27...Response.1...82" "Question.28...Response" "Question.29...Response.1...84"
[931] "Question.29...Response.1...85" "Question.29...Response.1...86" "Question.29...Response.1...87"
[934] "Question.29...Response.1...88" "Question.29...Response.1...89" "Question.29...Response.1...90"
[937] "Question.29...Response.1...91" "Question.29...Response.1...92" "Question.29...Response.1...93"
[940] "Question.29...Response.1...94" "Question.29...Response.1...95" "Question.29...Response.1...96"
[943] "Question.29...Response.1...97" "Question.30...Response.1...98" "Question.30...Response.1...99"
[946] "Question.30...Response.1...100" "Question.1...Response" "Question.2...Response"
[949] "Question.3...Open.Ended.Response" "Question.4...Response...18" "Question.4...Response...19"
[952] "Question.5...Response.1...20" "Question.5...Response.1...21" "Question.5...Response.1...22"
[955] "Question.5...Response.1...23" "Question.5...Response.1...24" "Question.5...Response.1...25"
[958] "Question.6...Response.1...26" "Question.6...Response.1...27" "Question.6...Response.1...28"
[961] "Question.6...Response.1...29" "Question.6...Response.1...30" "Question.6...Response.1...31"
[964] "Question.7...Response.1...32" "Question.7...Response.1...33"
Desired Output (Do not worry about indexes [number])
"Question 1 - Response"
"Question 2 - Response"
"Question 3 - Open-Ended Response"
"Question 4 - Response"
"Question 4 - Response"
[20] "Question 5 - Response 1"
[21] "Question 5 - Response 1"
[22] "Question 5 - Response 1"
[23] "Question 5 - Response 1"
[24] "Question 5 - Response 1"
[25] "Question 5 - Response 1"
[26] "Question 6 - Response 1"
[27] "Question 6 - Response 1"
[28] "Question 6 - Response 1"
[29] "Question 6 - Response 1"
[30] "Question 6 - Response 1"
[31] "Question 6 - Response 1"
[32] "Question 7 - Response 1"
[33] "Question 7 - Response 1"
[34] "Question 8 - Response 1"
[35] "Question 8 - Response 1"
[36] "Question 8 - Response 1"
[37] "Question 8 - Response 1"
[38] "Question 9 - Response 1"
[39] "Question 9 - Response 1"