Here is what I would do to read your data:
> psAll <- readLines("/temp/node1-ps-1.txt") > ps <- read.table(text = substring(psAll, 1, 65) # parse the first part + , header = TRUE + , as.is = TRUE + , fill = TRUE + , check.names = FALSE + ) > commands <- substring(psAll, 66)[-1] # remove header > ps <- cbind(ps, COMMAND = commands) > > head(ps) USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 1 root 1 0 0 10372 692 ? Ss Aug09 0:02 init [5] 2 root 2 0 0 0 0 ? S< Aug09 0:00 [migration/0] 3 root 3 0 0 0 0 ? SN Aug09 0:00 [ksoftirqd/0] 4 root 4 0 0 0 0 ? S< Aug09 0:00 [watchdog/0] 5 root 5 0 0 0 0 ? S< Aug09 0:00 [migration/1] 6 root 6 0 0 0 0 ? SN Aug09 0:00 [ksoftirqd/1] > On Fri, Aug 16, 2013 at 9:08 AM, <mohan.radhakrish...@polarisft.com> wrote: > My code is not complete. But the headers I see are > > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > 68 4517 0.0 0.0 12348 864 ? S Aug08 0:00 > hald-addon-keyboard: listening on /dev/input/event1 > 68 4521 0.0 0.0 12348 860 ? S Aug08 0:00 > hald-addon-keyboard: listening on /dev/input/event0 > root 4529 0.0 0.0 10256 704 ? S Aug08 1:57 > hald-addon-storage: polling /dev/sr0 > > The last column value doesn't follow any rule. > > Thanks, > Mohan > > > > > > Re: [R] Output from unix PS > > > Sarah Goslee > to: > mohan.radhakrishnan > 16-08-2013 06:01 PM > > > > > Cc: > r-help > > > > > > > > > > You don't tell us your OS details or provide an actual reproducible > example, but the error suggests that COMMAND is not one of the column > names in your data frame. > > Have you checked that? When I run ps on my Fedora system, the column > name is CMD and not COMMAND. > > Sarah > > On Fri, Aug 16, 2013 at 7:30 AM, <mohan.radhakrish...@polarisft.com> > wrote: > > Hi, > > > > When I view this output from the unix command ''ps'' the columns seem to > > properly aligned but it is not read properly into the data frame. The > > aggregate function throws > > > > Error in aggregate.data.frame(data, by = list(COMMAND), FUN = sum) : > > object 'COMMAND' not found > > > > Is there a recomendation to massage this ? > > > > data = read.table("D:\\p..txt",sep="\t") > > > > agg<-aggregate(data,by=list(COMMAND),FUN=sum) > > > > 68 4524 0.0 0.0 12348 872 ? S Aug09 0:00 > > hald-addon-acpi: listening on acpid socket /var/run/acpid.socket > > 68 4528 0.0 0.0 12348 860 ? S Aug09 0:00 > > hald-addon-keyboard: listening on /dev/input/event1 > > 68 4532 0.0 0.0 12348 864 ? S Aug09 0:00 > > hald-addon-keyboard: listening on /dev/input/event0 > > root 4540 0.0 0.0 10256 704 ? S Aug09 1:02 > > hald-addon-storage: polling /dev/sr0 > > root 4576 0.0 0.0 8540 492 ? Ss Aug09 > > 0:00 /usr/bin/hidd --server > > root 4619 0.0 0.0 122008 1540 ? Ssl Aug09 0:00 > automount > > root 4636 0.0 0.0 26348 524 ? Ss Aug09 0:00 ./hpiod > > root 4641 0.0 0.0 154876 6428 ? S Aug09 > > 0:00 /usr/bin/python ./hpssd.py > > root 4654 0.0 0.0 63544 1212 ? Ss Aug09 > > 0:00 /usr/sbin/sshd > > root 4663 0.0 0.0 134208 2744 ? Ss Aug09 0:00 cupsd > > root 4677 0.0 0.0 21668 896 ? Ss Aug09 0:00 xinetd > > -stayalive -pidfile /var/run/xinetd.pid > > root 4695 0.0 0.0 66968 2324 ? Ss Aug09 0:00 > sendmail: > > accepting connections > > smmsp 4703 0.0 0.0 57716 1760 ? Ss Aug09 0:00 > sendmail: > > Queue runner@01:00:00 for /var/spool/clientmqueue > > root 4713 0.0 0.0 6480 372 ? Ss Aug09 0:00 gpm > > -m /dev/input/mice -t exps2 > > > > Thanks. > > > > > > > -- > Sarah Goslee > http://www.functionaldiversity.org > > > > > This e-Mail may contain proprietary and confidential information and is > sent for the intended recipient(s) only. If by an addressing or > transmission error this mail has been misdirected to you, you are requested > to delete this mail immediately. You are also hereby notified that any use, > any form of reproduction, dissemination, copying, disclosure, modification, > distribution and/or publication of this e-mail message, contents or its > attachment other than by its intended recipient/s is strictly prohibited. > > Visit us at http://www.polarisFT.com > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.