Blogalia

"En el arte marcial como en la vida diaria. En la vida diaria como en un arte marcial."

Aikido

Sígueme en Twitter

<Marzo 2019
Lu Ma Mi Ju Vi Sa Do
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
             


Todas las Historias

VELOCIDAD DE ESCAPE

Inicio > Historias > COSAS QUE NUNCA TE DIJE, EN R. (1)

2016-06-15

COSAS QUE NUNCA TE DIJE, EN R. (1)

Cuando llevas un tiempo pegándote con esto del Data Science, que es, a decir de los entendidos, lo que yo hago aunque lleve haciéndolo desde casi el siglo pasado, entonces bajo otros nombres, terminas llegando a R.

Y es lógico, pues se trata del lenguaje más útil que puedes aprender si lidias con datos. R está muy arriba, sólo en la cúspide, con el SQL a muy corta distancia, y un poco más atrás Python.

Dedicarse a esto y no conocer SQL y R es como pretender correr una maratón con grilletes en ambos pies. Mejor dedícate a otra cosa. Llegarás tarde, llegarás mal, y llegarás magullado.

Ya hace casi dos años que topé con este maravilloso, potente, fascinante (se me acaban los adjetivos) lenguaje, y no puedo hacer más que recomendarlo.
Al principio con timidez, y en la última época intensivamente, lo uso a diario, y a diario también, me sorprende con cosas nuevas.
A diario. ¿de cuántos lenguajes se puede decir lo mismo?

Como todo nuevo lenguaje, al principio te toca "pelearte" con ciertos comportamientos "extraños", que no vienen sino a ser peculiaridades del propio lenguaje,
y que pronto comienzas a reconocer, como cuando se reconoce a un viejo amigo. Sin embargo, estas pequeñas "peleas" no aparecen en los ejemplos ni en los tutoriales de la web.
Te quitan no pocas horas, pero son cosas tan elementales o al margen del objetivo central de un proyecto que se obvian o no se suelen mencionar y siempre eché de menos que alguien me hubiese echado una mano en esos momentos.

Pues aquí va mi aportación. Esta serie se denomina: "Cosas que nunca te dije. En R"

Lo habitual cuando manipulas tus datos y estás en una fase inicial, es que de todo el set de datos, en un momento dado deseas quedarte con un conjunto reducido.
Esto en R se denomina "subsetting", y es muy habitual.

Imaginemos un pequeño set de datos:

Generamos dos secuencias. Una de letras y otra de números y con ellas componemos el dataframe (objeto tabular básico de R)

df <- data.frame(letters=letters[1:5],numbers=seq(1:5))

 
df
 
letters numbers
1 a 1
2 b 2
3 c 3
4 d 4
5 e 5



Veamos los diferentes Levels de los Factores. Levels viene a ser el equivalente de UNIQUE ó DISTINCT y los Factores son aquellas columnas que almacenan valores categóricos, que pueden ser tanto numeros como cadenas de texto.


levels(df$letters)

[1] "a" "b" "c" "d" "e"


Hacemos un subsetting de las filas cuyo número sea mayor de 3

subdf <- subset(df, numbers <=3)

 
subdf
 
letters numbers
1 a 1
2 b 2
3 c 3

Y ahora viene lo bueno: Volvemos a mirar los Levels
levels(subdf$letters)

[1] "a" "b" "c" "d" "e"

¿¿CÓMO ES POSIBLE QUE SEAN LOS MISMOS ?? si hemos eliminado filas!!
Huelga decir que intentas hacer el subsetting de otras maneras, pero siempre terminas llegando a la misma conclusión: hago algo mal y no sé qué es.

Lo único que ocurre es que R conserva los Levels originales de un factor aunque hagamos subsetting.
Se soluciona habitualmente factorizando de nuevo o con droplevels

# factorizando

subdf$letters <- factor(subdf$letters)
 
# droplevels
subdf$letters <- droplevels(subdf$letters)
 
 
# et voilá
 
levels(subdf$letters)
[1] "a" "b" "c"

Programación | jomaweb | 11 Comentarios | Enlace


Referencias (TrackBacks)

URL de trackback de esta historia http://jomaweb.blogalia.com//trackbacks/76381

Comentarios

1
De: hotmail Fecha: 2018-09-10 07:22

https://hotmailde.de/www-hotmail-de-anmeldung/



2
De: Jim Harxmon Fecha: 2019-01-09 04:19

card games free



3
De: felix1seid Fecha: 2019-01-10 11:29

