Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9090865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:28:30+00:00 2026-06-16T22:28:30+00:00

I have some data.frames dat1=read.table… dat2=read.table… dat3=read.table… And I would to count the rows

  • 0

I have some data.frames

dat1=read.table...
dat2=read.table...
dat3=read.table...

And I would to count the rows for each data set. So
the names are saved like this (cannot “change” it) vector=c(“dat1″,”dat2”,”dat3…)

p <- vector(numeric, length=1:length(dat))
counting <- function(x) {for (i in 1:x){
      p[i]<-nrow(dat[i])}
return(p)
}

This is not working because the input for nrow is a character, but i need integer(?) or?

Thx for help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:28:32+00:00Added an answer on June 16, 2026 at 10:28 pm

    You can use get for this, but be careful! Instead reading the tables at a list is the R-ish way:

    file.names <- list.files()
    
    dat <- lapply(file.names, read.table)
    

    Then you have all the conveniences of lapply and the apply family at your disposal, e.g.:

    lapply(dat, nrow)
    

    The solution using get (also vector is a bad variable name since its a very important function):

    lapply(vector, function(x) nrow(get(x)))
    

    Your method fails since there is no object called dat to index into. The for loop could look like:

    p = NULL
    for(v in vector) {
      p <- c(p, nrow(get(v)))
    }
    

    But that technique is poor form for lotsa reasons…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 data frames with different number of columns each. Some of the
I'm trying to do some data manipulation in R. I have 2 data frames,
I'm having some trouble indexing data.frames in R. I'm an R beginner. I have
I have a data frame that is some 35,000 rows, by 7 columns. it
I have two very large data frames (50MM+ rows) and I need to run
I have subset some data frames based on a three month period and named
I have a list of data.frames . Within each data.frame I want to split
So I have many data frames and I'm trying to merge them. Some of
I have some SerialPort code that constantly needs to read data from a serial
I have two data frames DF1, DF2 each with 2 vectors DF1$A DF1$B, DF2$C,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.