above data is in data.frame which is in the folder E drive inside "Amesh's" folder
so by giving data.frame
strsplit('Incoming/Amesh_CV_v1.docx', '')
I want the output to be like
Path and Version in separate column
It should based on the Version i.e (v1, _v1, V1 and so on)
I tried text processing using tidytext
stringr
regmatches with gregexpr
string_extract using regex (regular expression)
I am not able to get any output
Kindly let me know I am trying this from two days.
I'm using the fill argument of separate() to get all of the files into the same column, despite the fact that the files are at different depths (you could probably extract file names using a regular expression, too, but I'm not that good at them).
I can't tell without the exact error message and a sample of the data, but I'm guessing that you don't have stringsAsFactors=FALSE set, and, thus, are trying to do string operations on factors. You can convert this by changing the column in the data frame character with as.character().
This is a separate question, and the answer depends on the file format. There's readLines() in base R, as well as read.csv(), etc. — both of these things can also be done with other packages, such as readr and data.table.
I am getting a error: non character argument in r
there are versions here right:
#> # A tibble: 8 x 4
#> lv1 lv2 lv3 version
#>
#> 1 Incoming Amesh_CV_v1.docx v1
#> 2 Incoming Amesh_CV_v2.docx v2
#> 3 Incoming Amesh_CV_v3.docx v3
#> 4 Incoming Amesh_CV_v4.docx v4
#> 5 Incoming Amesh_CV_v6.docx v6
#> 6 Incoming Amesh_Q_v1.docx v1
#> 7 Incoming MIT Akash_MIT_SoP_v1.docx v1
#> 8 Incoming MIT Akash_MIT_SoP_v2.docx v2
i.e : v1, v2, v3, v4, v6
v5 is missing there so how to extract the missing version
like: Version V5 is missing (i want it to be like this)
I want for this
dir("E:/Review/Angshuman_Baruah", pattern=NULL, all.files=FALSE,
full.names=FALSE, recursive = TRUE)
it has 49 entries
how to give out like this for the above file Ma'am
A tibble: 8 x 4
lv1 lv2 lv3 version
1 NA Incoming Amesh_CV_v1.docx 1
2 NA Incoming Amesh_CV_v2.docx 2
3 NA Incoming Amesh_CV_v3.docx 3
4 NA Incoming Amesh_CV_v4.docx 4
5 NA Incoming Amesh_CV_v6.docx 6
6 NA Incoming Amesh_Q_v1.docx 1
7 Incoming MIT Akash_MIT_SoP_v1.docx 1
8 Incoming MIT Akash_MIT_SoP_v2.docx 2
There's also a nice FAQ on how to do a minimal reprex for beginners, below:
What to do if you run into clipboard problems
If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.
By using above code I got files which are there inside the folder by giving recursive = TRUE
folder inside folder then files
so if i run the above code (first code) then it display all the file
if i run second code then it displays all the file in a data frame but
when i am trying to use that data frame as stringasfactor doesnot work because of the dir command
i want the output like
From the folder inside folder - files
i want to access all the file and display the versions for the filename
i.e: v1 ,v2 ,v4 ,v5, v6...............
if v 3 is missing i want output as
version v3 missing
the command which u sent earlier work for the input data, it doesnot work for the data.frame or files which are there inside the directory
i.e: E:/Review/Nidha Khan inside this there are folders like "Nidha Khan/MSc" inside this there are docx, xlsx, png and some folders (file inside this)
No its just folder inside directories which i have to extract
dir("E:/Review/Nidha_Khan", pattern=NULL, all.files=FALSE,
full.names=TRUE, recursive = TRUE)
This above command how to use :
details<-data.frame(dir("E:/Review/Angshuman_Baruah", pattern=NULL, all.files=FALSE,
full.names=FALSE, recursive = TRUE))
for this data
tibble(files) %>%
separate(files, into = c("lv1", "lv2", "lv3"), sep = "/", fill = "left") %>%
mutate("version" = str_extract(lv3, regex("v\d+")))
Output:::::
A tibble: 49 x 4
lv1 lv2 lv3 version
1 NA NA 1:49 NA
2 NA NA 1:49 NA
3 NA NA 1:49 NA
4 NA NA 1:49 NA
5 NA NA 1:49 NA
6 NA NA 1:49 NA
7 NA NA 1:49 NA
8 NA NA 1:49 NA
9 NA NA 1:49 NA
10 NA NA 1:49 NA
Can you please look at the reprex materials I linked to earlier. Though obviously I don't have your actual system drive, it's very hard to tell what's going on with unformatted code.