+ 2
friends, what is wrong with this?(I need to add the taken string to the list as a new field called "id", and output the result)
str <- readLines('stdin') x <- list("name"="James", "age"=42, "country"="USA") y <- list("id"="1-2-3") z<- c(x, y) print(z)
3 Antworten
+ 2
1. You aren't using the input. You assign it to a variable, but never use the variable.
2. Where does the value "1-2-3" come from that you assign to "id"? That's probably where you should use the variable str.
+ 1
now it's correct:
str <- readLines('stdin')
x <- list("name"="James", "age"=42, "country"="USA")
list <- c(x,"id"=str)
print(list)
+ 1
Dankeschön :)