Dataset data type incorrect - R

0 votes
Problem - Date field from the dataset import is taken as character instead of date type and Integre is taken as character.

How to assign/convert datatypes to different variables in R?
Jul 15 in Data Analytics by Devika
45 views

1 answer to this question.

0 votes

You can assign datatypes for the field using converting functions or while importing the data into a R variable.

For ex:

I have used global superstore dataset to show the data format as shown as above.

Lets convert data type of Ship date to Date and Row.Id to number datatype.

> d$Ship.Date = as.Date.character(d$Ship.Date,"%d-%m-%Y")
> d$Row.ID = as.numeric(d$Row.ID)

Another way is to provide a vector of variable locations to assign with a vector of datatypes.

> class(d$Row.ID) = "Numeric"

But this methos does not support date conversion, it would return NA values.

answered Jul 15 by anonymous

Related Questions In Data Analytics

0 votes
1 answer

Extract data fron R dataset

You can use the dplyr package,  Convert the ...READ MORE

answered Jul 29 in Data Analytics by Cherukuri
• 32,260 points
26 views
0 votes
1 answer

R Error: Recommender method UCBF not implemented for data type realRatingMatrix

Kalyan, Try changing method from UBCF to POPULAR. train ...READ MORE

answered Oct 28 in Data Analytics by anonymous
• 32,260 points
30 views
0 votes
1 answer

Create train and test data from dataset in R

Hi, Use sample or sample.split function to create ...READ MORE

answered Oct 13 in Data Analytics by anonymous
• 32,260 points
35 views
0 votes
1 answer

R query and Data Science

Dear Deepika, Hope you are doing great. You can ...READ MORE

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
41 views
+1 vote
2 answers
0 votes
1 answer

R programming logic

Use gsub to match the substring that we want ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,040 points
41 views
0 votes
1 answer
0 votes
1 answer

Editing the plots/visualization on a timeline.

find the ten lowest total cash flows. ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,040 points
23 views
0 votes
2 answers

Change data type of one column in R

You can change data types using as.* ...READ MORE

answered Aug 16 in Data Analytics by anonymous
• 32,260 points
184 views
0 votes
9 answers

Creating an empty data.frame with only column names - R

Will the below code work to create ...READ MORE

answered Aug 1 in Data Analytics by preeti
20,445 views