Can anyone tell me what this path is trying to do: 'DesktopPersonalityDataCombined_3.copy$Big6[DesktopPersonalityDataCombined_3.copy$Big6]' I am simply trying to define (not create) variables. I have a csv file imported with data and I am trying to define the given variables in order to then recode them. As you can see the initial path recognized the variable but then the ls() command could not find the variable?
I'll start with addressing your second question/issue first: ls() is a function that returns a character vector of object names found in the provided environment. If no environment is provided, it defaults to use the Global environment (i.e. the main R workspace). So calling ls() on an object won't work, it only works on environments.
As for the first part, I am not sure what you mean by:
I am trying to define the given variables in order to then recode them
Yes, sorry. I am entirely new to all this. From what I understand I need to first make the variables (e.g., Big6) in my csv file "existent" before I am able to recode them. My professor gave me the pathway 'DesktopPersonalityDataCombined_3.copy$Big6[DesktopPersonalityDataCombined_3.copy$Big6]' to use but I have a limited understanding of it. I believe he explained it as 'DesktopPersonalityDataCombined_3.copy' is the file and then 'Big6' is the variable within the file I am trying to recode. I really don't understand the syntax.
Some clarifications, you are not working with a csv file (on disk), you have loaded data from a csv file into a data frame, which is an object in memory that contains tabular data, so Big6 would be a variable or a column of your data frame and in this context "defining" a variable is a synonymous of "creating" a variable.
See this example
# This represents the data frame you are working with
df <- data.frame(
big6 = c(3, 3, 6, 5, 9)
)
df
#> big6
#> 1 3
#> 2 3
#> 3 6
#> 4 5
#> 5 9
# Now I'm going to define a new variable called new_recoded
# based on big6 and recode 3 as 0
df$new_recoded = df$big6
df$new_recoded[df$new_recoded == 3] <- 0
df
#> big6 new_recoded
#> 1 3 0
#> 2 3 0
#> 3 6 6
#> 4 5 5
#> 5 9 9
Created on 2019-11-06 by the reprex package (v0.3.0.9000)
There are better methods to accomplish this task but I suppose you have to use base R for your course