HP Printer Support
HP Computer Support
HP Laptop Support
HP Printer Customer Service
HP Printer Drivers
HP Printer Helpline
HP Printer Atlanta
HP Printer Baltimore MD
HP Printer Berkeley CA
HP Printer Boston
HP Printer Chicago
Dell Customer Service
Samsung Customer Service
Toshiba Customer Service
Panasonic Customer Service
Epson Customer Service
Sharp Customer Service
Printronix Customer Service
Lemark Customer Service
Canon Customer Service
HP Printer Repair Near Me
HP Printer Orange County
HP Printer Orlando
HP Printer Pasadena CA
HP Printer Phoenix
HP Printer Portland Oregon
HP Printer Raleigh NC
HP Printer Sacramento
HP Printer San Diego
HP Printer San Francisco
HP Printer San Jose
HP Printer Seattle
HP Printer St Louis MO
HP Printer Tulsa
HP Printer Vancouver WA
HP Printer Setup
HP Printer Harvey Norman
HP Sacnner Support
HP Support Phone Number
HP Printer Installation
The Customer Service Phone Number
About Us
Adt Customer Service
Air India Express Airlines Customer Service
Airasia India Customer Service
Airlines Customer Service
Alaska Airlines Customer Service
Allegiant Air Customer Service
Amazon Customer Service Number
Apple Customer Service Number
Atlas Air Customer Service
Att Business Customer Service Number
Att Customer Service Number
Att Email Customer Service
Bank Of America Customer Service Number
Banks Customer Service
Boost Mobile Customer Service Number
British Airways Customer Service Number
British Airways Executive Club Customer Service Number
British Airways Uk Customer Service Number
Cable Companies Customer Service
Car Rental Customer Service
Cathay Pacific Airlines Customer Service
Chase Customer Service Number
Citizens Bank Customer Service Number
Comcast Customer Service Number
Comcast Email Customer Service
Comcast Xfinity Home Security Systems Customer Service Number
Companies
Computer Customer Service
Consumer Service Customer Service
Contact Us
Delta Airlines Skymiles Customer Service Number
Delta Customer Service Number
Department Store Customer Service
Dish Network Customer Service Number
Ebay Customer Service Number
Email
Enterprise Rent A Car Customer Service Number
Envoy Air Customer Service
Equifax Customer Service Number
Etihad Airways Customer Service
Expedia Customer Service Number
Fedex Canada Customer Service Number
Fedex Customer Service Number
Fedex International Customer Service Number
Geico Customer Service Number
Godaddy Email Customer Service
Government Customer Service
Hertz Customer Service Number
Home Security
Hp Customer Service
Hulu Customer Service Number
Icloud Mail Customer Service
Incredimail Customer Service
Insurance Customer Service
Irs Customer Service Number
Jet Airways Customer Service
Jetblue Airlines Customer Service Number
Juno Email Customer Service
Kroger Customer Service Number
Lufthansa Airlines Customer Service
Macy Customer Service Number
Malaysia Airlines Customer Service
Medco Pharmacy Customer Service Number
Netflix Customer Service Number
Office 365 Email Customer Service
Outlook Email Customer Service
Paypal Customer Service Number
Pharmacy Customer Service
Phone Company Customer Service
Roadrunner Email Customer Service
Sbcglobal Email Customer Service
Shipping Customer Service
Shopping Customer Service
Singapore Airlines Customer Service
Skywest Airlines Customer Service
Spicejet Airlines Customer Service
Spirit Airline Customer Service
Sprint Customer Service Number
Store
Straight Talk Customer Service Number
Supermarket Customer Service
T Mobile Customer Service Number
Tech
Thai Airways Customer Service
Time Warner Cable Customer Service Number
Trujet Airlines Customer Service
Turkish Airlines Customer Service
Uber Customer Service Number
United Airlines Customer Service Number
Ups Customer Service Number
Ups Freight Customer Service Number
Ups Mail Innovations Customer Service Number
Ups Uk Customer Service Number
Verizon Customer Service Number
Verizon Email Customer Service
Virgin America Customer Service Number
Visa Customer Service Number
Vivint Customer Service
Wells Fargo Customer Service Number
Xfinity Email Customer Service
Yahoo Customer Service Number
Yahoo Email Customer Service
Zoho Mail Customer Service
Dell Customer Service
Samsung Customer Service
Toshiba Customer Service
Panasonic Customer Service
Epson Customer Service
Sharp Customer Service
Printronix Customer Service
Lemark Customer Service
Canon Customer Service
Printer Support
Apple Wireless Printer Support
Brother Printer Support
Canon Printer Support
Contact Printer Support
Dell Printer Support
Epson Printer Support
HP Printer Support
Kodak Printer Support
Konica Minolta Printer Support
Kyocera Printer Support
Lanier Printer Support
Lexmark Printer Support
OKI Printer Support
Panasonic Printer Support
Ricoh Printer Support
Samsung Printer Support
Sharp Printer Support
Toshiba Printer Support
Xerox Printer Support
Google Chrome Customer Service
Mozilla Firefox Customer Service
Opera Mini Customer Service
Safari Customer Service
Internet Explorer Customer Service
Seamonkey Customer Service
Microsoft Edge Customer Service
Netscape Browser Customer Service
UC Browser Customer Service
Slimjet Browser Customer Service



