looking for some solutions? You are welcome.

SOLVED: csv conversion into ts object

Charles:

I need to convert data with five columns (first is a date and the rest are annual sales of four companies from 1983 to 2018). In some years, there are missing data and the first row has labels.

The data is structured as follows:

Year      dis    cob     rrl     jmat

1983      1,307      
1984      1,656
1985      1,700

Sales data for the other three companies start from 1993. I have used the code

sale_trial <- read.csv("file_name.csv", header = TRUE, stringsAsFactors = FALSE) 

to read the data into R. Then used

sale_ts <- as.ts(sale_trial) 

to convert it into a ts object.

However, most I end up only a portion of one column's data appearing when I view the sales_ts object with the rest of the columns showing NA when in fact there were sales data in the csv file.

I have tried numerous suggestions on csv reading & conversions and none has helped.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent