Identify object in R

0 votes

I'm facing a problem of identifying the output data type. If I'm expecting a list, it ends up being a list of lists or a data frame. What's a good method or workflow for figuring out the output data type when first using a function?

Jun 7, 2018 in Data Analytics by darklord
• 6,140 points
28 views

1 answer to this question.

0 votes

Hi, 

You can use ? followed by the function() or class(variable) it can provide you the class (or data type) of the output it can return. 

It's not suggested to do so for every function you use, so you can try explicitly converting your output into the required data type for the functions or operations that you are performing.

Some function has a default return type of the output that it returns, except those few you can try converting others as long as the conversion is possible and valid.

You can use functions such as unlist()as.[array/character/data frame/Date], etc that are vailable in R for conversions. 

answered Jul 2 by anonymous
• 25,620 points

Related Questions In Data Analytics

0 votes
1 answer

Check if the object(variable) is defined in R

You can use the exists(): > exists("toFindUnknown") [1] FALSE > ...READ MORE

answered Apr 17, 2018 in Data Analytics by darklord
• 6,140 points
47 views
0 votes
1 answer

"Error in eval(ei, envir) : object 'RDX2' not found" when trying to source the code in R

This is a very common issue that ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,040 points
532 views
0 votes
1 answer

How to check if object is defines in R?

You can use the exists function for ...READ MORE

answered Nov 6, 2018 in Data Analytics by Kalgi
• 40,420 points
28 views
0 votes
1 answer
0 votes
1 answer

Big Data transformations with R

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

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
47 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
61 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
124 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
102 views
0 votes
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 25,620 points
118 views
0 votes
2 answers

How to sum a variable by group in R?

You can also try this way, x_new = ...READ MORE

answered Jul 31 in Data Analytics by Cherukuri
• 25,620 points
7,279 views