Result of nrow function - error

Can anyone help with this error message Error: unexpected '}' in "}" I keep getting when trying to run the following code

for(i in 1:(nrow(RPdta_AU))) {
  RPdta_AU[i, RPdta_AU$AU[i]]
%>% 'RPdta_AU$Corr_AU'

RPDta_AU has 3 columns RP, AU and Corr_AU. The RP field has an integer in each row and AU field has a list of names in each row, while the Corr_AU field is blank. The integer in RP corresponds to the position of the corresponding author's name in the list of names. The code is to try to extract the corresponding author's name from the AU field and output it to Corr_AU.

Hi @Willa2020 and welcome! Thanks for posting the code, but it is even easier for folks to help you if you posts a reproducible example (reprex) that contains your data and code. Please have a look at this guide, to see how to create one.

As to your code above, one problem I see is that you are using the pipe (%>%) when it sounds like you want to be using the assignment operator (<- or ->). If you post a reprex including your data, I'm sure we'll be able to help out!


It's hard to tell without the data, but how about selecting all four lines before executing? Sometimes RStudio won't include all the code which results in the error.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.