dataframe - How to create a similar data frame in R that is empty? -


i new r , need help. please me out in...

how create data frame (say mydata2) in r similar existing data frame (say mydata1 5 columns), blank. is, new data frame has 5 columns in mydata1 has no data in rows.

i want output have "0 obs. of 5 variables".

here, assuming column names , `data types. however, can change according requirements

  mydata2<- data.frame(x= character(0), y= numeric(0), = character(0), b= integer(0), c = numeric(0))    mydata2   # [1] x y b c   # <0 rows> (or 0-length row.names)    str(mydata2)   # 'data.frame':   0 obs. of  5 variables:   #  $ x: factor w/ 0 levels:    #  $ y: num    #  $ a: factor w/ 0 levels:    #  $ b: int    #  $ c: num     dim(mydata2)   # [1] 0 5    class(mydata2)   # [1] "data.frame" 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -