counting


Counting the number of capital letters in each row in [R]


I am working in R and I have a column with various upper case and lower case letters in each row. I am trying to count the number of uppercase letters in each row and create a column that shows that number. My column looks like this(just with a lot more rows in the whole data set):
gctaggggggatggttactactGtgctatggactac
gGaagggacggttactaCgTtatggactac
gcGaggggattggcttac
Is there an easy way to create a column that list the number of upper case letters in each row. Thank you.
This should work:
t = c("gctaggggggatggttactactGtgctatggactac", "gGaagggacggttactaCgTtatggactac", "gcGaggggattggcttac")
sapply(regmatches(t, gregexpr("[A-Z]", t, perl=TRUE)), length)

Related Links

How to answer queries of type l,r,k which finds number of elements in an array in range l to r which occurs atleast k times?
Dafny and counting of occurences
Counting the number of capital letters in each row in [R]
python: count values of dictionary
How to apply hyperloglog to a timeseries stream
Counting the number of occurrences of C in each line and outputting this number plus the total number of characters in that line
Digit Counting Issue in C++ Program
Binary Strings of the form *111*

Categories

HOME
events
powerbi
generics
angular-ui-grid
barcode-scanner
concurrency
biztalk
android-emulator
web2py
u-boot
rangy
xbox360
rest-assured
vertica
android-contacts
string-formatting
xsl-fo
spring-ldap
uislider
sybase-ase
function-points
environment
jstree
cellular-network
bitbake
fatfs
objectmapper
location-services
lxml
cucumber-junit
autoencoder
buildforge
ms-solver-foundation
xll
assert
praat
raytracing
optionaldataexception
google-prediction
virtual-memory
common-table-expression
music21
rightnow-crm
deployd
phppgadmin
patternlab.io
kendo-treeview
google-shopping-api
petsc
allegro
elastic4s
rational-performance-test
e
pyaudio
always-on-top
ftp-client
msbuild-4.0
openseadragon
right-to-left
jeasyui
persistent-object-store
enunciate
m4
phpquery
boost-proto
godeps
html.actionlink
decidable
arbre
chicagoboss
sqlbase
knife
espresso
karma-coverage
scala-swing
nssortdescriptor
nsmutabledata
findersync
thoughtworks-go
distributed-r
forio-contour
refit
property-injection
usb-flash-drive
armv6
discovery
boinc
application-server
disjoint-union
form-for
.net-remoting
donut-chart
significant-digits
cyrillic
red-system
live-wallpaper
getopt-long
fork-join
nosetests
cewolf
airprint
multiple-users
uninstaller
android-input-method
eventaggregator

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App