Created
November 13, 2018 15:11
-
-
Save korkridake/138db538fe2c8e26623d17191336d812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readtext) | |
# mytab = readtext('E:/KorkridAke_GithubRepo/sample_tuple_file.txt') | |
# readtext object consisting of 1 document and 0 docvars. | |
# # data.frame [1 x 2] | |
# doc_id text | |
# <chr> <chr> | |
# 1 sample_tuple_file.txt "\"(1,2), (1,\"..." | |
mytuple = strsplit(mytab$text, ', ') | |
mytuple = mytuple[[1]] | |
substring(mytuple[1], 2, 2) # get x value | |
substring(mytuple[1], 4, 4) # get y value | |
x = c() | |
y = c() | |
for (i in 1:length(mytuple)){ | |
my_x = substring(mytuple[i], 2, 2) | |
my_y = substring(mytuple[i], 4, 4) | |
x <- c(x, my_x) | |
y <- c(y, my_y) | |
rm(my_x) | |
rm(my_y) | |
} | |
mydata = data.frame(x = x, y = y) | |
ggplot(data = mydata, aes(x = x, y = y)) + | |
geom_point() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment