I’m very new to R and have only had very limited basic instruction on using it in a statistics course for finding t scores and z scores and very basic correlational tests. I’m not a programmer and don’t program in any languages so my skillset is very liited here and I don’t really know what I’m doing. I’ve been given an Rnotebook assignment in a course and the instructions are lacking in my opinon and all the linked documentation they have provided is not answering my question nor is searching google. I’m hoping someone can help me with what is probably a simple and basic concept that I’ve just never learned.
I don’t know if this makes any difference, but packages that are installed and running include: dplyr, forcats, ggplot2, lubridate, psych, purrr, readr, stringr, tibble, tidyverse, base, datasets, graaphics, grDevices,methods, stats, and utils
I’m suppoposed to factor data from a survey that incudes a factor about arriving for appointments. The responses from that survey include “10 minutes early” “5 minutes early” “Precisely on time” “A few minutes late” and “I’m lucky to remember the appointment exists!” and blank responses “”
So when I try to order them and factor them I’ve entered this:
factor_appointments <- factor(appointments, order = TRUE, levels =c(’10 minutes early’,’5 minutes early’,’Precisely on time’,’A few minutes late’,’I’m lucky to remember the appointment exists!’, ”))
factor_appointments
summary(factor_appointments)
That returns an error:
Error: unexpected symbol in “factor_appointments <- factor(appointments, order = TRUE, levels =c(’10 minutes early’,’5 minutes early’,’Precisely on time’,’A few minutes late’,’I’m”
I’ve figured out it’s because the contraction in the word “I’m” makes it think a factor is ‘I’ followed by “m lucky to rember the appointment exists” because the coding uses ” to separate the levels so how do I get it to recognize I’m is not ‘I’ but a contraction word that’s still part of the larger label? If I simply remove the ‘ then it just counts zero instances of that response. If I leave it as is it retruns an error. What’s the soluton?
Cassandra Strand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.