Column of an existing data frame as a new data frame in R, but result is NULL -


i have data.frame (name: sample) in r imported csv file containing 15 fields , 100516 columns. want create new data frame "sample2" 3rd column of "sample".

sample2 = sample[,3] 

when checked nrow(sample2) result null.

but when used head(sample2) can see content.

your problem using nrow on vector.

if want keep data.frame structure when selecting single column in way, need add drop = false when subsetting.

consider following example:

## sample data mydf <- data.frame(v1 = 1:2, v2 = 3:4) nrow(mydf) # [1] 2  ## did mydf[, 1] # [1] 1 2 nrow(.last.value) # null  ## wanted mydf[, 1, drop = false] #   v1 # 1  1 # 2  2 nrow(.last.value) # [1] 2 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -