Hi @fixmeplease,
Welcome to the RStudio Community Forum.
Looks like your data has been imported from the CSV file incorrectly, since the commas in the second column mean that column has been imported as "character" not "numeric". You could fix that in Excel before importing, or deal with the problem in R. Another possibility is that second column is meant to be two separate columns?
suppressPackageStartupMessages(library(tidyverse))
vargrp <- data.frame(Date = c("1994-10-01","1995-01-01","1995-04-01",
"1995-07-01","1995-10-01","1996-01-01"),
GDP..mkt.prices = c("810,788", "823,972", "828,856",
"832,976", "840,680", "844,208"))
vargrp
#> Date GDP..mkt.prices
#> 1 1994-10-01 810,788
#> 2 1995-01-01 823,972
#> 3 1995-04-01 828,856
#> 4 1995-07-01 832,976
#> 5 1995-10-01 840,680
#> 6 1996-01-01 844,208
str(vargrp)
#> 'data.frame': 6 obs. of 2 variables:
#> $ Date : chr "1994-10-01" "1995-01-01" "1995-04-01" "1995-07-01" ...
#> $ GDP..mkt.prices: chr "810,788" "823,972" "828,856" "832,976" ...
var_one <- vargrp
var_one$price <- as.numeric(gsub(",", "", var_one$GDP..mkt.prices))
var_one <- var_one[, -2]
ts_one <- ts(var_one, frequency=4, start=c(1994, 4))
ts_one
#> Date price
#> 1994 Q4 1 810788
#> 1995 Q1 2 823972
#> 1995 Q2 3 828856
#> 1995 Q3 4 832976
#> 1995 Q4 5 840680
#> 1996 Q1 6 844208
str(ts_one)
#> Time-Series [1:6, 1:2] from 1995 to 1996: 1 2 3 4 5 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:2] "Date" "price"
var_two <- separate(vargrp,
GDP..mkt.prices,
into=c("price1", "price2"))
var_two$price1 <- as.numeric(var_two$price1)
var_two$price2 <- as.numeric(var_two$price2)
ts_two <- ts(var_two, frequency=4, start=c(1994, 4))
ts_two
#> Date price1 price2
#> 1994 Q4 1 810 788
#> 1995 Q1 2 823 972
#> 1995 Q2 3 828 856
#> 1995 Q3 4 832 976
#> 1995 Q4 5 840 680
#> 1996 Q1 6 844 208
str(ts_two)
#> Time-Series [1:6, 1:3] from 1995 to 1996: 1 2 3 4 5 6 810 823 828 832 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:3] "Date" "price1" "price2"
Created on 2021-06-19 by the reprex package (v2.0.0)