Group Abstract Group Abstract

Message Boards Message Boards

0
|
14.8K Views
|
13 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to use Drop with this data?

POSTED BY: Oscar Rodriguez
13 Replies

Hello Marco,

Thank you very much for your help and your explanations, i going to try to aplly the code to my data

greetings

POSTED BY: Oscar Rodriguez

Hi Oscar,

the StringContainsQ is only there because the search string contains spaces etc. If you take the exact search string and "double equal" it to #[[7]] it should work, too. If you had MMA10 the StringContainsQ function is slightly better, becaus it gives the result you want and also caters for cases where spaces etc are not always entered in the same way.

Cheers, Matco

POSTED BY: Marco Thiel

Hello David,

I appreciate your help, now i'm going to replicate the code with my data.

Thank you very much

POSTED BY: Oscar Rodriguez
Posted 11 years ago

Thanks Marco,

Unfortunately StringContainsQ is only available in Mathe 10, but i only have acces to version 9

Thank you

POSTED BY: Updating Name
Posted 11 years ago

Just what I was doing! The attached file uses a select similar to Marco's. You will find it in the last section.

Attachments:
POSTED BY: David Keith

What about

Part[Select[data, (#[[1]] == "1 VTS" && StringContainsQ[#[[7]], "Female"]) &], All]

Cheers,

Marco

POSTED BY: Marco Thiel
Attachments:
POSTED BY: Oscar Rodriguez
Posted 11 years ago

Select can be used outside of query, and was available much earlier.

In[1]:= Vts = {{"1 VTS", 2., 2., 5., 2., 5., "Female"}, {"1 VTS", 2., 
    2., 5., 2., 5., "Male"}, {"1 VTS", 2., 2., 5., 2., 5., "Female"}};

In[2]:= Select[Vts, #[[7]] == "Female" &]

Out[2]= {{"1 VTS", 2., 2., 5., 2., 5., "Female"}, {"1 VTS", 2., 2., 
  5., 2., 5., "Female"}}

In[3]:= (* Note:  #[[7]]\[Equal]"Female"& is a "pure function" *)
POSTED BY: David Keith

Hello Okkes,

I was trying the code but i did not work, i think that i am doing something wrong (i am learning). I would like to add the notebook and the excel file, probably i'll understand better with the code in the notebook

Thank you

Attachments:
POSTED BY: Oscar Rodriguez

Hello Emmerson,

I tried what you show me, but i did not work, then i realise that Query is an option only in mathematica 10 and for now i have access to mathematica 9. There is a similar option in mathematica 9?

I'll add the excel file and the notebook, probably it will help

Thank you

Attachments:
POSTED BY: Oscar Rodriguez

Query makes this sort of task easy.

Vts = {{"1 VTS", 2., 2., 5., 2., 5., "Female"},
   {"1 VTS", 2., 2., 5., 2., 5., "Male"},
   {"1 VTS", 2., 2., 5., 2., 5., "Female"}};
Query[Select[#[[7]] == "Female" &], 2]@Vts

A slight modification will give the total.

Query[Select[#[[7]] == "Female" &] /* Total, 2]@Vts
POSTED BY: Emerson Willard
Posted 11 years ago

deleted..

POSTED BY: Okkes Dulgerci
Posted 11 years ago
Vts = {{2, 1, 3, f}, {7, 1, 4, m}, {1, 4, 8, f}, {3, 4, 7, f}};
v = Select[Vts, MemberQ[#, f] &]
{{2, 1, 3, f}, {1, 4, 8, f}, {3, 4, 7, f}}
v[[All, 2]]
{1, 4, 4}

Replace f by Female

POSTED BY: Okkes Dulgerci
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard