[R] Date format
Medic
m@|||P@dpo@t @end|ng |rom gm@||@com
Sun May 10 02:30:46 CEST 2020
I took a SAMPLE CODE (for Connected scatterplot) from the R gallery
and applied to MY DATA, but got:
"Error in as.Date.numeric(mydata$date) : 'origin' must be supplied".
P.S. I can not understand ?as.Date()
SAMPLE CODE
library(ggplot2)
library(dplyr)
library(hrbrthemes)
data <- read.table("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/3_TwoNumOrdered.csv",
header=T)
str(data)
'data.frame': 1822 obs. of 2 variables:
$ date : chr "2013-04-28" "2013-04-29" "2013-04-30" "2013-05-01" ...
$ value: num 136 147 147 140 126 ...
data$date <- as.Date(data$date)
# Plot
data %>%
tail(10) %>%
ggplot( aes(x=date, y=value)) +
geom_line( color="grey") +
geom_point(shape=21, color="black", fill="#69b3a2", size=6) +
theme_ipsum() +
ggtitle("Evolution of bitcoin price")
MY DATA
mydata <- read.table("E:/mydata.csv", header=TRUE, sep=";", dec=",")
str(mydata)
'data.frame': 7 obs. of 2 variables:
$ date : chr "01.01.2000" "02.01.2000" "03.01.2000" "04.01.2000" ...
$ value: int 11 12 13 14 15 16 17
mydata$date <- as.Date(mydata$date)
Error in as.Date.numeric(mydata$date) : 'origin' must be supplied
More information about the R-help
mailing list