R Programming: Create an empty data frame
R Programming: Data frame Exercise-1 with Solution
Write a R program to create an empty data frame.
Sample Solution :
R Programming Code :
df = data.frame(Ints=integer(),
Doubles=double(),
Characters=character(),
Logicals=logical(),
Factors=factor(),
stringsAsFactors=FALSE)
print("Structure of the empty dataframe:")
print(str(df))
Sample Output:
[1] "Structure of the empty dataframe:" 'data.frame': 0 obs. of 5 variables: $ Ints : int $ Doubles : num $ Characters: chr $ Logicals : logi $ Factors : Factor w/ 0 levels: NULL
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: R Programming Data frame Exercises Home.
Next: Write a R program to create a data frame from four given vectors.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework