Hi PSYC3361!
Here is my Week 4 Learning Log
This week has been full on so today I got up at 6am to try and get through Dani’s final session - DPLYR, or a dance with data (for the third time lucky I hoped!)
Within 5 minutes I’d already hit an error message and I freaked out…I haven’t had much luck with getting past error messages in the past. The message said…“Error in 1:n : NA/NaN argument”. I had no idea what that meant and google just said there was a missing value, which didn’t make any sense to me… I powered on hoping the error wouldn’t affect things. I then started exercise one and for some reason I realised what I had done wrong (THIS IS REAL PROGRESS!!!). I’d forgotten to put brackets after n when writing the mystery file. The code should read: swow <– swow %>% mutate(id = 1:n()).
No sooner had I worked this error out when another error message came up. This time it said “Error in is.connection(x) : object ‘data_swow.csv.zip’ not found”. Again, I had no idea what this meant so I went back to the slides and realised I’d left out the quotation marks for the file name. The code should read: swow <- read_tsv(file = “data_swow.csv.zip”).
I then went back to the data and got the same error message. This time, for some reason, deleting file = helped. The code that worked read: swow <- read_tsv(“data_swow.csv.zip”)
It seems as though I need to post my question on Slack…for me to work out the answer myself…at which point I then delete the slack post. This method has worked without fail so far!!
I began exercise 2 and got another message: “Error: object ‘woman’ not found”. This time I knew pretty quickly that I hadn’t put woman in "“. The correct code read: filter(response ==”woman")
Onto data arranging, and yet another message… this really stumped me for a while and despite fixing it, I still don’t really know what was wrong…The message read: "Error in desc(strength) : object ‘strength’ not found. My understanding was that this meant strength wasn’t defined, but it was. The way I fixed it was to instead of just adding arrange(desc(strength)) after
woman_bck <- swow %>%
filter(response == "woman") %>%
filter(n_response >1)I rewrote below:
swow %>%
filter(response == "woman", n_response >1) %>%
arrange(desc(strength))and this seemed to work…
Again, it was after doing the exercise and posting on slack, that I was able to work this out for myself!
The same thing happened again but this time the message read: “Error in select(cue, response, strength, id) : object ‘cue’ not found”. Again, I still don’t understand why this is happening but for some reason rewriting it all fixes it, so this is what I did.
Actually, I think I may have finally worked it out. I think I’m forgetting to pipe (%>%) after filter and before arrange. I’m too scared to delete what I have to test this theory out but if the error message comes up again, I’ll try that as a troubleshooting method.
Okay yep…that was my issue!
Also, I got past the part that I had an error code last week with, by remembering to put the n from select(-starts_with(“n_”)) in ""!
Although no error codes are coming up, my man_bck won’t descend by strength despite arranging them and also don’t organise by rank…:
man_bck # A tibble: 289 x 6 cue response n_response n_total strength id
1 abusive man 3 100 0.03 1392 2 Adam man 4 98 0.0408 4127 3 adults man 2 100 0.02 5911 4 aftershave man 3 99 0.0303 7645 5 aggressive man 2 100 0.02 8212 6 Albert man 3 100 0.03 9659 7 animal man 2 100 0.02 14992 8 ape man 2 100 0.02 17448 9 armed man 2 100 0.02 20705 10 arrogance man 2 95 0.0211 21461 # … with 279 more rows
gender <- bind_rows( + man_bck, man_fwd, woman_bck, woman_fwd + ) gender # A tibble: 505 x 10 cue response n_response n_total strength id rank type word associate
1 abusive man 3 100 0.03 1392 NA NA NA NA
2 Adam man 4 98 0.0408 4127 NA NA NA NA
3 adults man 2 100 0.02 5911 NA NA NA NA
4 aftershave man 3 99 0.0303 7645 NA NA NA NA
5 aggressive man 2 100 0.02 8212 NA NA NA NA
6 Albert man 3 100 0.03 9659 NA NA NA NA
7 animal man 2 100 0.02 14992 NA NA NA NA
8 ape man 2 100 0.02 17448 NA NA NA NA
9 armed man 2 100 0.02 20705 NA NA NA NA
10 arrogance man 2 95 0.0211 21461 NA NA NA NA
# … with 495 more rows
gender A tibble: 505 x 5 id rank type word associate
1 1392 NA NA NA NA
2 4127 NA NA NA NA
3 5911 NA NA NA NA
4 7645 NA NA NA NA
5 8212 NA NA NA NA
6 9659 NA NA NA NA
7 14992 NA NA NA NA
8 17448 NA NA NA NA
9 20705 NA NA NA NA
10 21461 NA NA NA NA
… with 495 more rows
names_to you must also supply one of names_sep or names_pattern.