I have more than 100 name-items on my R Script without " " and "," between them. I want to make a vector from them.
AWE XYA Name3 WERFS XYAGD ...... DSFSF
The vector should be
vec <- c("AWE", "XYA" ,"Name3" ,"WERFS" ,"XYAGD" ...... ,"DSFSF")
Instead of manually entering " " and,. Is there a way to automate this?
If you want to do that from Rstudio, you have some solutions here .
You also have a Rstudio addin
to put quotation mark around words:
remotes::install_github("hrbrmstr/hrbraddins")
See there or there . After putting quotation marks, you can do a find and replace after selecting the area in the script to transform "
into ",
Assuming the file in which this is stored is called temp.R
, you can use scan
to get a character vector. This will also work if you have text ( .txt
) file.
vec <- scan('temp.R', what = "character", quiet = TRUE)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.