Learn R – Extract Data Frame with One Column

This article represents code sample that could be used to create/extract data frame with one column from existing data frame. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
Extract Data Frame with One Column

In the code sample below, diamonds dataset from ggplot2 package is used. To work with the example below, one needs to load the ggplot2 library using command such as require(“ggplot2”). In the command below, method as.data.frame is used. Make a note of drop=false parameter passed to as.data.frame method.

dfn1 <- as.data.frame(diamonds[,c(1)], drop=false)	
Ajitesh Kumar
Follow me

Ajitesh Kumar

I have been recently working in the area of Data Science and Machine Learning / Deep Learning. In addition, I am also passionate about various different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia etc and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data etc. I would love to connect with you on Linkedin and Twitter.
Posted in Data Science. Tagged with .

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.