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,641 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 30, 2019 in Data Analytics by Cherukuri
• 33,030 points
614 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
• 33,030 points
1,064 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 14, 2019 in Data Analytics by anonymous
• 33,030 points
3,313 views
+1 vote
1 answer

R query and Data Science

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

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,570 points
907 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 9, 2018 in Data Analytics by Abhi
• 3,720 points
1,672 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,840 points
768 views
0 votes
1 answer
+2 votes
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
• 33,030 points
122,265 views
+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,460 points
108,104 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP