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
140 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, 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,490 points
67 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, 2019 in Data Analytics by anonymous
• 32,490 points
113 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, 2019 in Data Analytics by anonymous
• 32,490 points
808 views
+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
93 views
+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,680 points
194 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,820 points
67 views
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,490 points
861 views
+3 votes
10 answers

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

fruit_Frame<-data.frame(Fruit=NA, Cost=NA, Quantity=NA)[-1,]; ...READ MORE

answered May 7 in Data Analytics by yxcv

edited May 8 by Gitika 62,646 views