4
De: Independent Delhi Escorts Fecha: 2019-01-17 07:51

Myself Reva Datta I am a Model i am working as an independent escorts girl in Delhi NCR area.
Delhi Independent Escorts
Rajouri Garden Escorts
Saket Escorts
Escorts in Mahipalpur
Delhi Escorts
Aerocity Escorts
Karol Bagh Escorts
Independent Escorts in Delhi
Paharganj Escorts
Connaught Place Escorts
Noida Escorts
Vasant Kunj Escorts
Laxmi Nagar Escorts
Nehru Place Escorts



5
De: Escorts In Bangalore Fecha: 2019-01-28 10:48

--Bangalore Escorts--
--Escorts in Bangalore--
--Independent Escorts in Bangalore--
--Escorts in Delhi--
--Escorts in Bangalore--
--Escorts in Bangalore--
--VIP Escorts in Bangalore--
--Escorts in Bangalore--
--Escorts Services in Bangalore--
--Escorts in Bangalore--
--Escorts in Delhi--
--Escorts In Gurgaon--
--Escorts In Rohini--
--Escorts In bangalore--
--Escorts In Delhi--
--Escorts In Aerocity--
--Escorts In Dwarka--
--Escorts In Mahipalpur--
--Escorts In Noida--



6
De: Aisha Paal Fecha: 2019-02-03 09:45

At Aisha paal pune Escorts office, we have the best of magnificence, every one of our models is free pune escorts and they are too world class. You will see magnificence with class with our hot female pune Escorts.
Pune Escorts
Pune Escorts Girls
Escorts Service in Pune
Independent Pune Escorts
Female Pune Escorts
Escorts in Pune
Pune Escort Service
Female Escort in Pune
Picture gallery of Pune Escorts
Pune Escorts photos
real escort photos
Pune Escorts

Our Partner link :-
Pune Escorts
Pune Escort
Escorts in Pune
Escort in Pune
Escorts Pune
Escort Pune
Independent Pune Escorts
Female Pune Escorts
Best Pune Escorts
Pune Escorts Girls
Female Escort in Pune
Escorts service in Pune
Pune Escort services
Call Girls in Pune
Pune Escort Agency
Jaipur Escorts
Nashik Escorts



7
De: felix1seid Fecha: 2019-02-15 08:30

Air Canada Reservations



8
De: mumbai Fecha: 2019-03-06 11:26

You can benefit their administrations in Mumbai and furthermore adjacent spots. On the off chance that you are not in Mumbai and need to appreciate with Mumbai based call young ladies then you can simply book your arrangement. You can generally expect mind breaking administration given by call young ladies in Mumbai. They are actually quite benevolent and they realize great how to awe their customer.
Mumbai Independent Escorts
andheri Escorts
bandra Escorts services



9
De: mumbai escorts Fecha: 2019-03-13 04:47

Neha is an Mumbai Escorts. If you are looking forward to meeting the best Mumbai Call Girls for luxury services then Visit now - For more information Visit Our Website -
Mumbai Independent Escorts
female Escorts in mumbai
Andheri Escorts Services
Bandra Escorts Services
Vashi Escorts Services
Wadala Escorts Services
Juhu call girls
Mira road Escorts Services
Web Development Company
Free Technical Support



10
De: Best Night Clubs near me Fecha: 2019-03-19 11:03

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful

Party Venue Fort Lauderdale
Latin Dance Clubs Kendall
Tapas Menu Lake Charles



11
De: mumbai escorts Fecha: 2019-03-23 09:01

Welcome to Mumbaihotcollection.com, home of the finest Mumbai escorts in Mumbai area. Our Mumbai escorts are the finest Mumbai has to offer and will provide an unforgettable Mumbai Escort experience!
Escorts in mumbai
Escort service in mumbai
Mumbai escorts
Mumbai call girls
Call girls in mumbai
Escorts mumbai
Mumbai escorts services
Gurgaon escorts
Independents mumbai escorts
Mumbai escorts independents
Mumbai Escorts services
Escort service in mumbai
Escorts in delhi
Escort service in delhi
delhi escorts service



Nombre
Correo-e
URL
Dirección IP: 54.242.115.55 (8bf75d471b)
Comentario
¿Cuánto es: diez mil + uno?