Assigning function to element of a vector R -


i trying assign function every row of vector. not work properly. tried many things using parse, eval, etc no find mistake. think should not complicated. here's code

quartale <- c("2014", "2015") test <- c("arnaud", "elio", "pascal", "david", "senior")  for(i in 1:5){   assign(paste("meldungen.", quartale[1], "[",i, "]", sep=""),nchar(test[i]))                                    }  

thus, have vector

meldungen.arnaud = 6,4,6,5,6 

try this:

nam <- paste("meldungen.", quartale[1], sep="") assign(nam, nchar(test))  > meldungen.2014 [1] 6 4 6 5 6 

not sure looking there advice:

this code:

for (i in 1:5){ assign((paste0("meldungen.", test[i])), nchar(test[i]))} 

gives you

> meldungen.arnaud [1] 6 

respectively

> meldungen.elio [1] 4 

this code gives described in post:

> assign((paste0("meldungen.", test[1])), nchar(test)) > meldungen.arnaud [1] 6 4 6 5 6 

hope helps


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -