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
mc
cucumber
angular-ui-grid
couchdb
transactions
visual-studio-2010
autocomplete
mathematical-optimization
gentelella
impala
ui-automation
cocotb
port
azure-logic-apps
locationmanager
watch-os-3
sap-fiori
game-maker
buffer
fullcalendar-scheduler
sslhandshakeexception
webstore
supervisord
tomcat8
mixpanel
varnish-vcl
jaspersoft-studio
infrared
sharedpreferences
gollum-wiki
rxjs5
chronicle-queue
function-points
fstar
hdmi
django-import-export
jsonresult
credit-card
progid
actframework
lxml
counting
dreamfactory
textmate2
redgate
llvm-ir
assert
ejml
flipkart
1wire
optionaldataexception
httphandler
dbcc
moinmoin
asihttprequest
intellij-lombok-plugin
entropy
iptv
mobile-angular-ui
network-protocols
polymaps
swiperefreshlayout
prefetch
xcode6.4
system.net.mail
callouts
mathml
unsigned
urbit
distributed-cache
psd
management-studio-express
ajax4jsf
textpattern
perceptron
html.actionlink
srv-record
dnx50
pythonxy
360-degrees
postal-code
artisan
kefir.js
com0com
webproject
console.log
r.java-file
maven-shade-plugin
kognitio-wx2
fat32
dc
producer
visual-c++-2012
libgcc
stripe.net
meteor-collections
pageviews
xmi
accountmanager
cpu-time
mod-perl
meteorite
ctp
saga
progress-db
stty
sly-scroller
django-filebrowser
dojo-1.9
ip-geolocation
clearinterval
getopt-long
uitextfielddelegate
prefuse
firebird1.5
liveconnect
affinetransform
memory-pool
qtextbrowser
kext
anonymous-types
android-input-method
rawcontacts
suggestbox
service-factory

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile