-1

I want to split the following data into three columns.

Sample column from which I want to split the data. I have thousands of rows like:

dimension116  
15.3859085 | 74.0314209 | 7J7P92PJ+9H77QGCCCC   

... then store in this format:

A                    B             C  
15.3859085     74.0314209   7J7P92PJ+9H77QGCCCC   

Here is my example code:

ga.data$dimension116<-as.character(ga.data$dimension116)

ga.data$col<-strsplit(ga.data$dimension116, "|")


ga.data$col<-strsplit(ga.data$dimension116, "|")[1]

[[1]]
 [1] "1" "3" "." "0" "4" "0" "3" "7" "1" " " "|" " " "8" "0" "." "1" "9" "3" "8" "2"
[21] "5" "7" " " "|" " " "7" "M" "5" "2" "2" "5" "R" "V" "+" "4" "G" "W" "V" "4" "X"
[41] "R" "R" "W" "R"

Also how can i reverse geo code to obtain address against the latitude(A) and longitude(B).

I went through a lot of posts none helps.

I have the api key but throws 400 bad request.

I tried through git but this appears Error: Failed to install 'unknown package' from GitHub: attempt to set an attribute on NULL

Is there simpler way rather than using git or google api.

ashishpat
  • 51
  • 7
  • 3
    try to escape the pipe `\\|` – fra Oct 31 '19 at 10:59
  • In case, `library(stringr); str_split_fixed(text, "\\|", 3)`. – s__ Oct 31 '19 at 11:01
  • Try to stick to one question per post. This question is mostly about splitting a string, which has been covered elsewhere and is why it's been closed as a duplicate. But then you're asking about geocoding (unclear how you're trying this), an API key (to what?) and installing a package (what package?) – camille Oct 31 '19 at 15:08

1 Answers1

0

ga.data<- data.frame(do.call('rbind', strsplit(as.character(ga.data$dimension116),'|',fixed=TRUE)))

ashishpat
  • 51
  • 7
  • Not sure what this is. If it's meant to be an answer, please make it a complete one (see [answer]). If it's additional code for the question, edit the question to include it – camille Oct 31 '19 at 15:05