I have a sensor data in R studio. Each of the column values have semi colon in the end. What should I write to remove the semicolons from each value. I am attaching a picture. This data set is quite big, like about 5300 about entries. I want to remove semicolons, so I can easily plot them using ggplot() Sensor Data
This is my code:
library(ggplot2) T <- Sensor$V3
Displacement1 <- Sensor$V4
ggplot(Sensor, aes(x =T, y = Displacement1)) + geom_point()
I have recreated the Sensor dataset as a simplified CSV file (I called "iStack2.csv") which reads
Than you need to work on that file, clean it up and replace things to get a data frame like that
ID T Displacement1
1 0002 18.628 -0.0345
2 0003 17.28 -0.0245
3 0004 18.328 -0.0145
4 0005 19.628 -0.1245
5 0006 1.628 -0.345
6 0007 28.628 -0.2345
Here is the entire code with ggplot
rm(list=ls())
library(ggplot2)
filenames <- "iStack2.csv"
delim = ","
DF <- read.csv(filenames,header = F,sep=delim)
print(DF)
print(is.data.frame(DF))
DF2 <- data.frame(lapply(DF, function(x) gsub("13:00:", "", x)))
DF3 <- data.frame(lapply(DF2, function(x) gsub("=", "", x)))
DF4 <- data.frame(lapply(DF3, function(x) gsub(";", "", x)))
colnames(DF4) <- c("ID","T","Displacement1")
p1 <- ggplot(DF4, aes(x=T, y=Displacement1)) +
geom_point()
print(p1)
Hope this helps, obviously if would be better if you could produce a clean dataset to start with, it would save you lots of time.