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, 2019 in Data Analytics by Devika

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, 2019 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, 2019 in Data Analytics by Cherukuri
• 32,930 points
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, 2019 in Data Analytics by anonymous
• 32,930 points
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, 2019 in Data Analytics by anonymous
• 32,930 points
+1 vote
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
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 8, 2018 in Data Analytics by Abhi
• 3,720 points
+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,840 points
0 votes
1 answer
+1 vote
2 answers

Change data type of one column in R

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

answered Aug 16, 2019 in Data Analytics by anonymous
• 32,930 points
+4 votes
11 answers

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

Hi, You need to create a data frame ...READ MORE

answered Dec 11, 2020 in Data Analytics by MD
• 95,180 points